nsimage

Changing the Color Space of NSImage

混江龙づ霸主 提交于 2019-12-22 09:56:59
问题 Is there a way I can change the color space of an NSimage or NSBitmapImageRep/CGimage or the like. I am open to any way. Preferably the way photoshop does it. 回答1: CGImageRef CGImageCreateCopyWithColorSpace ( CGImageRef image, CGColorSpaceRef colorspace ); To get a CGColorSpaceRef, you can do things like CGColorSpaceRef CGColorSpaceCreateDeviceRGB(); OR see this page for how to create other color spaces. 回答2: The problem with the code you see below CGImageRef CGImageCreateCopyWithColorSpace (

NSImage from a 1D pixel array?

China☆狼群 提交于 2019-12-20 10:58:20
问题 I have a large 1D dynamic array in my program that represents a FITS image on disk i.e. it holds all the pixel values of the image. The type of the array is double . At the moment, I am only concerned with monochrome images. Since Cocoa does not support the FITS format directly, I am reading in the images using the CFITSIO library. This works - I can manipulate the array as I wish and save the result to disk using the library. However, I now want to display the image. I presume this is

Flip NSImage on both axes

喜你入骨 提交于 2019-12-19 07:26:25
问题 I'm trying to flip an NSImage created with a NSImageBitmapRep representation. After some digging (Flipping Quicktime preview & capture and Mirroring CIImage/NSImage) I tried two ways via a CIImage and applying a scaling transformation with -1 for both factors. First using CIImage imageByApplyingTransform: NSBitmapImageRep *imgRep = ... CGImageRef cgi = [imgRep CGImage]; CIImage *cii = [CIImage imageWithCGImage:cgi]; CGAffineTransform at = CGAffineTransformTranslate(CGAffineTransformMakeScale(

how to change image resolution in objective-c

China☆狼群 提交于 2019-12-18 12:37:15
问题 I need to change the resolution of the existing image in objective-c just like Apple's Preview application Tools->Adjust Size...->Resolution. Please let me know the possible solutions. 回答1: Here's a great sample I've used - http://weblog.scifihifi.com/2005/06/25/how-to-resize-an-nsimage/ From that sample, you can write resizedData to the file - and this will be a resized output in tiff format. UPDATE: here comes the NSImage category implementation, that allows to save NSImage instance with

How to draw a NSImage like images in NSButtons (with a deepness)?

元气小坏坏 提交于 2019-12-18 09:58:26
问题 Is there any way to draw an NSImage like images in NSButtons or other cocoa interface elements? Here are examples: Apple uses pdf's with black icons: 回答1: If you simply want this effect to be applied when you use your own images in a button, use [myImage setTemplate:YES] . There is no built-in way to draw images with this effect outside of a button that has the style shown in your screenshots. You can however replicate the effect using Core Graphics. If you look closely, the effect consists

Turning an NSImage* into a CGImageRef?

我们两清 提交于 2019-12-17 22:25:45
问题 Is there an easy way to do this that works in 10.5? In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like that setup... Is there a general way of doing this? I need to do this because I have an IKImageView that seems to only want to add CGImages, but all I've got are NSImages. Currently, I'm using a private setImage:(NSImage*) method that I'd REALLY

NSImage to cv::Mat and vice versa

你。 提交于 2019-12-17 17:59:11
问题 while working with OpenCV I need to convert a NSImage to an OpenCV multi-channel 2D matrix (cvMat) and vice versa. What's the best way to do it? Greets, Dom 回答1: Here's my outcome, which works pretty well. NSImage+OpenCV.h: // // NSImage+OpenCV.h // #import <AppKit/AppKit.h> @interface NSImage (NSImage_OpenCV) { } +(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat; -(id)initWithCVMat:(const cv::Mat&)cvMat; @property(nonatomic, readonly) cv::Mat CVMat; @property(nonatomic, readonly) cv::Mat

NSImage to cv::Mat and vice versa

南楼画角 提交于 2019-12-17 17:59:06
问题 while working with OpenCV I need to convert a NSImage to an OpenCV multi-channel 2D matrix (cvMat) and vice versa. What's the best way to do it? Greets, Dom 回答1: Here's my outcome, which works pretty well. NSImage+OpenCV.h: // // NSImage+OpenCV.h // #import <AppKit/AppKit.h> @interface NSImage (NSImage_OpenCV) { } +(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat; -(id)initWithCVMat:(const cv::Mat&)cvMat; @property(nonatomic, readonly) cv::Mat CVMat; @property(nonatomic, readonly) cv::Mat

How to save a NSImage as a new file

◇◆丶佛笑我妖孽 提交于 2019-12-17 03:46:37
问题 How can I save a NSImage as a new file (png, jpg, ...) in a certain directory? 回答1: Do something like this: NSBitmapImageRep *imgRep = [[image representations] objectAtIndex: 0]; NSData *data = [imgRep representationUsingType: NSPNGFileType properties: nil]; [data writeToFile: @"/path/to/file.png" atomically: NO]; 回答2: You could add a category to NSImage like this @interface NSImage(saveAsJpegWithName) - (void) saveAsJpegWithName:(NSString*) fileName; @end @implementation NSImage

Mirroring CIImage/NSImage

烈酒焚心 提交于 2019-12-13 05:14:59
问题 Currently I have the following CIImage *img = [CIImage imageWithCVImageBuffer: imageBuffer]; NSCIImageRep *imageRep = [NSCIImageRep imageRepWithCIImage:img]; NSImage *image = [[[NSImage alloc] initWithSize: [imageRep size]] autorelease]; [image addRepresentation:imageRep]; This works perfectly, I can use the NSImage and when written to a file the image is exactly how I need it to be. However, I'm pulling this image from the users iSight using QTKit, so I need to be able to flip this image