Re: NSImage from Palm Bitmap?
Re: NSImage from Palm Bitmap?
- Subject: Re: NSImage from Palm Bitmap?
- From: John Randolph <email@hidden>
- Date: Tue, 2 Sep 2003 15:03:20 -0700
On Aug 31, 2003, at 4:23 PM, Dave Riggle wrote:
Anybody know how to create an NSImage from a Palm Bitmap? I tried the
following, but it doesn't work.
NSImage *PalmBitmapToNSImage(NSData *palmBmp)
{
PalmBitmapTypeV2_16 *bmp = (PalmBitmapTypeV2_16 *) [palmBmp bytes];
unsigned char *bits = (unsigned char *) bmp +
sizeof(PalmBitmapTypeV2_16);
NSImage* image;
NSBitmapImageRep *bitmap;
bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: &bits
pixelsWide: bmp->width pixelsHigh:
bmp->height
bitsPerSample: 5 samplesPerPixel: 3
hasAlpha: NO isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: bmp->rowBytes bitsPerPixel:
bmp->pixelSize];
image = [[NSImage alloc] initWithSize:NSMakeSize(bmp->width,
bmp->height)];
[image addRepresentation:bitmap];
[bitmap release];
return image;
}
The Palm bitmap I want to load is in 16 bit RGB565 format.
You'll need to expand that to 24-bits. NSBitmapImageRep doesn't deal
with any packed-pixel formats, AFAIK.
-jcr
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.