nsimageview

NSImageView image aspect fill?

走远了吗. 提交于 2019-12-20 10:30:00
问题 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? 回答1: You may find it much easier to subclass NSView and provide a CALayer that does the aspect fill for

NSImageview change in two active viewcontrollers at a time

强颜欢笑 提交于 2019-12-11 13:39:37
问题 I have two viewcontrollers 1) Profile.h &.m, 2) settings.h &.m. Both have NSimageview, so when i change imageview on settings,thenn at same time how change imageview on opened viewcontroller profile. 回答1: Use notification or Delegate method. Notification method: profile.m -(viewDidLoad) { [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(changeImageview) name:@"changeImage" object: nil]; } -(changeimageView) { //Change Image here } settings.m -(void

Using NSImageView to display multiple images in quick sucession

时光怂恿深爱的人放手 提交于 2019-12-11 03:18:23
问题 I have an application where, in one window, there is an NSImageView. The user should be able to drag and drop ANY FILE/FOLDER (not only images) into the image view, so I subclassed NSImageView class to add support for those types. The reason why I chose an NSImageView instead of a normal view is because I also wanted to display an animation (say an arrow pointing downwards and going up and down) when the user hovers over with files ready to drop. My question is this: what would be the best

Disable user interaction for NSImageView

﹥>﹥吖頭↗ 提交于 2019-12-10 22:59:29
问题 I have 2 sets of images. One set contains draggable ones and other is a static set. I have implemented drag-drop functionality for the draggable images. This is because the images needs to be dragged to static ones which contains matches. Now after placing the dragged image on the static one, there is nothing to do with it, hence I want to disable user interaction for image (since it's still draggable). I have explored several solutions and SO questions here and there , but none of the

Scaled image in NSImageView looks bad with layer-backing on

醉酒当歌 提交于 2019-12-10 11:38:16
问题 I'd like to have a view with a gradient background and a image. So I turned on layer backing for the layer, added NSImageView and set the layer to CAGradientLayer . However, this makes the scaled-down image very ugly. See the comparison: Layer ON: , layer OFF: Has anyone observed this too? Is there any way to resolve this problem without turning off layer backing? 回答1: I stumbled across this question after running into exactly the same problem. The rendering for a layer-backed NSImageView

Resize and Save NSImage?

梦想与她 提交于 2019-12-09 06:27:27
问题 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. 回答1: 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

Rotating NSImageView cause the NSImageView to scale

烂漫一生 提交于 2019-12-08 19:07:34
I am using the following code to rotate a NSImageView (actually three stacked on top of each other) the rotation works fine, but the image scales up and down when it rotates. why? and how can i fix it? - (void)UpdateRotate:(CGPoint)mouseLoc{ mouseLoc.y = mouseLoc.y - 200; CGPoint playerMid = CGPointMake(prect.xPos, prect.yPos); x = mouseLoc.x - playerMid.x; y = mouseLoc.y - playerMid.y; double priorResult = rot; rot = atan2(y,x) * 180 / PI; [image rotateByAngle:-priorResult]; [image rotateByAngle:rot]; [image setNeedsDisplay:YES]; [WeaponImage rotateByAngle:-priorResult]; [WeaponImage

Rotating NSImageView cause the NSImageView to scale

岁酱吖の 提交于 2019-12-08 08:43:11
问题 I am using the following code to rotate a NSImageView (actually three stacked on top of each other) the rotation works fine, but the image scales up and down when it rotates. why? and how can i fix it? - (void)UpdateRotate:(CGPoint)mouseLoc{ mouseLoc.y = mouseLoc.y - 200; CGPoint playerMid = CGPointMake(prect.xPos, prect.yPos); x = mouseLoc.x - playerMid.x; y = mouseLoc.y - playerMid.y; double priorResult = rot; rot = atan2(y,x) * 180 / PI; [image rotateByAngle:-priorResult]; [image

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

混江龙づ霸主 提交于 2019-12-07 20:01:45
问题 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

Scaled image in NSImageView looks bad with layer-backing on

一曲冷凌霜 提交于 2019-12-07 08:27:27
I'd like to have a view with a gradient background and a image. So I turned on layer backing for the layer, added NSImageView and set the layer to CAGradientLayer . However, this makes the scaled-down image very ugly. See the comparison: Layer ON: , layer OFF: Has anyone observed this too? Is there any way to resolve this problem without turning off layer backing? I stumbled across this question after running into exactly the same problem. The rendering for a layer-backed NSImageView looked horribly scaled, but non-layer-backed one looked great. I tried a number of different things, but in the