Questions tagged [nsbitmapimagerep]

The NSBitmapImageRep class renders an image from bitmap data. Bitmap data formats supported include GIF, JPEG, TIFF, PNG, and various permutations of raw bitmap data.

The NSBitmapImageRep class renders an image from bitmap data. If a coverage (alpha) plane exists, a bitmap’s color components are premultiplied with it. If you modify the contents of the bitmap, you are therefore responsible for premultiplying the data. For this reason, though, if you want to manipulate the actual data, an NSBitmapImageRep object is not recommended for storage. If you need to work with data that is not premultiplied, you should use Quartz, specifically CGImageCreate with kCGImageAlphaLast.

More : NSBitmapImageRep Class Reference

56 questions
31
votes
6 answers

How to save PNG file from NSImage (retina issues)

I'm doing some operations on images, and after I'm done, I want to save the image as PNG on the disk. I'm doing the following: + (void)saveImage:(NSImage *)image atPath:(NSString *)path { [image lockFocus] ; NSBitmapImageRep…
Ludovic Landry
  • 11,606
  • 10
  • 48
  • 80
16
votes
3 answers

NSImage to NSBitmapImageRep

How to convert NSImage to NSBitmapImageRep? I have code: - (NSBitmapImageRep *)bitmapImageRepresentation { NSBitmapImageRep *ret = (NSBitmapImageRep *)[self representations]; if(![ret isKindOfClass:[NSBitmapImageRep class]]) { …
hockeyman
  • 1,141
  • 6
  • 27
  • 57
10
votes
3 answers

How to create 8-, 4-, and 1-bit representations of NSImage

I had created 32 bit NSImage with following code. NSBitmapImageRep *sourceRep = [[NSBitmapImageRep alloc] initWithData: imageData]; // create a new bitmap representation scaled down NSBitmapImageRep *newRep = …
NewStack
  • 990
  • 8
  • 19
7
votes
1 answer

Using CALayer's renderInContext: method with geometryFlipped

I have a CALayer (containerLayer) that I'm looking to convert to a NSBitmapImageRep before saving the data out as a flat file. containerLayer has its geometryFlipped property set to YES, and this seems to be causing issues. The PNG file that is…
ndg
  • 2,585
  • 2
  • 33
  • 58
7
votes
5 answers

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…
Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
5
votes
2 answers

cocoa: Read pixel color of NSImage

I have an NSImage. I would like to read the NSColor for a pixel at some x and y. Xcode seems to thing that there is a colorAtX:y: method on NSImage, but this causes a crash saying that there is no such method for NSImage. I have seen some examples…
mtmurdock
  • 12,756
  • 21
  • 65
  • 108
4
votes
1 answer

How to convert 256 colors palettized RGBA image data to NSImage

I'm a newbie developer and I need your help with something that is probably trivial for you. I have an image data in this pixel format: 256 colors palettized RGBA. It comes from FFmpeg (PIX_FMT_PAL8) and it's explained this way: PIX_FMT_RGB32 is…
Andrea3000
  • 1,018
  • 1
  • 11
  • 26
4
votes
1 answer

setColor on NSBitmapImageRep not working in Swift

I'm trying to figure out how setColor works. I have the following code: lazy var imageView:NSImageView = { let imageView = NSImageView(frame: view.frame) return imageView }() override func viewDidLoad() { …
Ben A.
  • 874
  • 7
  • 23
4
votes
3 answers

How to create NSBitmapImageRep from scratch?

First off: I want to use NSBezierPath to draw some simple button artwork in my app, so I figure I should create an NSBitmapImageRep, get the CGImage, create an NSImage from that, and then call setImage: on the button. Correct me if I'm wrong. So I…
PopKernel
  • 4,110
  • 5
  • 29
  • 51
4
votes
2 answers

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…
user256411
  • 51
  • 3
4
votes
1 answer

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: -…
danwood
  • 1,512
  • 1
  • 10
  • 27
3
votes
2 answers

Is it possible to make a NSBitmapImageRep with 24 bpp and no alpha channel?

I don't understand really well the premultiplied alpha. I need a NSBitmapImageRep without alpha channel (I don't need a particular bpp). My problem is that this code give me errors: NSSize imageSize = NSMakeSize(200, 200); //create a non-alpha RGB…
PabloLerma
  • 620
  • 5
  • 12
3
votes
1 answer

Objective-C: NSBitmapImageRep SetColor

I'm trying to read an NSImage into an NSBitmapImageRep, for changing the color of some pixels. The Program should read the Color-Value of each pixel, and check if its equal to a color which is selected by a colorwell. I've got an ImageView named…
3
votes
1 answer

Can't create an NSBitmapImageRep in Swift

I've got an osx xcode project created with xcode 6.1 I wanted to use it to train using with SWIFT a little bit. In one of my views I tried creating an NSBitMapImageRep as seen here: class BitmapView : NSView { var image: NSBitmapImageRep! override…
Infinite
  • 2,931
  • 2
  • 27
  • 33
2
votes
2 answers

NSBitmapImageRep to RGB with high efficency

I am working on my first mac osx cocoa app for 10.5+ where I have a CVImageBufferRef (captured using QTKit), I need to transfer this image over TCP Socket to the client app. The client app needs RGB values. So here is what I am currently doing (my…
Abduliam Rehmanius
  • 928
  • 12
  • 23
1
2 3 4