[futurebasic] Re: [FB] Incorporating External Frameworks into an FB Project

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 5 May 2013 06:53:26 -0400
Steve wrote:

> I'm now left with one error message:…


I'm attending a convention today and will be out of pocket, but I'm guessing you built your headers in Xcode to the default iOS settings rather than for the Mac OS. Running the Objective-C code you sent me back channel seems to indicate that at least your code recognizes the library-- which is a good thing.

Following is the testbed I have been using in an attempt to generate a 21 x 21 QRCode in an FB window for the phrase "This is a test." I have no idea this could ever work since the first step has to be getting the library to work. I am posting this for those who might like the challenge of attempting to solve the framework question.



 * ApplicationServices.framework
 * CoreMedia.framework
 * CoreVideo.framework
 * QuartzCore.framework
 * QTKit.framework

Add this line in FBtoC prefs:

F../ -framework ZXingObjC -framework ApplicationServices -framework CoreMedia -framework CoreVideo -framework QuartzCore -framework QTKit



compile as "Objective-C"

include resources "ZXingObjC.framework"
// include resources "ZXingObjCHeaders"

include library "ZXingObjC"

include "Tlbx MoreFilesX.incl"
include "Tlbx CoreGraphics.incl"

#import "<ZXingObjC/ZXingObjC.h>"

CGImageRef CreateQRCodeImage( CFStringRef stringToEncode );
Boolean CGImageRefToPICT(CGImageRef ref, PicHandle *hPic);

CGImageRef CreateQRCodeImage( CFStringRef stringToEncode ) {
NSError              *error = nil;
ZXMultiFormatWriter  *writer;
ZXBitMatrix          *result;
CGImageRef            image = nil;

writer = [[ZXMultiFormatWriter alloc] init];

result = [writer encode:(NSString)stringToEncode format:kBarcodeFormatQRCode width:21 height:21 error:&error];

if (result)
         // image = [[ZXImage imageWithMatrix:result] cgimage];
     } else {
         NSLog(@"error: %@", error);
return image;

Boolean CGImageRefToPICT( CGImageRef ref, PicHandle *hPic ) {
CGImageDestinationRef dest;
CFMutableDataRef      data;
Boolean               success = false;
Handle                h = nil;
Size                  len;
if ((data = CFDataCreateMutable( NULL, 0 )))
  if ((dest = CGImageDestinationCreateWithData( data, kUTTypePICT, 1, NULL )))
     CGImageDestinationAddImage( dest, ref, NULL );
     success = CGImageDestinationFinalize( dest );
     CFRelease( dest );
          if ( success )
               if (( h = NewHandle( len = CFDataGetLength( data ))))
               CFDataGetBytes( data, CFRangeMake( 0, len ), ( UInt8 *) *h );
               else success = false;
*hPic = ( PicHandle )h;
return success;

toolbox fn CreateQRCodeImage( CFStringRef stringToEncode ) = CGImageRef
toolbox fn CGImageRefToPICT( CGImageRef ref, PicHandle *hPic ) = Boolean

dim as CGImageRef  qrImage
dim as handle      pictH
dim as rect        r
dim as boolean     success

// Generate a 21 x 21 QRCode for the phrase "This is a test"
qrImage = fn CreateQRCodeImage( @"This is a test" )
success = fn CGImageRefToPICT( qrImage, pictH )

window 1, "Show Image", @r
picture ( r.top, r.left ) - ( r.right, r.bottom ), pictH
fn DisposeH( pictH )