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

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

From: Schwarz Stephanie <sschwarz@...>
Date: Sat, 4 May 2013 06:29:05 +0000
Thank you so much - this does exactly what we were hoping for, and as you say, in one compact function.

(and thank you to Rich and Robert for your assistance as well)

It just makes us realise how much we have to learn. We would have thought we were pretty good programmers!

Stephanie 

________________________________________
From: futurebasic@... [futurebasic@...] on behalf of Ken Shmidheiser [kshmidheiser@...]
Sent: Tuesday, April 30, 2013 1:14 PM
To: futurebasic@...
Subject: [FB] re: Incorporating images using FBtoC

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/