Skip to main content

Layermanager help

2 replies [Last post]
Joined: 2009-03-18

How I can copy content of layermanager to image.I tried the following code but the result image is empty.

public void paint(Graphics g)

int[] RGB = new int[150*150];
Image image1 = Image.createImage(150,150);

Graphics g1 = image1.getGraphics();
mLayerManager.paint(g1, 0, 0);
image1.getRGB(RGB, 0, image1.getWidth(), 0, 0, image1.getWidth(), image1.getHeight());
g.drawRGB(RGB, 0, 50, 50, 50, 150, 150, true);

Is there anything wrong in the above code?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-03-18

Thanks for your advice,the scanlength was wrong.its now working fine.

Joined: 2003-06-15

try adding

just before you call mLayerManager.paint(g1,0,0);

Also on your g.drawRGB(..) I think your scanlength is wrong, it should be 150 I think.


PS. Get Jonathan Knudsen's book Kicking Butt with MIDP and MSA it will have most answers to your JavaME questions. Also read all of the JavaDoc for a class there are usually hints as to additional methods needed to call before other methods work as expected.

Message was edited by: sfitzjava