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 do advanced image drawing?

 
Fredrik Andersson
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

In regular java.awt.Graphics there is an method like:

public abstract boolean drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
ImageObserver observer)

But in javax.microedition.lcdui.Graphics there is just this method:

public void drawImage(Image img,
int x,
int y,
int anchor)

In my app I need to use the first method, do you guys have any solution for this?

Best regards
Fredrik
 
Ramender Mall
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fred,
As far as I could get from the documentation of the java.awt.Graphics.drawImage(), it can scale(and possibly some other operations too) the image to fit the desired rectangle and all.

However, in J2ME there is no such option provided in APIs.

You put down what exactly do you want to achieve and then ppl here may provide you with some way arounds.

- Ramy..
 
Fredrik Andersson
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

Thanks for your reply!

I would like to be able to draw an image with size 100*100 into a area of for eg 50*100 so it gets scaled.

I'm able to do that with regular Java, but to mee it looks like I can't do it in J2ME.

So if you got an suggetstion how to solve this please let me know.

Best regards
Fredrik
 
Punit Raizada
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as scaling is concerned, you can use source code posted on this forum itself. Try searching for "Image resize" or "Image rescale".

You will have to tweak the code a bit to get it to do exactly what you want. The idea revolves around creating a new Image object by getting the pixels from the original image.

Hope it helps
 
Casper Maxwell
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This tip may help too:

Displaying images as thumbnails on J2ME devices
http://www.java-tips.org/java-me-tips/midp/displaying-images-as-thumbnails-on-j2me-devices.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic