You cannot resize the in-memory image unless you understand the encoding algorithm. But when you draw the image on screen, you can map each screen pixel to several pixels on the image -- effectively smooth it and reduce its display size.
Here is a piece of code I use to display a resized image. Hope it helps.
Let's make this great code more readable using CODE tags. - Mark [ May 15, 2005: Message edited by: Mark Spritzler ]
Joined: Feb 23, 2005
Thank you Jari Kemppinen for this code, Now my problem is that when I make bigger picture to Thumbnail image it works fine, the quality of picture is also good, but when I use the same method in which I passed Thumbnail image as parameter and changed the thumbWidth,thumbHeight values,to get the bigger image the quality of picture is not good. But if I use the original image to fit the screen I am getting java.lang.OutOfMemoryError if the image is bigger the screen size. if the image is small the screen size, so the error dosen't cum can u help me [ February 24, 2005: Message edited by: Praveen india ]
You've "awakened a zombie". LuisMiguel posted that message 5 years ago. In this business that means that he's probably gone on to at least 2 other employers since he posted. And that's assuming he didn't quit the profession entirely.
We're glad that this thread was helpful to you, but I wouldn't count on LuisMiguel answering you!
An IDE is no substitute for an Intelligent Developer.
Joined: Dec 13, 2010
Tim - that's okay. It's import to thank him and to let other's know that his code works well.
Thank you for the code, it was extremely useful. However, I have noticed that on some phones it does not work if the image is very large as it has to create a huge array. So I have come up with an optimized version:
What's good about it is that it loads the original image line by line and depending on the ratio it skips the lines from the original image that are not needed for the resize process.