nsimage

Writing image metadata (EXIF/TIFF/IPTC) to image file in OS X

风流意气都作罢 提交于 2019-11-29 14:53:41
问题 I am creating a photo editing app, and so far I've managed to read the metadata from image files successfully (after getting an answer to this question: Reading Camera data from EXIF while opening NSImage on OS X). source = CGImageSourceCreateWithURL((__bridge CFURLRef)url, NULL); NSDictionary *props = (__bridge_transfer NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source, 0, NULL); This copies all the metadata of the image file to a dictionary, and it works faily well. However, I

How to display animated GIF in Objective C on top of the layered View?

心不动则不痛 提交于 2019-11-29 03:50:04
问题 I am trying to draw animated gif on my screen in mac OSX app . I used this code to insert the gif: I can see the Gif as 1 picture it doesn't animates only static picture :( what should I add to make it animated ? #import <Cocoa/Cocoa.h> #import <Quartz/Quartz.h>//for drawing circle #import "sharedPrefferences.h" @interface GenericFanSubView : NSView { NSColor * _backgroundColor; NSImageView* imageView; } - (void)setBackgroundColor :(NSColor*)color; - (void)insertGif1; - (void)insertGif2; -

Converting CIImage Into NSImage

让人想犯罪 __ 提交于 2019-11-29 02:38:11
问题 I'm playing with the Core Image framework. As I understand, if I have an image ( NSImage ), it needs to be converted into CIImage , first. I can do that. NSImage *im1 = [[NSImage alloc] initWithContentsOfFile:imagepath]; NSRect rect1;rect1.size.width = img1.size.width; rect1.size.height = img1.size.height; CGImageRef imageRef1 = [img1 CGImageForProposedRect:&rect1 context:[NSGraphicsContext currentContext] hints:nil]; CIImage *ciimage = [CIImage imageWithCGImage:imageRef1]; I have a function

How to draw a rounded NSImage

自作多情 提交于 2019-11-29 01:12:09
问题 I am trying to create a NSImage or NSImageCell with rounded corners inside a NSTableView . I can't get anything to work. Here is the best I have so far inside my custom NSCell : - (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView { if (thumbnailLink) { NSURL *url = [NSURL URLWithString:thumbnailLink]; if (url) { NSRect imageFrame = [self _imageFrameForInteriorFrame:frame]; NSImage *image = [[NSImage alloc] initWithContentsOfURL:url]; [image setScalesWhenResized:YES];

Swift NSImage to CGImage

故事扮演 提交于 2019-11-28 23:09:02
问题 How can I convert a NSImage to CGImage in Swift? In Objective-C I did it like this: - (CGImageRef)CGImage { NSData *imageData = self.TIFFRepresentation; CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); CGImageRef maskRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); return maskRef; } Now I tried with: extension NSImage { var CGImage: CGImageRef { get { let imageData = self.TIFFRepresentation let source = CGImageSourceCreateWithData(imageData as

Turning an NSImage* into a CGImageRef?

不问归期 提交于 2019-11-28 18:52:15
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 REALLY rather not be using... Found the following solution on this page : NSImage* someImage; // create the

How do I get the icon of the user's Mac?

本小妞迷上赌 提交于 2019-11-28 17:54:26
问题 Using Objective-C and Cocoa, does anyone know how to get the icon for a user's computer (the one that shows under "Devices" and "Network" in Finder)? Not the harddisk icon, the actual one for a user's device. It ranges from a MacBook icon to the Mac Pro icon to a Windows blue screen of death monitor icon. I've tried stuff along the following lines: NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode(kComputerIcon)]; But that just returns the same icon all

NSImage to NSData as PNG Swift

谁都会走 提交于 2019-11-28 13:18:58
I am writing a Mac app based on an iOS app. The code below converts a UIImage to NSData to upload to Parse.com. I would like to do the same for Mac but I do not seem to be able to convert it to NSData. What should I be doing? Thanks var image = UIImage(named: "SmudgeInc") let imageData = UIImagePNGRepresentation(image) let imageFile = PFFile(name:"image.png", data:imageData) You can use the NSImage property TIFFRepresentation to convert your NSImage to NSData : let myImageData = yourImage.TIFFRepresentation! If you need to save your image data to a PNG file you can use NSBitmapImageRep(data:)

NSImage to cv::Mat and vice versa

↘锁芯ラ 提交于 2019-11-28 06:04:51
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 dom 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 CVGrayscaleMat; @end NSImage+OpenCV.mm: // // NSImage+OpenCV.mm // #import "NSImage+OpenCV.h" static void

How do I take a “screenshot” of an NSView?

风格不统一 提交于 2019-11-27 19:54:40
I need to take the contents of an NSView and put them in an NSImage , for an experimental project. Is this possible? I did some Googling, tried two methods that I found - but they didn't really work. Any suggestions? [[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]]; From WWDC 2012 Session 245 (translated to Swift): let viewToCapture = self.window!.contentView! let rep = viewToCapture.bitmapImageRepForCachingDisplayInRect(viewToCapture.bounds)! viewToCapture.cacheDisplayInRect(viewToCapture.bounds, toBitmapImageRep: rep) let img = NSImage(size: viewToCapture.bounds.size