• 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: David Blanton <email@hidden>
  • Date: Wed, 6 Jan 2010 11:19:20 -0700

OK.

So, from other comments I made some changes.

1. Correctly set the dimensions by using m_bitmap.m_pixelsx and m_bitmap.m_pixelsy (these are members of our portable bitmap class).


m_NSBitmapImageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:m_ptrs pixelsWide:m_bitmap.m_pixelsx pixelsHigh:m_bitmap.m_pixelsy bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bitmapFormat:NSAlphaFirstBitmapFormat bytesPerRow:(4 * m_bitmap.m_pixelsx) bitsPerPixel:32];


And changed the drawInRect to draw in the views bounds

- (void)drawRect:(NSRect)dirtyRect {

	NSRect bounds = [self bounds];
	[NSGraphicsContext saveGraphicsState];
	[m_NSBitmapImageRep drawInRect:bounds];
	[NSGraphicsContext restoreGraphicsState];
}

Now, from David Duncan's comment.

My bitmap data does have alpha, i.e 4 samples per pixel ARGB. I thought kCGImageAlphaNoneSkipFirst says don't make an alpha plane, skip byte 1 and go to RED.

I am not sure how to specify this in the 'bitmapFormat' parameter.


On Jan 6, 2010, at 10:35 AM, David Duncan wrote:

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

	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];

This code creates a bitmap with alpha.

context = CGBitmapContextCreate (bitmap.m_array, bitmap.m_pixelsx, bitmap.m_pixelsy, 8, bitmap.m_pixelsx * 4, colorSpace, kCGImageAlphaNoneSkipFirst|kCGBitmapByteOrder32Host);

This code creates a bitmap without alpha.

The problem is I just see garbage, no image. Clearly I am doing something wrong with the NSBitMapImageRep but I have no idea what.


Hence garbage.
--
David Duncan
Apple DTS Animation and Printing




_______________________________________________

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: NSBitMapImageRep Woes
      • From: David Duncan <email@hidden>
References: 
 >NSBitMapImageRep Woes (From: David Blanton <email@hidden>)
 >Re: NSBitMapImageRep Woes (From: David Duncan <email@hidden>)

  • Prev by Date: Re: NSXMLParser question about duplicate nodes
  • Next by Date: Re: NSBitMapImageRep Woes
  • Previous by thread: Re: NSBitMapImageRep Woes
  • Next by thread: Re: NSBitMapImageRep Woes
  • Index(es):
    • Date
    • Thread