Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to scale an image in J2ME?

 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone has any idea how to scale an image in J2ME?
Does Graphics class and Image class provide any method to support the implementation of image scaling?
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The phone only has 100 KB of heap memory. Why would you waste it on oversized images? You should probably resize and optimize your images offline and then bundle them your application.
 
Mirko Froehlich
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could think of a few cases where you might want to scale down an image that was acquired on a camera phone using the MMAPI, for example in order to generate a thumbnail. In fact, I am working on such an application right now. The following article points out a simple way to do this:
http://developers.sun.com/techtopics/mobility/midp/articles/picture/
Check out the createThumbnail() example. In theory, this solution is not ideal, but it works fine for this purpose on my Nokia 3650.
With regards to scaling up you would need some real interpolation algorithm, so this would be more tricky. I'm not sure why anyone wouln need to do this, though.
Otherwise, I completely concur with Michael that you should do the scaling before and package the scaled images with your app.
-Mirko
 
Mirko Froehlich
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could think of a few cases where you might want to scale down an image that was acquired on a camera phone using the MMAPI, for example in order to generate a thumbnail. In fact, I am working on such an application right now. The following article points out a simple way to do this:
Link
Check out the createThumbnail() example. In theory, this solution is not ideal, but it works fine for this purpose on my Nokia 3650.
With regards to scaling up you would need some real interpolation algorithm, so this would be more tricky. I'm not sure why anyone wouln need to do this, though.
Otherwise, I completely concur with Michael that you should do the scaling before and package the scaled images with your app.
-Mirko
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone needs to write a PNG parser and manipulation program for MIDP!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic