canvas in layer

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

canvas in layer

Postby sou » Thu Apr 10, 2008 3:18 pm

Hi All...
please can any one tell me how to put canvas class in layer???
i have canvas class extend canvas .... it show the video stream ...and i want to put it in a layer to add layer with frame to it
please don't ignore my question




this is the canvas class
import javax.microedition.lcdui.*;
import javax.microedition.media.MediaException;
import javax.microedition.media.control.VideoControl;

public class CameraCanvas
extends Canvas {
private SnapperMIDlet mSnapperMIDlet;

public CameraCanvas(SnapperMIDlet midlet, VideoControl videoControl) {
int width = getWidth();
int height = getHeight();

mSnapperMIDlet = midlet;

videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
try {
videoControl.setDisplayLocation(2, 2);
videoControl.setDisplaySize(width - 4, height - 4);
}
catch (MediaException me) {
try { videoControl.setDisplayFullScreen(true); }
catch (MediaException me2) {}
}
videoControl.setVisible(true);
}

public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();

// Draw a green border around the VideoControl.
g.setColor(0x00ff00);
g.drawRect(0, 0, width - 1, height - 1);
g.drawRect(1, 1, width - 3, height - 3);
}

public void keyPressed(int keyCode) {
int action = getGameAction(keyCode);
if (action == FIRE)
mSnapperMIDlet.capture();
}
}
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

Re: canvas in layer

Postby DevelopmentTeam » Fri Apr 11, 2008 4:41 am

I dont understand why do you need canvas in layers, but all I can understand is you are trying to draw a frame over the video captured image. You can always do that within the canvas class itself, similar to how you draw the green border.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: canvas in layer

Postby sou » Fri Apr 11, 2008 8:51 am

that's right I need to draw a frame over the video captured image as drawing the green border. just i want to decrease the dimensions of this border....when i did that the border disappear behind the video ....so the idea of layer coming in my mind ..to put the border in layer in front to video....can you tell me how to do that without layer???
really thanks for your caring
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

Re: canvas in layer

Postby DevelopmentTeam » Sat Apr 12, 2008 7:13 am

ok, I can understand now. let me try that and post the code here...
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 4 guests

cron