• 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: filling NSImage with binary data from NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filling NSImage with binary data from NSData


  • Subject: Re: filling NSImage with binary data from NSData
  • From: John Stiles <email@hidden>
  • Date: Sun, 07 May 2006 21:10:18 -0700



Lester Dowling wrote:
On 08/05/2006, at 1:24 PM, marc joanisse wrote:

Here's the code so far. It works once but fails when called a second time.

- (void)drawXImage:(int)xSlice
{
NSBitmapImageRep* imageRep;
unsigned char *plane;
int i,j; imageRep=[[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
pixelsWide:256
pixelsHigh:256
bitsPerSample:8
samplesPerPixel:1
hasAlpha:NO
isPlanar:YES
colorSpaceName:NSCalibratedWhiteColorSpace
bytesPerRow:256
bitsPerPixel:0] autorelease];


    NSImage* producedNSImage = [[[NSImage alloc]
initWithSize:NSMakeSize(256, 256)] autorelease];

[producedNSImage addRepresentation:imageRep];
// pointer to the bitmapData
unsigned char *data = [imageRep bitmapData];
// pointer to the portion of vmrData (an NSData object) I want to show
// ***segfault happens here!***



The seg fault happens because the image is not planar. Substitute "isPlanar:NO" because according to the manual:


• The isPlanar argument should be YES if the data components are laid out in a series of separate “planes” or channels (“planar configuration”) and NO if component values are interwoven in a single channel (“meshed configuration”).

Since you have a grayscale image, there is only a single channel.

I would think that a grayscale image could be considered either planar or non-planar.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: filling NSImage with binary data from NSData
      • From: Lester Dowling <email@hidden>
References: 
 >filling NSImage with binary data from NSData (From: "marc joanisse" <email@hidden>)
 >Re: filling NSImage with binary data from NSData (From: "Greg Herlihy" <email@hidden>)
 >Re: filling NSImage with binary data from NSData (From: "marc joanisse" <email@hidden>)
 >Re: filling NSImage with binary data from NSData (From: Lester Dowling <email@hidden>)

  • Prev by Date: Re: filling NSImage with binary data from NSData
  • Next by Date: Re: Application for Specific Processors
  • Previous by thread: Re: filling NSImage with binary data from NSData
  • Next by thread: Re: filling NSImage with binary data from NSData
  • Index(es):
    • Date
    • Thread