nsbitmapimagerep

Why is bitmapImageRepForCachingDisplayInRect: creating an empty image?

I have a very simple bit of code that is supposed to capture the bitmap of a view. This used to work in Leopard, but seems horribly broken in Snow Leopard. Here is the code, responding to a button press on the window: - (IBAction)snapshot:(id)sender { NSView* view = [[sender window] contentView]; NSBitmapImageRep* bitmap = [view b...

NSBitmapImageRep drawing in snow leopard

In MacOS 10.5 (Leopard) and 10.4 (Tiger) the following code was working fine: NSImage *pBitmapImage = [[NSImage alloc] initWithSize:[pThumbBmp size]]; [pBitmapImage addRepresentation:pThumbBmp]; NSSize pThumbSize =[pBitmapImage size]; if(pThumbBmp) { [pThumbBmp release]; pThumbBmp = NULL; } [pBitmapImage lockFocus]; [fillColor...

How to compress jpeg image with Cocoa?

I have an jpeg image and I want to be able to incrementally compress it using Cocoa/Core Image/Core Graphics. For example, I have A.jpg (3MB), I compress A and get B.jpg (1MB), compress B and get C.jpg (400KB), and so on till the image can't be compressed anymore. I am trying to use NSBitmapImageRep representationUsingType:properties w...

Translating clicked NSPoint in NSImageView to correct pixel coordinates in the underlying NSBitmapImageRep

Here is what I'm trying to accomplish: I'm working on an open source TI calculator emulator where I'm currently trying to add skin support. The skin image is just an NSImageView with its image set to the skin image. I override the mouseDown: method and get the location of the mouse in the NSImageView coordinates using convertPointFromBas...

How do I create an 8-bit PNG with transparency from an NSBitmapImageRep?

I have a 32-bit NSBitmapImageRep which has an alpha channel with essentially 1-bit values (the pixels are either on or off). I want to save this bitmap to an 8-bit PNG file with transparency. If I use the -representationUsingType:properties: method of NSBitmapImageRep and pass in NSPNGFileType, a 32-bit PNG is created, which is not what...

Saving NSBitmapImageRep as NSBMPFileType file. Wrong BMP headers and bitmap content

I save a NSBitmapImageRep to a BMP file (Snow Leopard). It seems ok when i open it on macos. But it makes an error on my multimedia device (which can show any BMP file from internet). I cannot figure out what is wrong, but when i look inside the file (with the cool hexfiend app on macos), 2 things wrong: the header have a wrong value ...

Getting into pixel data of NSImage

Hi, I'm writing application that operates on black&white images. I'm doing it by passing a NSImage object into my method and then making NSBitmapImageRep from NSImage. All works but quite slow. Here's my code: - (NSImage *)skeletonization: (NSImage *)image { int x = 0, y = 0; NSUInteger pixelVariable = 0; NSBitmapImageRep *bitm...