• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImage from Palm Bitmap?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSImage from Palm Bitmap?
      • From: "M. Uli Kusterer" <email@hidden>
  • Prev by Date: Selector runs only once
  • Next by Date: Re: Enough with the newbie C questions!
  • Previous by thread: Re: Selector runs only once
  • Next by thread: Re: NSImage from Palm Bitmap?
  • Index(es):
    • Date
    • Thread