• 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

How to do advanced image drawing?

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic