nsimage


NSButton setImage not working

半城伤御伤魂 提交于 2020-01-25 10:37:08
问题 I am trying to change the image of my nsbutton for my application. I have searched and found a couple of ways to do so but none of them are working for me at the moment. I have looked at the following solutions : How to set NSButton background image Using -setImage on NSButton I have a routine that is called when I click the button : - (IBAction)pauseResumeButtonAction:(id)sender { IAgentInterface* agentInterface = ioc::Container::Resolve(); if (self.pauseResumeSwitch == PauseResumeSwitch:

UIImage vs NSImage: Drawing to an off screen image in iOS

半世苍凉 提交于 2020-01-22 11:50:06
问题 In mac osx (cocoa), It is very easy to make a blank image of a specific size and draw to it off screen: NSImage* image = [[NSImage alloc] initWithSize:NSMakeSize(64,64)]; [image lockFocus]; /* drawing code here */ [image unlockFocus]; However, in iOS (cocoa touch) there does not seem to be equivalent calls for UIImage. I want to use UIImage (or some other equivalent class) to do the same thing. That is, I want to make an explicitly size, initially empty image to which I can draw using calls

UIImage vs NSImage: Drawing to an off screen image in iOS

独自空忆成欢 提交于 2020-01-22 11:48:39
问题 In mac osx (cocoa), It is very easy to make a blank image of a specific size and draw to it off screen: NSImage* image = [[NSImage alloc] initWithSize:NSMakeSize(64,64)]; [image lockFocus]; /* drawing code here */ [image unlockFocus]; However, in iOS (cocoa touch) there does not seem to be equivalent calls for UIImage. I want to use UIImage (or some other equivalent class) to do the same thing. That is, I want to make an explicitly size, initially empty image to which I can draw using calls

Cocoa - Fade between two NSImage's?

不问归期 提交于 2020-01-14 18:55:15
问题 I have a menu with an NSImage showing some information, and when it gets updated I would like the new (updated) image to fade in. I know it is easy on the iPhone, but is this possible in OS X ? 回答1: It depends on how your menu is showing the image. If it's the menu item itself, this isn't possible without a lot of hackery. If you're using a custom NSView in the menu, then you can use two NSImageViews and swap between them using the view's -animator. You'd match imageViewB's frame to

Loading NSImage with imageNamed from xcassets crash in older osx versions

≯℡__Kan透↙ 提交于 2020-01-14 07:34:07
问题 So, I have an xcassets that is shared amongst quite a few apps. I'm developing with Xcode8 in a Mac Mini with MacOs Sierra installed in it. If I compile and run in the development machine, there's no issue at all. However, when I try to run it in a device with OSX Mavericks I get a crash. Here's the trace in the report Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x00007fff887dc866 __pthread_kill + 10 1 libsystem_pthread.dylib 0x00007fff87a3935c pthread

NSImage doesn't scale

守給你的承諾、 提交于 2020-01-11 18:35:51
问题 I'm developing a quick app in which I have a method that should rescale a @2x image to a regular one. The problem is that it doesn't :( Why? -(BOOL)createNormalImage:(NSString*)inputRetinaImagePath { NSImage *inputRetinaImage = [[NSImage alloc] initWithContentsOfFile:inputRetinaImagePath]; NSSize size = NSZeroSize; size.width = inputRetinaImage.size.width*0.5; size.height = inputRetinaImage.size.height*0.5; [inputRetinaImage setSize:size]; NSLog(@"%f",inputRetinaImage.size.height);

Resizing Large Resolution Images Producing 1000x1000 Pixels Size when Size is set to 500x500 Pixels

柔情痞子 提交于 2020-01-11 14:52:27
问题 Im using the following extension method to resize an image.When it comes to large resolution images the output size remains 1000x1000 pixels even when I set the output size to 500x500 pixels extension NSImage { func resizeImage(width: CGFloat, _ height: CGFloat) -> NSImage { let img = NSImage(size: CGSize(width:width, height:height)) img.lockFocus() let ctx = NSGraphicsContext.current ctx?.imageInterpolation = .high self.draw(in: NSMakeRect(0, 0, width, height), from: NSMakeRect(0, 0, size

Adorning screenshots with NSStrings inside an NSImage

天涯浪子 提交于 2020-01-03 06:47:08
问题 I'm trying to grab a screenshot from a NSView, draw a string on top of the screenshot using the NSImage buffer then saving everything. The view grabbed from is a plain NSPanel contentview that hosts a single NSImageView. Unfortunately the output file is my string on an all black background with no sign of the screenshot. This is the code: NSImage *screenshot = [[NSImage alloc] initWithData:[mView dataWithPDFInsideRect:[mView bounds]]]; NSString *frameCounterString = @"123"; [screenshot

How to create a ICNS icon programmatically?

▼魔方 西西 提交于 2020-01-01 14:22:07
问题 OK this is what I want : Take some NSImage s Add them to an ICNS file Save it This is what I've done so far (purely as a test) : - (CGImageRef)refFromImage:(NSImage*)img { CGImageSourceRef source; source = CGImageSourceCreateWithData((CFDataRef)[img TIFFRepresentation], NULL); CGImageRef maskRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); return maskRef; } - (void)awakeFromNib { NSImage* img1 = [NSImage imageNamed:@"image1"]; NSImage* img2 = [NSImage imageNamed:@"image2"]; NSLog(@"%@"

cocoa: Read pixel color of NSImage

那年仲夏 提交于 2020-01-01 11:49:17
问题 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 where you create an NSBitmapImageRep and call the same method on that, but I have not been able to successfully convert my NSImage to an NSBitmapImageRep . The pixels on the NSBitmapImageRep are different for some reason. There must be a simple

工具导航Map