• 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: NSBitMapImageRep Woes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBitMapImageRep Woes


  • Subject: Re: NSBitMapImageRep Woes
  • From: "Henry McGilton (Boulevardier)" <email@hidden>
  • Date: Wed, 6 Jan 2010 09:44:44 -0800

On Jan 6, 2010, at 9:21 AM, David Blanton wrote:

> Here is the code:
>
> @interface MyDocumentView : NSView {
> @public
>
> 	NSBitmapImageRep*	m_NSBitmapImageRep;
> 	NSRect				m_frameRect;
> 	float				m_sz;
> 	BBitmap				m_bitmap;
> 	unsigned char*		m_ptrs[1];
> }
>
> - (void)awakeFromNib {
>
> 	m_ptrs[0] = (unsigned char*)&m_bitmap.m_array;
> 	m_NSBitmapImageRep = [[NSBitmapImageRep alloc]
> 						   initWithBitmapDataPlanes:m_ptrs
> 						   pixelsWide:m_frameRect.size.width
> 						   pixelsHigh:m_frameRect.size.height
> 						   bitsPerSample:8
> 						   samplesPerPixel:4
> 						   hasAlpha:YES
> 						   isPlanar:NO
> 						   colorSpaceName:NSCalibratedRGBColorSpace
> 						   bitmapFormat:NSAlphaFirstBitmapFormat
> 						   bytesPerRow:(4 * m_frameRect.size.width)
> 						   bitsPerPixel:32];
> }

Two questions:

1.    where is    m_frameRect    initialised ?

2.    and are the width and height initialised to the precise number of  bits per row and number of rows
of whatever m_ptrs[0] is pointing at ?

3.    (I said previously I can't count), are there potential endian issues involved ?


>
> - (void)drawRect:(NSRect)dirtyRect {
>
> 	[NSGraphicsContext saveGraphicsState];
> 	[m_NSBitmapImageRep drawInRect:dirtyRect];
> 	[NSGraphicsContext restoreGraphicsState];
> }
>
> m_bitmap.m_array is created in readFromData:ofType:fromFile
>
> I know it is correct because if I use this code I get proper results:(in this case bitmap is a local var but is generated just m_bitmap is.
>
> 	context = CGBitmapContextCreate (bitmap.m_array, bitmap.m_pixelsx, bitmap.m_pixelsy, 8, bitmap.m_pixelsx * 4, colorSpace, kCGImageAlphaNoneSkipFirst|kCGBitmapByteOrder32Host);
> 	CGImageRelease(_cgImageRef);
> 	_cgImageRef =  CGBitmapContextCreateImage (context);
> 	CGImageRetain(_cgImageRef);
> 	CGContextRelease(context);
> 	CGColorSpaceRelease(colorSpace);
>
>
> The problem is I just see garbage, no image.  Clearly I am doing something wrong with the NSBitMapImageRep but I have no idea what.
>
> Please comment!
>



=================================================
iPhone App Development and Developer Education . . .
        Visit  www.nonatomic-retain.com

Mac OSX Application Development, Plus a Great Deal More . . .
        Visit  www.trilithon.com

_______________________________________________

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

References: 
 >NSBitMapImageRep Woes (From: David Blanton <email@hidden>)

  • Prev by Date: Re: NSBitMapImageRep Woes
  • Next by Date: Re: Printing doc file using cocoa
  • Previous by thread: Re: NSBitMapImageRep Woes
  • Next by thread: Re: NSBitMapImageRep Woes
  • Index(es):
    • Date
    • Thread