On Sep 27, 2009, at 9:42 PM, Brian Stevens wrote: > > On Sep 27, 2009, at 5:28 PM, Robert Covington wrote: > >> >> On Sep 27, 2009, at 7:29 PM, WinGammon@... wrote: >> >>> Is there a replacement for USR IMAGEFILETOPICT? Or does someone >>> have some code that does the same thing? >> >> From the caveman non-exact sciences dept... >> ...just an un-encapsulation of the runtime code, tested to work. >> But gets the rect while it is at it. >> >> >> However, there are a few GCC warnings from the pointerwhacking with >> r (rect) >> >> r >> c >> >> local >> dim AS HANDLE @myPict >> dim as GraphicsImportComponent @grphImpComp >> dim as ComponentResult crslt >> dim as OSERR err >> Local Fn CustomFSIMAGEFILETOPICT(fSpec as ^FSSpec, r as ^Rect) >> '~'1 >> myPict = 0 >> long if fn GetGraphicsImporterForFile(#fSpec, grphImpComp) = >> _noErr // if error, then try @myFileSpec, or #myFileSpec >> crslt = fn GraphicsImportGetBoundsRect(grphImpComp,#r) >> crslt = FN GraphicsImportGetAsPicture(grphImpComp,myPict) >> err = fn CloseComponent(grphImpComp) >> end if >> >> end fn = myPict >> >> >> dim fs as FSSpec >> dim fname$ >> dim pictH as handle >> dim r as rect >> >> SetRect(r,0,0,400,400) >> >> fName$ = Files$(_FSSpecOpenPreview,"" ,"", fs) >> >> long if fName$ >> >> pictH = Fn CustomFSIMAGEFILETOPICT(fs,@r) >> >> long if pictH >> >> Window 1,"Test",@r >> >> drawpicture(pictH,r) >> Killpicture(pictH) >> >> end if >> >> end if >> >> do >> handleEvents >> until gFBQuit >> > > > David, > > If you're loading images out of your application bundle, what RC > posted is good but would need to preceded by getting a spec to it. > That would involve : > > fn CFBundleGetMainBundle // get a CFBundleRef > fn CFBundleCopyResourceURL // get a url for the bundleRef > fn CFURLGetFSRef // get an FSRef for the url > fn FSGetCatalogInfo // get an FSSpec for the FSRef - one of the > few times when a spec is needed > > then make the GraphicsImporter calls as shown by RC. > > > Brian S Steve Van Voorst also posted a nice demo for retrieving images ( back in May this year ) using CGImagexxxxx calls. They don't require FSSpecs. Steve made this public ( and was in response to my request ) and could be re-posted if you can't find it. Brian S