This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image resize

 
Debojit Nag
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic