Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create NSImage from array of integers




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to 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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.