Skip navigation.
 
mlRE: Scaling an NSImage non-destructively
FROM : Keith Blount
DATE : Tue Nov 30 09:00:49 2004

Again, sorry for replying to my own thread. I've been
trying to solve this problem, but it still has me
stumped. Brief recount: All I want to do is scale an
image in such a way that if I save it and restore it
using something like TIFFRepresentation, if I rescale
it again all the data from the original image is still
intact (ie. so that it is not resampled and doesn't
result in a blocky image in the image is scaled down
and then back up again). I thought that if I created a
scaled image rep, this wouldn't destroy the data in
the original image, like this:

[image setSize:s];
NSImage *newImage = [[NSImage alloc] initWithSize:s];
//[newImage setDataRetained:YES]; // makes no
difference
[newImage setScalesWhenResized:YES];    
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
initWithData:[image TIFFRepresentation]];
[newImage addRepresentation:rep];

But this doesn't work - when I display newImage it
returns to the original size of image. And if I try
saving newImage by locking focus on rep, the image is
resampled and looks horrible if scaled down and then
up. The problem seems to be with TIFFRepresentation -
this seems to resample the image. Is this right?

Many thanks in advance for any pointers, I seem to
have been struggling with this problem on and off for
months.
Keith


   
       
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail

Related mailsAuthorDate
mlScaling an NSImage non-destructively Keith Blount Nov 30, 01:00
mlRE: Scaling an NSImage non-destructively Keith Blount Nov 30, 09:00