• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Image resize

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friendz
Could any one give me any idea (Source code,if possible) for MIDP 2.0, CLDC 1.0 so that I can resize an larger image to a smaller size that fits into different device width/height.Thanx.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I don't know where my code was for that, but you can do a search on this forum for it. I am pretty sure I got my code here.

Also, note that when you resize the image, you can no longer have a transparent color. So if you have a transparent background color, so that that part would show up, it now will when you resize it.

I eventually had to make multiple .png file for different sizes, then check the size of the device with an if statement and choose a .png based on it. Although this ends up being trial and error to use the right .png for a particular width and height screen.

Mark
 
Debojit Nag
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark
Thanx for ur suggestion. Actually I am dealing with jpg images stored in the device(camera phone). My code is capable of geting thumbnail of the jpg images having EXIF or JFIF headers. otherwise thumnail is manually created. For this i need an int based resizing code. I have one. But when it encounters any mismatch in byte format,it throws illegal argument exception. What r the other reasons u think behind this? Thanx.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good question, and unfortunately, I haven't used JPEGs with J2ME. But wouldn't it still use the Image class and its methods to resize?

Mark
 
Debojit Nag
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark
Real problem is find out. its not due to an exception but an error- out of memory, for larger size images. Becauce for 1.3 megapixel images, the heap size required is not provided by the KVM. So a statement like
rgbOrgData = new int[sourceWidth * sourceHeight];
SURELY FAILS. Any way, I handled it by modifying the resize algo.
Bye
Debojit
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic