• 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: Create NSImage from array of integers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create NSImage from array of integers


  • Subject: Re: Create NSImage from array of integers
  • From: David Spooner <email@hidden>
  • Date: Wed, 31 Oct 2007 17:16:14 -0600


Wouldn't a more direct approach be to create an NSBitmapImageRep from the bitmapData using -initWithBitmapDataPlanes:... and then use NSImage -initWithSize: and -addRepresentation:?


dave


On 31-Oct-07, at 4:14 PM, Bill Dudney wrote:

Hi Jason,

This is a job for Quartz i believe.

If you know the exact pixel layout and such I'd think you could create a bitmap context and then get the image from that;

void* bitmapData = load your array of ints;
CGContextRef context = CGBitmapContextCreate(bitmapData, size.width, size.height, bitsPerComponent, bytesPerRow, CGColorSpaceCreateWithName(kCGColorSpaceGenericGray), kCGImageAlphaNone);
image = CGBitmapContextCreateImage(context);


I think this will work. You might have to tweak some of the args to the context create to get it to draw properly.

Good Luck,

-bd-
http://bill.dudney.net/roller/objc

On Wednesday, October 31, 2007, at 03:13PM, "Jason Horn" <email@hidden > wrote:
I need some help creating an NSBitmapImageRep or an NSImage from a
proprietary file. I have figured out how to load the data from the
file into an array of integers.  I'm not sure what to do from there.
The image is a greyscale image with 16 bit integers (unsigned int).
Separately, I have the dimensions of the image (640 x 480).

Any thoughts?

Thanks,

- Jason

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Create NSImage from array of integers
      • From: Troy Stephens <email@hidden>
References: 
 >Create NSImage from array of integers (From: Jason Horn <email@hidden>)
 >Re: Create NSImage from array of integers (From: Bill Dudney <email@hidden>)

  • Prev by Date: [Leopard] Core Data model versioning vs. NSPersistentDocument
  • Next by Date: Re: Create NSImage from array of integers
  • Previous by thread: Re: Create NSImage from array of integers
  • Next by thread: Re: Create NSImage from array of integers
  • Index(es):
    • Date
    • Thread