Hello frens,
I need some help how to display one image on the top of next image. Here i have to .PNG images and i need to draw one image on the top of another.
can anyone tell how this can be achieved?
Thanks
Hello frens,
I need some help how to display one image on the top of next image. Here i have to .PNG images and i need to draw one image on the top of another.
can anyone tell how this can be achieved?
Thanks
Hi amishra,
if you're using Canvas, you can do it by simply using the drawImage() method, and using appropriate x and y coordinates.
Pit
Hi,
I'm not sure I understand your question. But here's how I think it can be done (if this is not what you meant please explain your request in detail):
-create a Canvas
-display the first image
-display the second image on top of it
Here is the canvas code I tested:
Code:import javax.microedition.lcdui.*; public class MyCanvas extends Canvas { public void paint(Graphics g) { try { Image img1=Image.createImage("/src/a.PNG"); Image img2=Image.createImage("/src/b.PNG"); //Display the first image g.drawImage(img1, 0, 0, Graphics.TOP|Graphics.LEFT); //Display the second one g.drawImage(img2, 0, 0, Graphics.TOP|Graphics.LEFT); } catch(Exception e) { } } }
thanks
Yes i am working in canvas. I will try the codes and let you know if anything goes wrong.
Can we display more then 2 pictures also?
Basically you can display as many pictures as you want, though if they are many and large you might eventually have some problems with the phone running out of memory.
thanks friends that worked well, now the next query is i have a image that is quit big ( 1024 * 860 ) and i can display 240 * 320 at a time on the screen.
how can i move the image to show it? I mean using the key on mobile phones?
Looking for reply friends
Well you could display a part of the image using the drawRegion(...) method and when the navigation keys are pressed display the next part accordingly. See the Graphics.drawRegion() method documentation and Alessandro's recent article, How to build a Canvas based list in Java ME.
u might also want to try with the LayerManager and make sprites out of those images...
Hello,
I looked at the examples, but i didn't find the solution that I needed. Can you explain in details a bit so that i can get idea how to use? Or if there are any other examples that could really help me.
Looking for your reply.
Thanks
Hello,
I am able to scroll the image, but the problem is it repeats again. I want to stop if the image is at the end on the screen. How can i do this?
is there any way to handle this?
thanks
Hi amishra,
you should manually check it by comparing the y scroll coordinate and the Image height (using the getHeight() method). More detailed replies would highly depend on the scrolling logic you've implemented, but something like this should work:
PitCode:if(yScrollCoordinate + screenHeight > yourImage.getHeight()) { // DO NOT SCROLL }
Thanks for the reply.
But i have implemented in different way and its working fine now.
anyway thanks for the reply![]()
hi guys ,
I am trying to develop a map based location service software for mobile phones. I am facing a tedious problem of image. I have a bigger image ,i can reduce the size and then i can display it but i want to display the larger image.While i am trying to do so only the one part of image is being displayed the maximum which fits over screen at one time. I saw your discussion and i found that one of you have found the solution (amishra).So, if you can give me that code or can give any idea then that will really help me a lot. I will be really thankful to you.
you can send your mail to me at my id
sandeepdas.cse@gmai.com
I yhink u are talking about resizing the map...
cause it will only show the one part of it and specifically a part that is as big as the screen itself (in pixels), you would like to see the whole map on the screen, which actually means resizing whilst amishra is using scrolling...
so please first try to choose what u'd like : resizing (fitting image to screen) or scrolling ?
cause the resizing part will munch up insane amounts of memory on ur mobile (especially if the image is bigger than ur screen), but u could leave the resizing part for ur map-provider...