 |
|
| Computers Forum Index » Computer Languages (Objective-C) » Resizing image without losing quality... |
|
Page 1 of 1 |
|
| Author |
Message |
| mariot... |
Posted: Thu Oct 29, 2009 12:00 pm |
|
|
|
Guest
|
Hello guys,
What is the best way to resize an image in objective-c without losing
its quality?
Thanks,
mariot |
|
|
| Back to top |
|
|
|
| spikeysnack... |
Posted: Fri Oct 30, 2009 10:58 pm |
|
|
|
Guest
|
On Oct 29, 5:00 am, mariot <marioqta... at (no spam) gmail.com> wrote:
Quote: Hello guys,
What is the best way to resize an image in objective-c without losing
its quality?
Thanks,
mariot
Look at it from farther away.
Is this a troll?
What OS? What Kind Of image? size up or down? bit depth ? aspect?
A: reducing size reduces quality .
B Increasing size reduces quality for the same pixel space, while
possibly introducing artifacts.
C: The Human eye may not detect the reduction in quality, which is
what you want.
D: A lot of math sweat is expended on this problem and the solutions
are not simple.
E: Your job is not to reinvent the wheel here. Depending on your
specific task,and the image type/size one method may work better than
another.
F: All visual representations on the computer of graphics are bitmaps
when you see them on the screen, but they may be represented
in all sorts of ways before that. Most Development environment/
Libraries dealing with images have at least two levels
The Image object and the bitmap representation to send to the
screen.
G: A subtle difference here is whether you change the actual size of
the image or the size which it is displayed.
H. Are you concerned primarily with "doing it the best" (hard) or just
with "doing it" (not as hard)
I. This may help (a little) :
< http://borkware.com/quickies/one?topic=NSImage >
Non-chunky high-DPI image drawing
If you load NSImages from random files and draw them larger than they
say they are,
sometimes you get a really chunky, pixellated display for images that
have a high DPI
rather than a smooth interpolation (or even using all those extra
pixels due to the high DPI).
This is because (I think) that the image says that it's 100x100,
even though you have 1000x1000 pixels available, and Cocoa decides to
scale up only 100x100 pixels.
One way to hack around it is to tell the image to use the
pixel size of the underlying image representation:
NSImage *image;
image = [[NSImage alloc] initWithContentsOfFile: path];
NSBitmapImageRep *rep = [[image representations] objectAtIndex:
0];
if ([rep isKindOfClass:[NSBitmapImageRep class]])
{
theBitmap = (NSBitmapImageRep *) rep;
break;
}
NSSize size = NSMakeSize ([rep pixelsWide], [rep pixelsHigh]);
[image setSize: size];
for iphone http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
You may have to dig deep ==>
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Images/Images.html |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Wed Dec 02, 2009 3:50 am
|
|