• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scaling down an image proportionally
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scaling down an image proportionally


  • Subject: Re: Scaling down an image proportionally
  • From: Marco Binder <email@hidden>
  • Date: Sat, 21 Sep 2002 19:44:39 +0200

If you need a way to render down the actual image data, so you can e.g.
save it to disk in a smaller version, you can just create a new NSImage
with

NSImage *newImage = [[NSImage alloc] initWithSize:(NSSize)];

in the new desired size (that is, for proportional scaling [yourImage
size].width*x and [yourImage size]. height*x), then lockFocus on this
new image and call

[yourImage drawInRect:NSMakeRect(0,0,[newImage size].width,[newImage
size].height) fromRect:NSMakeRect(0,0,[yourImage size].width,[yourImage
size].height) operation:NSCompositeCopy fraction:1.0];

newImage now holds your proportionally scaled down original image.

In case you just need a way to display a scaled version on screen, the
easiest and cleanest way is to just follow the docs:


Taken from Apple4s developer documentation:

scalesWhenResized

- (BOOL)scalesWhenResized

Returns YES if image representations are scaled to fit the size
specified for the receiver. If representations are not scalable, this
method returns NO. The default is NO.

Representations created from data that specifies a size (for example,
the "ImageLength" and "ImageWidth" fields of a TIFF representation or
the bounding box of an EPS representation) will have the size the data
specifies, which may differ from the size of the NSImage.

See Also: - setSize:


marco


Am Samstag, 21.09.02 um 18:44 Uhr schrieb Thilo Ettelt:

>
> Hi! Could someone give me a hint how I can scale an NSImage down
> proportionally?
>
>
> Thx in advance!
>
>
> Cheers, Thilo
--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Scaling down an image proportionally
      • From: Thilo Ettelt <email@hidden>
References: 
 >Scaling down an image proportionally (From: Thilo Ettelt <email@hidden>)

  • Prev by Date: Re: Sending a keystroke
  • Next by Date: Re: NSAttributedString and HTML
  • Previous by thread: Scaling down an image proportionally
  • Next by thread: Re: Scaling down an image proportionally
  • Index(es):
    • Date
    • Thread