nsimageview

Creating memory efficient thumbnails using an NSImageView (cocoa/OSX)

余生长醉 提交于 2019-12-06 07:28:17
I am creating small NSImageViews (32x32 pixels) from large images often 512x512 or even 4096 x 2048 for an extreme test case. My problem is that with my extreme test case, my applicaiton memory footprint seems to go up by over 15MB when I display my thumbnail, this makes me think the NSImage is being stored in memory as a 4096x2048 instead of 32x32 and I was wondering if there is a way to avoid this. Here is the process I go through to create the NsImageView: • First I create an NSImage using initByReferencingFile: (pointing to the 4096x2048 .png file) • Next I initialize the NSImageView with

How can I animate a content switch in an NSImageView?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 01:54:17
问题 I want to switch the image shown in an NSImageView , but I want to animate that change. I've tried various methods to do this. Hopefully one of you could suggest one that might actually work. I'm working with Cocoa for Mac. 回答1: You could implement your own custom view that uses a Core Animation CALayer to store the image. When you set the contents property of the layer, the image will automatically smoothly animate from the old image to the new one. 回答2: As far as I know, NSImageView doesn't

How to create a NSImageView with a rounded corner?

巧了我就是萌 提交于 2019-12-05 05:33:49
Currently now i want to create a round corner NSImageView,i am a newb,how to ? par I don't know if this will work so please try it and we'll cross our fingers. On the iPhone you can use the CALayer of any UIView (the NSView counterpart in iOS) to get rounded corners. Based on the reference docs it appears that NSView supports this but again you'll have to try it. Please let me know if it works. NSImageView *view = your view; [view setWantsLayer: YES]; // edit: enable the layer for the view. Thanks omz view.layer.borderWidth = 1.0; view.layer.cornerRadius = 8.0; view.layer.masksToBounds = YES;

NSImageView double click action

让人想犯罪 __ 提交于 2019-12-05 01:48:58
I have some NSImageView in my Mac App where the user can drag'n drop objects like .png or .pdf, to store them into User Shared Defaults, that works fine. I would now like to set an action for when user double click on these NSImageView, but it seems to be a little bit difficult (I had no trouble for NSTableView, but 'setDoubleAction' is not available for NSImage, and tons of answers (here or with google) concerning NSImageView's actions point to making a NSButton instead of NSImageView, so that doesn't help) Here is part of my AppDelegate.h: @interface AppDelegate : NSObject

How can I animate a content switch in an NSImageView?

坚强是说给别人听的谎言 提交于 2019-12-04 06:28:05
I want to switch the image shown in an NSImageView , but I want to animate that change. I've tried various methods to do this. Hopefully one of you could suggest one that might actually work. I'm working with Cocoa for Mac. You could implement your own custom view that uses a Core Animation CALayer to store the image. When you set the contents property of the layer, the image will automatically smoothly animate from the old image to the new one. As far as I know, NSImageView doesn't support animating image changes. However, you can place a second NSImageView on top of the first one and animate

Getting bounds of an NSImage within an NSImageView

妖精的绣舞 提交于 2019-12-04 03:35:09
I've got an NSImageView that takes up the full extent of a window. There's no border to the image view, and its set to display in the lower left. So this means that the origin of the view matches the origin of actual image, no matter how the window is resized. Also, the image is much larger than what I can reasonably fit at full scale on the screen. So I also have the imageview set to proportionally scale down the size of the image. However, I can't seem to find this scale factor anywhere. My ultimate goal is to map a mouse down event into actual image coordinates. To do this, I think I need

Resize and Save NSImage?

荒凉一梦 提交于 2019-12-03 07:57:48
I have an NSImageView which I get an image for from an NSOpenPanel. That works great. Now, how can I take that NSImage, half its size and save it as the same format in the same directory as the original as well? If you can help at all with anything I'd appreciate it, thanks. Check the ImageCrop sample project from Matt Gemmell: http://mattgemmell.com/source/ Nice example how to resize / crop images. Finally you can use something like this to save the result (dirty sample): // Write to TIF [[resultImg TIFFRepresentation] writeToFile:@"/Users/Anne/Desktop/Result.tif" atomically:YES]; // Write to

NSImageView image aspect fill?

自闭症网瘾萝莉.ら 提交于 2019-12-02 23:02:23
So I am used to UIImageView , and being able to set different ways of how its image is displayed in it. Like for example AspectFill mode etc... I would like to accomplish the same thing using NSImageView on a mac app. Does NSImageView work similarly to UIImageView in that regard or how would I go about showing an image in an NSImageView and picking different ways of displaying that image? Chris Demiris You may find it much easier to subclass NSView and provide a CALayer that does the aspect fill for you. Here is what the init might look like for this NSView subclass. - (id)initWithFrame: