void _HYPlatformGraphicPane::_SavePicture (_String prompt) { InitializeQTExporters (); if (graphicsFormats.lLength) { _String filePath; long menuChoice = SaveFileWithPopUp (filePath, savePicPrompt,prompt,savePicAs,graphicsFormats); if (menuChoice>=0) { ComponentInstance grexc = OpenComponent ((Component)qtGrexComponents(menuChoice)); GraphicsExportSetInputGWorld (grexc,thePane); FSSpec fs; Str255 buff; StringToStr255 (filePath,buff); FSMakeFSSpec(0,0,buff,&fs); GraphicsExportSetOutputFile (grexc,&fs); GraphicsExportRequestSettings (grexc,nil,nil); unsigned long dummy; OSType t,c; GraphicsExportGetDefaultFileTypeAndCreator (grexc,&t,&c); GraphicsExportSetOutputFileTypeAndCreator (grexc,t,c); GraphicsExportDoExport (grexc,&dummy); CloseComponent (grexc); } } }
//------------------------------------------------------------------------ bool pixel_map::save_as_qt(const char *filename) const { FSSpec fss; OSErr err; // get file specification to application directory err = HGetVol(nil, &fss.vRefNum, &fss.parID); if (err == noErr) { GraphicsExportComponent ge; CopyCStringToPascal(filename, fss.name); // I decided to use PNG as output image file type. // There are a number of other available formats. // Should I check the file suffix to choose the image file format? err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePNG, &ge); if (err == noErr) { err = GraphicsExportSetInputGWorld(ge, m_pmap); if (err == noErr) { err = GraphicsExportSetOutputFile (ge, &fss); if (err == noErr) { GraphicsExportDoExport(ge, nil); } } CloseComponent(ge); } } return err == noErr; }