• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can we resize the image in j2me

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we resize the image in j2me so that bigger dimention image can fit into
the mobile screen.
My actual task in to zoom in and out the image
[ February 23, 2005: Message edited by: Praveen india ]
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 34
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Praveen india
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jari,

tht code was really gud, but i have one query when i tried this code on transparent image it showed me white pixels on transparent area.

can i remove these these white pixels.

thnks
 
Jari Kemppinen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I can't help you guys any further, haven't got time to look into the problems you are having. If you find a solution please post it up to help other people with similar problems.
 
Nitin India
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all..

can any one help. i hv same question which i asked in my previous post.

though i hv done few things but was unsuccessful. its related to changing a alpha channel in a png image using nokia UI API.

can some one help.

thnks
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. Thanks for your code. I've created other faster than yours, but i think it could be faster with some changes. And the more important, can resize images with transparent pixels.

It works with RGBArrays. First, we need a function to resize Arrays:



INI: Source Array
X: Width of Source Array
Y: Height of Source Array
X2: Width of the Output Array
Y2: Height of the Output Array
Returns OUT (Output Array)

How to use it:



Et voil�. Next, i will modify a bit the "reescalaArray" function to improve more speed. If you get better results, please, share the solution

Happy summer!!

PD: Sorry my English, but i am Spanish
[ July 27, 2005: Message edited by: LuisMiguel Rubio ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks LuisMiguel,

Your code works perfectly. It really solves the problem of how to resize an image.

 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Mark!

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!
 
Mark Cowan
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim - that's okay. It's import to thank him and to let other's know that his code works well.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks LuisMiguel, it works great...i have modified a bit..to make it faster also helps in freeing up memory


Image image1=reescalaArray(image,image.getWidth(),image.getHeight(),newX,newY);

Image reescalaArray(Image temp, int x, int y, int x2, int y2) {
int ini[] = new int[temp.getWidth()*temp.getHeight()];
//Get the RGB array of image into "rgb"

int i=0,t2;
int dy,dx;
temp.getRGB(ini,0,temp.getWidth(),0,0,temp.getWidth(),temp.getHeight());
int out[] = new int[x2*y2];
//t1=y/y2;
t2=x/x2;
for (int yy = 0; yy < y2; yy++) {
dy = yy *y/y2;

for (int xx = 0; xx < x2; xx++) {
dx = xx * t2;

out[i++]=ini[(x*dy)+dx]; //(x2*yy)+xx
}
}
Image temp3 = Image.createRGBImage(out,getWidth(),getHeight(),true);
return temp3;
}
 
swaroop venu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

swaroop venu wrote:Thanks LuisMiguel, it works great...

 
swaroop venu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya. .. It s perfect.. Thank you very much
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,
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.
 
Marshal
Posts: 79240
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Razvan Cotty welcome to the Ranch
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic