×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    1

    Exclamation avax.microedition.media.MediaException: Failed to get Camera Snapshot data size

    Hello,

    I have problem with taking picture.

    the function videoControl.getSnapshot(null) throws MediaException: Failed to get Camera Snapshot data size

    Does one know how I can manage this problem. I've tried getSpanshot("encodings=jpeg") and with png too. But it doesn't work.

    Thank you very much in advance!

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    13

    Cool Re: avax.microedition.media.MediaException: Failed to get Camera Snapshot data size

    Try outthis code it will work it did for me


    //main midlet class
    Code:
    import java.io.IOException;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.media.control.VideoControl;
    
    public class VideoMIDlet extends MIDlet implements CommandListener {
    
    private Display display;
    private Form form;
    private Command exit,back,capture,camera;
    private Player player;
    private VideoControl videoControl;
    private Video video;
    
    public VideoMIDlet() {
    
    exit = new Command("Exit", Command.EXIT, 0);
    camera = new Command("Camera", Command.SCREEN, 0);
    back = new Command("Back", Command.BACK, 0);
    capture = new Command("Capture", Command.SCREEN, 0);
    
    form = new Form("Capture Video");
    form.addCommand(camera);
    form.setCommandListener(this);
    }
    
    public void startApp() {
    display = Display.getDisplay(this);
    display.setCurrent(form);
    }
    
    public void pauseApp() {}
    
    public void destroyApp(boolean unconditional) {}
    
    public void commandAction(Command c, Displayable s) {
    if (c == exit) {
    destroyApp(true);
    notifyDestroyed();
    } else if (c == camera) {
    showCamera();
    } else if (c == back)
    display.setCurrent(form);
    else if (c == capture) {
    video = new Video(this);
    video.start();
    }
    }
    
    public void showCamera() {
    try {
    player = Manager.createPlayer("capture://video");
    player.realize();
    
    videoControl = (VideoControl)player.getControl("VideoControl");
    Canvas canvas = new VideoCanvas(this, videoControl);
    canvas.addCommand(back);
    canvas.addCommand(capture);
    canvas.setCommandListener(this);
    display.setCurrent(canvas);
    player.start();
    } catch (IOException ioe) {} catch (MediaException me) {}
    }
    
    class Video extends Thread {
    VideoMIDlet midlet;
    public Video(VideoMIDlet midlet) {
    this.midlet = midlet;
    }
    
    public void run() {
    captureVideo();
    
    }
    
    public void captureVideo() {
    try {
    byte[] raw = videoControl.getSnapshot(null);
    Image image = Image.createImage(raw, 0, raw.length);
    form.append(image);
    display.setCurrent(form);
    
    player.close();
    player = null;
    videoControl = null;
    } catch (MediaException me) { }
    }
    };
    }
    //videcanvas sub class
    Code:
    import javax.microedition.lcdui.*;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.control.VideoControl;
    
    public class VideoCanvas extends Canvas
     {
    private VideoMIDlet midlet;
    
    public VideoCanvas(VideoMIDlet midlet, VideoControl videoControl) 
    {
    int width = getWidth();
    int height = getHeight();
    this.midlet = midlet;
    
    videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
    try 
    {
    videoControl.setDisplayLocation(2, 2);
    videoControl.setDisplaySize(width - 4, height - 4);
    } 
    catch (MediaException me)
     {}
    videoControl.setVisible(true);
    }
    
    public void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();
    
    g.setColor(0x00ff00);
    g.drawRect(0, 0, width - 1, height - 1);
    g.drawRect(1, 1, width - 3, height - 3);
    } 
    }

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: avax.microedition.media.MediaException: Failed to get Camera Snapshot data size

    Hello Len23,
    You can have a look over the code that id gioven by Jibrael, since that is working either. However this is the compete article on wiki,

    http://wiki.forum.nokia.com/index.ph...ure_in_Java_ME
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Size of data uploaded and restored
    By prajapati.ajay in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2009-11-04, 13:52
  2. J2ME encrypt C# decrypt
    By josual in forum Mobile Java Networking & Messaging & Security
    Replies: 13
    Last Post: 2008-10-20, 04:29
  3. Problems with Camera. Camera run on java class and it failed on midlet.
    By Kaisser in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-04-17, 10:23
  4. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  5. 7650 camera raw data
    By gamit in forum Symbian
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×