nsimagerep

NSImage size is wrong

一个人想着一个人 提交于 2019-12-24 13:52:48
问题 I think i'm missing something really basic here. If I do this with a legal URL/path which I know exists: NSImage* img = [[NSImage alloc] initWithContentsOfFile:[[selectedItem url] path]]; NSLog(@"Image width: %d height: %d", [img size].width, [img size].height); then I get reported to the console that the width is -2080177216 and the height 0. Although I know that the width is actually 50 and the height 50. I tried calling isValid and it returns YES, and I also tried checking the size of the

How to Implement Custom Image representation for NSImage

梦想的初衷 提交于 2019-12-08 05:34:14
问题 I am developing an application to draw and process specific image format not currently supported by the NSimage class. In this specific format, the images are in form of a 1D binary table preceded by an ASCII header which describe the data (number dimension, image size, bit per pixel, ...). I read in the Coco Drawing Guide that it is possible to create new image representation. I am new in Coca and Objectiv-C programming and, on this topic, I find the Coco Drawing Guide explanation very short

Create and write paletted RGBA PNG using NSImage

ぐ巨炮叔叔 提交于 2019-12-01 14:08:43
I'm trying to create paletted PNG image (8-bit per pixel) that uses RGBA palette (32-bit per palette entry) using Cocoa framework*. I've tried few combinations for [NSBitmapImageRep initWithBitmapDataPlanes:…] method. It seems to create appropriate bitmap for bitsPerSample:2 bitsPerPixel:8 . However, when I try to write such bitmap with [NSBitmapImageRep representationUsingType:NSPNGFileType…] I get: libpng error: Invalid bit depth for RGBA image If I try other bit depths, then I get 32-bit per pixel (non-paletted) image. *) I know I could just use libpng , but that's not an answer I'm looking

Create and write paletted RGBA PNG using NSImage

99封情书 提交于 2019-12-01 12:43:47
问题 I'm trying to create paletted PNG image (8-bit per pixel) that uses RGBA palette (32-bit per palette entry) using Cocoa framework*. I've tried few combinations for [NSBitmapImageRep initWithBitmapDataPlanes:…] method. It seems to create appropriate bitmap for bitsPerSample:2 bitsPerPixel:8 . However, when I try to write such bitmap with [NSBitmapImageRep representationUsingType:NSPNGFileType…] I get: libpng error: Invalid bit depth for RGBA image If I try other bit depths, then I get 32-bit