[futurebasic] Re: [FB] re: Incorporating images using FBtoC

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2013 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Tue, 30 Apr 2013 00:37:20 -0400
That's purty and modern retro.

Now simplify the FB Editor. :)

rc

On Apr 29, 2013, at 11:14 PM, Ken Shmidheiser <kshmidheiser@...> wrote:

> My belated contribution as a single function.
> 
> Ken
> 
> 
> include "Tlbx MoreFilesX.incl"
> 
> include resources "test.jpg"
> 
> local fn ResourceImageToPICTHandle( imageName as CFStringRef, imageRect as ^rect ) as handle
> '~'1
> dim as GraphicsImportComponent gi
> dim as ComponentResult         result
> dim as PicHandle               pictH : pictH = NULL
> dim as CFURLRef                url
> dim as FSRef                   fsRef
> dim as FSSpec                  fsSpec
> dim as OSErr                   err
> dim as Boolean                 success
> 
> url = fn CFBundleCopyResourceURL( fn CFBundleGetMainBundle(), imageName, 0, 0 )
> long if ( url )
> success = fn CFURLGetFSRef( url, @fsRef )
> CFRelease( url )
> long if ( success )
> err = fn FSGetCatalogInfo( @fsRef, _kFSCatInfoNone, NULL, NULL, #fsSpec, NULL )
> long if ( err == _noErr )
> err = fn GetGraphicsImporterForFile( fsSpec, gi )
> long if ( err == _noErr )
> result = fn GraphicsImportGetAsPicture( gi, pictH )
> result = fn GraphicsImportGetBoundsRect( gi, #imageRect )
> err = fn CloseComponent( gi )
> end if
> end if
> end if
> end if
> end fn = (handle)pictH     // User must dispose
> 
> dim as handle pictH
> dim as rect   r
> 
> pictH = fn ResourceImageToPICTHandle( @"test.jpg", @r )
> window 1, "Show Image", @r
> picture ( r.top, r.left ) - ( r.right, r.bottom ), pictH
> fn DisposeH( pictH )
> 
> RunApplicationEventLoop()
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
> To access the list archives, go to:  http://freegroups.net/groups/futurebasic/
>