saing files in carbon(QT) from cocoa. help!
saing files in carbon(QT) from cocoa. help!
- Subject: saing files in carbon(QT) from cocoa. help!
- From: eblueBeta <email@hidden>
- Date: Mon, 13 Aug 2001 17:15:08 -0400
problems abound when I try to save a file from cocoa, through carbon.
I want to use the cocoa NSSavePanel class, and its resulting filename
(in an NSString) to determine the filename.
problems are:
1. no documenttation on how to turn a NSString* into an FSSpec
2. a Technote (TN2022) specifically states that FSSpec is dead for file
creation, use the completely undocumented: FileUrl instead.
3. number 2 does not jive with the QuickTime specification at all, it
seems that it Only accepts FSSpec for saving to files
I have made several passes at this, the carbon specification is quite
profuse and disorganized, and the cocoa api's are very little help, in
this area.
the ironic thing is, if my needs were slightly more generic i could use
the universal Quicktime save dialog, which does a ton of work, for me,
but alas it is inadequate for my needs.
here's an example of the structure i need to implement:
- (IBAction)saveButton:(id)sender
{
// variables
NSData* theRep;
Handle h;
NSSavePanel *savePanel;
int result;
GraphicsImportComponent gi = 0;
GraphicsExportComponent ci = 0;
// not variables
savePanel = [NSSavePanel savePanel];
[savePanel setRequiredFileType:@"pct"];
// result = invoke a save dialog
result = [savePanel runModalForDirectory:NSHomeDirectory()
file:[imageName stringValue]];
if (result == NSOKButton)
{
// in here we do our thing
//[savePanel fileName] is the string we want to use
theRep = [[imageView image] TIFFRepresentation]; // use the tiff
ref to make qt import it use tiff bc its supported better in cocoa
PtrToHand([theRep bytes],&h,[theRep length]);
OpenADefaultComponent(GraphicsImporterComponentType,
kQTFileTypeTIFF,&gi);
GraphicsImportSetDataHandle( gi, h);
// at this point i have a handle to the tiff, but no data for
the exporter...
if(GraphicsExporterSetInputGraphicsImporter(ci,gi)) // if i can
get an exporter...
{
// this is where documentation and samples fail to illuminate me
//
//
// i need to make a FSSpec from [savePanel fileName];
// heres an example of what i want to do
GraphicsExportSetOutputFile(ci, FSSpec* theFile);
GraphicsExportWriteOutputData(ci, void *dataPtr, unsigned Long dataSize);
CloseComponent(ci); // dispose of the handle
}
CloseComponent(gi);
if(h) DisposeHandle(h);
}
}
obi wan you are my only hope...