0

In my project I have an NSImageView and I drop a picture from the finder on it. In an IBAction I want to take care if the picture size is bigger than the dimensions of the NSImageView as shown below.

I hoped that sender.size or sender.size.x or sender.size.width would give me the size of the NSImageView imageDropped but it doesn't.

Any ideas how I can get the dimensions of the NSImageView?

- (IBAction)imageWasDropped:(id)sender {
   NSImage *theImage = [imageDropped image];

   NSLog(@"%@", sender); // this returns <NSImageView: 0x10011d210>

   NSSize _dimensions = [theImage size];

  if (_dimensions.width > sender.size){

  }

   [imageOriginal setImage:theImage];
   [picture_1 setImage:theImage];

}
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
Ronald Hofmann
  • 1,390
  • 2
  • 15
  • 26

1 Answers1

1

This is very Simple, _imageView the outlet name of that imageWell where you drop or display your image.

NSLog(@"%f, %f", [[_imageView image]size].height, [[_imageView image]size].width);

EDIT:

For imageWell Size:

NSLog(@"Image well size is  :%f x %f",[_imageView frame].size.height, [_imageView frame].size.width);
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • Yes, that´s it. And you are right, it´s really easy :) Thanks a lot. – Ronald Hofmann Dec 13 '12 at 09:41
  • Sorry, I got to correct myself. I don´t need the the size of the dropped image, I already have that. I need the size of the imageWell where the picture was dropped on. Something like sender.bounds – Ronald Hofmann Dec 13 '12 at 09:52