IllegalArgumentException in Image.createImage()

Hello,
I have a problem trying to create an image-object from a captured snapshot as I always get an IllegalArgumentException in Image.createImage when capturing with 640x480. My code looks like:
raw = mVideoControl.getSnapshot("encoding=jpeg&width=640&height=480");
Image img = Image.createImage(raw, 0, raw.length);When I capture with 320x240, everything's fine. I guess this is a bug with my phone (Siemens S65), but would anyone have an idea how to work around that one? I thougt of doing some kind of a "screenshot", but couldn't figure out how and if this is possible.
Thanks a lot for any help or hints
Tobias

I am absolutely sure, the actual code looks like:
byte[] raw = mVideoControl.getSnapshot(enc);
Image img = null;
try {
    img = Image.createImage(raw, 0, raw.length);
} catch (Throwable t) {
    showAlert(t.toString());
    System.out.println(t.toString());
}showAlert() is my own convenience method for showing an Alert. I also send the image-byte[] to a server where I save it to a file and this works perfectly... So the Exception is definitely from createImage().
Tobias

Similar Messages

  • Image.createImage exception

    Hi all, I have problem with loading image to my application. If I create image with methodImage.createImage(String name)everything is ok and image shows up, but when I want to use just part of this image and I call methodImage.createImage(Image image, int x, int y, int width, int height, int transform)the Exception is thrown.
    Part of my code:
    - works correct:
    try {
        String name = "name.png";
        Image img = Image.createImage(name);
        g.drawImage(img, imageX, imageY, 0);
    } catch (IOException ioex) {
        System.err.println(ioex);
    }- throws Exception:
    try {
        String name = "name.png";
        Image img = Image.createImage(name);
        img = Image.createImage(img, 0, 0, img.getWidth(), img.getWidth(), Sprite.TRANS_NONE);    // the whole image is 26x364 and I'd like to use just 26x26 from the top left corner
        g.drawImage(img, imageX, imageY, 0);
    } catch (IOException ioex) {
        System.err.println(ioex);
    } catch (IllegalArgumentException iaex) {
        System.err.println(iaex);
    }Any idea what could be wrong? Thank you.

    I'm not sure. But can you give the size of the image without creating it and the code does not understand.
    eg
    img = Image.createImage (img, 0, 0, 26, 364, Sprite.TRANS_NONE);

  • Problem with Image.createImage()

    Hi all!
    I'm writing a simple midlet just to display an image on the screen and I'm having some problems with Image.createImage()
    Here is my code
    Image bg_img;
    ImageItem imageItem1;
    imageItem1 = new ImageItem("", null,ImageItem.LAYOUT_DEFAULT, "");
    try{
    bg_img = Image.createImage("/image.png");
    imageItem1.setImage(bg_img);
    catch(java.io.IOException e){
    e.printStackTrace();
    I'm getting an exception on bg_img = Image.createImage("/image.png");
    I can't understand what is it...:(
    I know for sure that the problem is not "file not found"
    Any one can help me???

    If you are catching IOException, then u may have problem with ur image path. "image not found on the specified path." if ur image is not in the current directiry then put it into current directory. otherwise, If u are using resouce folder and it is already included into the resouce path, then put ur image in that folder..try this..
    Still not get, then please give some detail about ur development toolkit. and ur apllication packaging scheem. are you using ANT?
    Pranav

  • Image.createImage() crashed in Nokia 7210 Emulator

    Dear all,
    I'm developing a midlet for showing png file on a canvas by the 7210 emulator.
    whenever I call the Image.createImage("/myfile.png"), the midlet will shown "Unable to run application" and then exit the midlet application. My png file's size is 734 bytes (140x100 pixel).
    When I test the programme by other emulator, ie. 7650, default color phone and so on, the programme runs smoothly.
    Does anyone know how to solve this problem??
    joey829

    From your experience I think maybe the emulator have some bugs. Try to download updated emulator from nokia. Or try as many emulator as you can. In most cases different company though build different emulator, their work behavior should be identical with the same program.

  • Image.createImage() on benq-siemense M81 and SE z530i (using google maps)

    I'm getting static google maps to show them in my j2me application. There is one problem...
    Code for shoing image:
    try {
                byte[] preimage  = gm.retrieveStaticImage(<params>);
                this.my_image = Image.createImage(preimage, 0, preimage.length);
                this.getImageItem().setImage(my_image);
    } catch (Exception ex) {
                ex.printStackTrace();
    }Data coming to preimage. Size of it is OK. But Image.createImage() method doesnt work on z530i. I dont see any messages with exceptions... Whats wrong? Maybe data format? I tryed GIF, JPG, PNG32. Result is the same...
    PS
    Images from other resources (not google maps) loading whithout problems.
    Edited by: fewl on Aug 14, 2008 3:19 PM

    Hello
    I rooted my Sony Ericsson Arc S by following your excellent and easy to understand instuctions in order to remove some of the unwanted crap that came preloaded on the phone and in order to install the rooted version of Avast antivirus/antitheft app.
    Everything has worked perfectly well for the last few months since doing this however now I am unable to update the phone via the sony ericsson update service.
    Please advise
    Cheers
    Ian

  • Image.createImage() problem with eclipseME IDE

    I create directory struture like this:
    PhotoView
    |- class
    |- deployed
    |- res
    |- src
    |- verified
    Images was put in res.
    However, I am allways catched exception with the bold line.
    Please, help me.
    Thanks.
    private void showImage(int index) {
    imageForm.deleteAll();
    Image img;
    try {
    img = Image.createImage("/pBirds.png");
    } catch (Exception e) {
    img = null;
    e.printStackTrace();
    ImageItem imgItem = new ImageItem("pBirds.png", img,
    ImageItem.LAYOUT_CENTER, "Image");
    imageForm.append(imgItem);
    display.setCurrent(imageForm);
    }

    Maybe you should try to add the res folder to your project path?
    project properties-> build path add folder....

  • Image.createImage() IOException on certain file other files work :|

    Hi from newbie :)
    I writing this simple game and i have occured this strange problem.
    I can't read my file from the /res dir. However i can read a file that i have used in a tutorial. The file that i have problem with was created by me, it's a simple *.gif file (i used MS paint if that matters). The file that i can read was provided by a tutorial it's also a *.gif file. Here is a part of my code:
    public void start()
              try
                   playerImg = Image.createImage("/player.gif");
                   playerX = CENTER_X;
                   playerY= CENTER_Y;
              catch(NullPointerException nullEx)
                   System.err.println("NullPointerException data");
                   System.err.println(nullEx);
                   System.err.println(nullEx.getMessage());
                   nullEx. printStackTrace();
              catch(IOException ioex)
                   System.err.println("IOException data");
                   System.err.println(ioex);
                   System.err.println(ioex.getMessage());
                   ioex. printStackTrace();
              Thread runner = new Thread(this);
              runner.start();
         }This a msg from exception:
    IOException data
    java.io.IOException
    null
    Uncaught exception java/lang/NullPointerException: .
    java.io.IOException
         at javax.microedition.lcdui.Image.createImage(+17)
         at MyGameCanvas.start(+6)
         at AdventureGameMIDlet.startApp(+12)
         at javax.microedition.midlet.MIDletProxy.startApp(+7)
         at com.sun.midp.midlet.Scheduler.schedule(+270)
         at com.sun.midp.main.Main.runLocalClass(+28)
         at com.sun.midp.main.Main.main(+116)
    I'm using SonyEricsson J2ME SDK WTK2 for P900 if that matters.
    Also i have one more question why this exception is not caught by the catch(NullPointerException nullEx) {...} clause?
    For any help i'll be grateful :)

    Main class with std MIDlet methods
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.Display;
    public class AdventureGameMIDlet extends MIDlet
         MyGameCanvas gCanvas;
         public AdventureGameMIDlet()
              gCanvas = new MyGameCanvas();
         public void startApp()
              Display display = Display.getDisplay(this);
              gCanvas.start();
              display.setCurrent(gCanvas);
         public void pauseApp()
         public void destroyApp(boolean unconditional)
    }Class for the game:
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.game.GameCanvas;
    import java.io.IOException;
    import java.lang.NullPointerException;
    import java.lang.Thread;
    public class MyGameCanvas extends GameCanvas implements Runnable
         // the couple image
         private Image playerImg;
         // the couple image coordinates
         private int playerX;
         private int playerY;
         // the distance to move in the x axis
         private int dx = 1;
         // the center of the screen
         public final int CENTER_X = getWidth()/2;
         public final int CENTER_Y = getHeight()/2;
         public MyGameCanvas()
           super(true);
         public void start()
              try
                   playerImg = Image.createImage("/player.png");
                   playerX = CENTER_X;
                   playerY= CENTER_Y;
              catch(NullPointerException nullEx)
                   System.err.println("NullPointerException data");
                   System.err.println(nullEx);
                   System.err.println(nullEx.getMessage());
                   nullEx. printStackTrace();
              catch(IOException ioex)
                   System.err.println("IOException data");
                   System.err.println(ioex);
                   System.err.println(ioex.getMessage());
                   ioex. printStackTrace();
              Thread runner = new Thread(this);
              runner.start();
         public void run()
              Graphics g = getGraphics();
              while(true)
                   verifyGameState();
                   checkUserInput();
                   updateGameScreen(getGraphics());
                   try
                        Thread.currentThread().sleep(30);
                   catch(Exception ex)
         private void verifyGameState()
           //code
         private void checkUserInput()
              int keyState = getKeyStates();
              calculateCoupleX(keyState);
         private void updateGameScreen(Graphics g)
              g.setColor(0xffffff);
              g.fillRect(0, 0, getWidth(), getHeight());
              g.drawImage(playerImg, playerX, playerY, Graphics.HCENTER | Graphics.BOTTOM);
              flushGraphics();
         private void calculateCoupleX(int keyState)
              if((keyState & LEFT_PRESSED) != 0)
                   playerX -= dx;
              else if((keyState & RIGHT_PRESSED) != 0)
                   playerX += dx;
    }

  • Image.createImage(inputstream) not work in mobilityback

    hi,
    Guys, while using MIDlet with WTK tool its working fine and dowload the image from corresponding URL (using Image.createImage(inputstream obj) ).
    The same code was used in mobilityback error like "cannot resolve symbol createImage(inputstream) "
    This error only on while build the project not in compiling particular midlet file.
    What may be the problem please any idea?

    hi,
    one more thing
    The same method working fine in WTK emulator as well as netBeans also, while using it with j2mepolish the error arise at the time of build project(The seperate file is compiling properly).
    what i have to do with polish ?

  • Create an Image

    Hie.. i've browse through the forum to search a solution to my problem but i dont find any resourceful. I hope someone could help me out. Here is the problem :-
    I tried to create an Image using byte of array as such :-
    ** the message is in byte
    currentImage = Image.createImage(message,0,message.length);
    imageItem = new ImageItem("Default", currentImage,
    imageItem.LAYOUT_CENTER,"image");
    But i got this error message :-
    java.lang.IllegalArgumentException:
         at javax.microedition.lcdui.ImmutableImage.<init>(+11)
         at javax.microedition.lcdui.Image.createImage(+40)
         at showReceivedMessage.<init>(+155)
         at Register.displayReceivedMessage(+23)
         at ReceiveMessage.notifyMessage(+279)
         at j.notifyRequest(+391)
         at gov.nist.microedition.sip.SipConnectionNotifierImpl.a(+33)
         at gov.nist.microedition.sip.StackConnector.processRequest(+106)
         at gov.nist.siplite.EventScanner.run(+389)
    I suppose the error message mean i'd had passed an illegal argument for an immutableImage but i already make sure that its all correct yet still get thismessage. Please help as i've look into this for weeks.. :(

    Hi
    It means that your layout value is not legal. Also, try using this instead: currentImage = Image.createImage(message,0,message.length);
    imageItem = new ImageItem("Default", currentImage, 0, "image");Also, you might want to try using ImageItem.LAYOUT_CENTER instead of imageItem.LAYOUT_CENTERMihai

  • Images won't show on Display

    hey, i'm just starting out with MIDP programming. i created a MIDlet with a Canvas and tried to display an image but it just doesn't show. at first i didn't get any errors or exceptions but after a bit of tweaking i got this exception:
    java.io.IOException
            at javax.microedition.lcdui.ImmutableImage.getImageFromStream(Image.java:971)
            at javax.microedition.lcdui.ImmutableImage.<init>(Image.java:942)
            at javax.microedition.lcdui.Image.createImage(Image.java:310)
            at hello.MyCanvas.paint(GraphicsMIDlet.java:62)
            at javax.microedition.lcdui.Canvas.callPaint(Canvas.java:1074)
            at javax.microedition.lcdui.Display.repaint(Display.java:1566)
            at javax.microedition.lcdui.Display.registerNewCurrent(Display.java:1872)
            at javax.microedition.lcdui.Display.access$700(Display.java:221)
            at javax.microedition.lcdui.Display$DisplayAccessor.foregroundNotify(Display.java:2344)
            at javax.microedition.lcdui.Display$DisplayManagerImpl.notifyWantsForeground(Display.java:3126)
            at javax.microedition.lcdui.Display$DisplayManagerImpl.access$100(Display.java:2565)
            at javax.microedition.lcdui.Display.setCurrent(Display.java:843)
            at hello.GraphicsMIDlet.startApp(GraphicsMIDlet.java:19)
            at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:43)
            at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:374)
            at com.sun.midp.main.Main.runLocalClass(Main.java:466)
            at com.sun.midp.main.Main.main(Main.java:120)and here's my MIDlet's code:
    package hello;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.IOException;
    public class GraphicsMIDlet extends MIDlet
      private Display  display;
      private MyCanvas canvas;
      public GraphicsMIDlet ()
        display = Display.getDisplay(this);
        canvas  = new MyCanvas(this);
      protected void startApp()
        display.setCurrent( canvas );
      protected void pauseApp()
      protected void destroyApp( boolean unconditional )
      public void exitMIDlet()
        destroyApp(true);
        notifyDestroyed();
    class MyCanvas extends Canvas implements CommandListener
      private Command exit;
      private Command refresh;
      private GraphicsMIDlet filledRectangleExample;
      Image img;
      public MyCanvas (GraphicsMIDlet filledRectangleExample)
        this. filledRectangleExample = filledRectangleExample;
        exit = new Command("Exit", Command.EXIT, 1);
        refresh = new Command("Refresh", Command.OK, 2);
        addCommand(exit);
        addCommand(refresh);
        setCommandListener(this);
        img = null;
      public void paint(Graphics graphics)
        graphics.setColor(255,255,255);
        graphics.fillRect(0, 0, getWidth(), getHeight());
        graphics.setColor(0, 0, 255);
        graphics.drawLine(2, 2, 19, 19);
        graphics.setColor(0, 255, 0);
        graphics.fillRoundRect(20, 20, 60, 60, 15, 45);
        graphics.setColor(0, 0, 0);
        graphics.drawString("Hello World", 10, 100, 0);
        if (img == null) {
                try {
                    img = Image.createImage("/ball.png");
                    //setFullScreenMode(true);
                } catch (IOException e) {
                    e.printStackTrace();
                    return;
        else if (img != null){
            graphics.drawImage(img, 100, 100, Graphics.VCENTER);
      public void commandAction(Command command, Displayable displayable)
        if (command == exit)
            filledRectangleExample.exitMIDlet();
    }i have no idea what exception means or how to fix it. the other graphics show on the screen without a problem. i also tried both jpg and png formats, none seem to work. did i get the image's destination wrong? the images showed up in the projects window so i assumed that i got it right. if not then which folder should i put the images in? or what am i doing wrong?

    line # 74 refers to the drawimage method, after editing the code drawimage is currently in line # 73
    ok i removed the constructor for the MIDlet class and moved everything to startApp()
    moved the image to the MIDlet class and initialized it in startApp() also
    the image did have transparent pictures so i changed it and put an image with no transparent or partially transparent pixels
    added repaint() method to the refresh command event cause i realized the first time paint is done the image isn't initialized yet so i get no errors sometimes and still don't see the image. (should i repaint in the MIDlet class instead?)
    created a res folder in the project's folder and added it to the resources in the project and copied the images folder from the src folder to there, so its in both folders
    commented the other draw functions as you suggested
    removed the anchor and put its integer value instead (Graphics.TOP = 16)
    here's what my code currently looks like:
    package hello;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.IOException;
    public class GraphicsMIDlet extends MIDlet
      private Display  display;
      private MyCanvas C;
      Image img = null;
      protected void startApp()
        display = Display.getDisplay(this);
        C  = new MyCanvas(this);
        display.setCurrent( C );
        img = null;
        if (img == null) {
                try {
                    img = Image.createImage("/images/Duke.png");
                    //setFullScreenMode(true);
                } catch (IOException e) {
                    e.printStackTrace();
                    return;
      protected void pauseApp()
      protected void destroyApp( boolean unconditional )
      public void exitMIDlet()
        destroyApp(true);
        notifyDestroyed();
    class MyCanvas extends Canvas implements CommandListener
      private Command exit;
      private Command refresh;
      private GraphicsMIDlet filledRectangleExample;
      //Timer t;
      public MyCanvas (GraphicsMIDlet filledRectangleExample)
          //t = new Timer();
          this. filledRectangleExample = filledRectangleExample;
          exit = new Command("Exit", Command.EXIT, 1);
          refresh = new Command("Refresh", Command.OK, 2);
          addCommand(exit);
          addCommand(refresh);
          setCommandListener(this);
      public void paint(Graphics graphics)
    //    graphics.setColor(255,255,255);
    //    graphics.fillRect(0, 0, getWidth(), getHeight());
    //    graphics.setColor(0, 0, 255);
    //    graphics.drawLine(2, 2, 19, 19);
    //    graphics.setColor(0, 255, 0);
    //    graphics.fillRoundRect(20, 20, 60, 60, 15, 45);
    //    graphics.setColor(0, 0, 0);
    //    graphics.drawString("Hello World", 10, 100, 0);
        if (filledRectangleExample.img != null){
            graphics.drawImage(filledRectangleExample.img, 0, 0, 16);
      public void commandAction(Command command, Displayable displayable)
        if (command == exit)
            filledRectangleExample.exitMIDlet();
        else if (command == refresh){
            repaint();
    }i debugged the program again, i put a break point at the draw image condition. the first time the paint function runs the image value is null so drawimage is never executed, when i press refresh and repaint is called, the image's value isn't null and drawimage is executed. at that point i get this exception :
    java.lang.IllegalArgumentException:
            at hello.MyCanvas.paint(GraphicsMIDlet.java:73)
            at javax.microedition.lcdui.Canvas.callPaint(Canvas.java:1074)
            at javax.microedition.lcdui.Display.repaint(Display.java:1566)
            at javax.microedition.lcdui.Display$DisplayAccessor.repaint(Display.java:2264)
            at javax.microedition.lcdui.Display$DisplayManagerImpl.repaint(Display.java:3012)
            at com.sun.midp.lcdui.DefaultEventHandler.repaintScreenEvent(DefaultEventHandler.java:394)
            at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(DefaultEventHandler.java:665)line 73 refers to drawimage()
    i've yet to try using a Form class and using image item, i'll let you know as soon as i do that. also i'm gonna try tinkering with the ready made example i have and see if i find out what i'm doing wrong.
    thanks i really appreciate your help

  • Reading and Writing Image through Socket

    hi
    i'm doing a mobileapplication and i send the Image from the server using a DataOutputStream. I'm converting the Image to a byteArray. The Image in .png format. But i need to read it from a J2ME application and when i read the byteArray and convert it to a Image it gives a illegalArgumentException coz it says that cannot decode the Image.
    Can anyone Help
    Rushi

    some png files are not standard png files thats why u may get the error but u should try like this:
    Server side=>
    OutputStream os=c.getOutputStream();
    int numBytesRead = 0;
    while ((numBytesRead = input.read(buf)) != -1) {
    os.write(buf, 0, numBytesRead);
    Client side=>
    bStrm=new ByteArrayOutputStream();
    c = 0;
    while ((c=dis.read())!=-1)
    bStrm.write(c);
    imgData = bStrm.toByteArray();
    bStrm.close();
    img=Image.createImage(imgData,0,imgData.length);

  • Factory method usage, creating the correct Image subclass

    Hi, I created a factory method
      public enum ImgType {
        SINGLE, STRIP, SPRITE_SHEET
    public static Image createImage(ImgType imgType) {
        switch (imgType) {
          case SINGLE:
            return new MyImage1(0, 0);
          case SPRITE_SHEET:
            return new MyImage2("", 0, 0);
          case STRIP:
            return new MyImage3("", 0, 0);
          default:
            throw new IllegalArgumentException("The image type " + imgType + " is not recognized.");
      }that creates different images based on the enum type provided.
    and heres is a usage of that function
      public BufferedImage loadAwtImage(ImageInputStream in, String imgName,  ImageTypeFactory.ImgType imgType) throws IOException {
        BufferedImage img = imgLoader.loadImage(in);
        BufferedImage imgsubType = ImageTypeFactory.createImage(imgType);  // Convert to real Image type
        addAwtImg(imgName, imgsubType);
        return imgsubType;
      }In a test:
    imgLib.loadAwtImage(imageStream, "cursor", ImageTypeFactory.ImgType.SPRITE_SHEET);Is it 'good' that in the test I can say(using the imgType enum) what sort of Image should be returned?
    doesn't this expose the working of the class to the outside, on the other hand I don't know howto create the correct sub image based on an image loaded.
    I use subImages to allow selection within the image, like the 3th 'tile' within an imageStrip returns just that cropped image.
    Before I had List<Image> and List<List<Image>> and now I can just return Images in 1 method instead of 2,3 by using lists.
    Edited by: stef569 on Dec 12, 2008 11:05 AM

    creates specifications... :p
    *  load the BufferedImage from the ImageInputStream
    * add it to the cache keyed by the imgName
    * @return a BufferedImage, or a custom subclass based on the imgType
    * @throws IOException when the img could not be loaded
    public BufferedImage loadAwtImage(ImageInputStream in, String imgName,  ImageTypeFactory.ImgType imgType) throws IOException I can test it, but the ImageTypeFactory.ImgType imgType parameter looks wrong to me.
    if you see this in a class method would you change it/find a better way.

  • Getting image from input stream

    Hi,
    I'm using the following code in a midlet to get an image from a inputstream from a servlet.
    is = hc.openDataInputStream();
    ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
    int d;
    while ((d = is.read()) != -1)
    bStrm.write(d);
    byte imageData[] = bStrm.toByteArray();
    im = Image.createImage(imageData, 0, imageData.length);
    ImageItem ii = new ImageItem(null, im, ImageItem.LAYOUT_DEFAULT, null);
    if (viewMap.size() != 0)
    viewMap.set(0, ii);
    else
    viewMap.append(ii);
    a problem occurs at
    im = Image.createImage(imageData, 0, imageData.length);
    and a 'exception java/lang/IllegalArgumentException'
    is generated. The inputstream is definitely not null.
    Can anyone see what I am doing wrong or recommend any alternative approaches?
    Thanks

    hi ,
    wouldn't "getResourceAsStream()" work here?
    ====
    kiran

  • Receiving Image via socket and creating via byte[]...

    Hi Folks...
    I�m trying to send a WebCam SnapShot to my Midlet running in a PDA via socket..
    The method used to send the Image is:
    BufferedImage img = toBufferedImage( getScreenShot( getFrameBuffer() ) );
              byte[] buf = convertImage( toBufferedImage( img ) );
              BASE64Encoder enc64 = new BASE64Encoder();
              enc64.encode(buf);
              try {
                   out.writeUTF("IMAGEM");
                   out.writeInt( buf.length );
                   out.write( buf );
              } catch (IOException e) {
                   e.printStackTrace();
              }So this code get a snapShot from the webCam and returns a BufferedImage. This BufferedImage is converted to a byte[], and later this byte[] is encoded in Base64 format with BASE64Encoder.
    In the next step the buffer is sent to the client, the server send the message "IMAGEM", in the sequence the size off the byte[] and then the byte[].
    The code that receive the Image byte[]...
    private void receiveImageAction(){
              byte[] buf;
              try {
                   buf = new byte[ in.readInt() ];
                   in.read(buf);
                   Image img = Image.createImage( buf, 0 , buf.length );
                   viewForm.setMsg("Image created");
                   viewForm.setImageView(img);
              } catch (IOException e) {
                   viewForm.setMsg( "" + e.toString() );
              }catch(Exception e){
                   viewForm.setMsg( "" + e.toString() );
         }When the connection manager receives a message "IMAGEM" the function receiveImageAction is called.
    It receives the size off the byte[] and then receive the array.
    When I try to create the image using Image.createImage( byte[], int, int ) the exception IllegalArgumentException is throwed...
    The exception doesnt have a message...
    What is wrong ?
    Is the format off my image sent ?
    Is my buffer been encoded correctly by the BASE64Encoder class ?

    Will u try with replacing this line
    Image img = Image.createImage( buf, 0 , buf.length );with this line
    Image img = Image.createImage( buf, 0 , buf.length-1 );

  • MIDP 1.0: Image to byte[] or serializing...

    I would like to extract pixels from a MIDP 1.0 "Image" object through any means possible. I am currently under the impression that "Image.toString()" would just do something lame, like giving me a string like "Image@1234" that identifies the class and the instance -- which could in principle be used for mere instance comparison. Anyhow, if I could serialize an Image object to a file, and then read back the file in to a byte array, then I would be delighted. I want to stress that I don't care how convoluted the approach may be, as long as it is in plain-vanilla J2ME Java code for MIDP 1.0 and is capable of working on an actual device (as opposed to an emulator). Can I cast the Image to Object, and then somehow convert to byte[]? I don't care if I have to get down and dirty, hacking the platform-specific bytes of the full Object manifestation of the Image. Anyhow, I want to make it clear that any hard core hack, doing all kinds of things that would break on different VMs, etc, is totally fine. Messy is fine. I just want access to the binary data of the entire Image object, or, even better (but only icing on the proverbial cake), access to pixel data. If I can get the byte[] representation of Image, then I can hack the rest myself.

    My goal was do a capture of the way things actually rendered on a device, kind of like a "screen capture", only a little more indirect (since I don't think there is a way to get access to the pixels of the LCD). What I have to do is render to an off-screen Image object and then retrieve pixel data from it using the platform-dependent getPixels() supplied by Motorola. You're going to think I'm crazy, but I send this image data to a web server via POSTs, which get collected and stored as a single file on my web server. Voila! A screen capture of how things actually render to an Image object on an actual device.
    Everything works, except...
    I can't get the Motorola "getPixels()" method to work in their emulator, so I'm worried
    that it won't work on my Motorola T720 (something I haven't actually tried, though).
    I get a "Uncaught Exception: java/lang/Error" message from the T720 emulator
    when I run one of the Motorola demos (built using their scripts) when I add the
    following code to the Canvas paint() method:
    if (0 == iDidThis) {  iDidThis = 1;
    try
    {  javax.microedition.lcdui.Image   temp = Image.createImage( 120, 160 );
    int [] rgbData = new int [120*160];
    com.motorola.game.ImageUtil.getPixels ( temp, 0, 0, 1, 1, rgbData );
    System.out.println("Captured Data");
    catch( java.lang.ArrayIndexOutOfBoundsException e )
    {  e.printStackTrace();   } }
    This code runs only once, when the paint() method of the Canvas object is called for
    the first time. Okay, I get the error message, but the "Bounce" demo (to which I added
    the code block above) goes on to run just fine. (NOTE: The message "Captured Data"
    is NOT printed in this scenario.)
    I don't understand why the public static "com.motorola.game.ImageUtil.getPixels()"
    method causes the "java/lang/Error" exception. (By the way, if I comment out the
    call to this method, the code totally works without error, and I see the printed
    statement "Captured Data" in the command window associated with the emulator.)
    If my getPixels() call resulted in bad array access, then I would get the
    java.lang.ArrayIndexOutOfBoundsException exception. But apparently this is
    not what is going on.
    I am really rusty with J2ME, so I don't even know the meaning of "java/lang/Error".
    I assume it is different from a "class not found" exception, but I suspect that my
    problem has to do with a fault in the emulator trying to execute the code for the
    "com.motorola.game.ImageUtil.getPixels()" method.
    My Motorola emulator (v7.5) is from around December, 2002, so it may be really old, and
    maybe this was a known issue at that time that has since been resolved. I'm just never
    tried to use platform-specific J2ME APIs before, so I don't know if what I am observing
    is my fault, or is an emulator issue.
    I'd be grateful for any ideas about what might be going wrong and for ideas about
    possible solutions.

Maybe you are looking for

  • Multiple Kinect 360 sensors in v2 SDK?

    Hi, therer are several threads pointing out that there is no way of using multiple v2 sensors on the same machine due to PCI bandwidth limitations. However, I would like to use multiple v1 sensors instead. I'm about to move form OpenNI to Kinect SDK

  • Brush tip preference

    using mac OS 10.6.8 with CS5 Xtnd: I don't get it! When I first began using this app (and I've spent much time swearing at it with no result) and until recently and in either normal or full size mode showing xhairs and whether I use as paint or erase

  • Issues tagging faces in iphoto and Facebook

    Hi I have iPhoto 11 (v9.4.3 720.91) and have been using faces on it for the last 4 months or so. I linked my facebook account with my iPhoto and have been sharing albums on facebook happily, assuming the faces I tagged were tagging on facebook too. H

  • 1 gig Mushkin and K7N2 question

    There is a large retailer here that is selling PC3200 Mushkin High Performance Level II matched 512 sticks for $250.00. This sounds like a great deal, but I want to know if anyone has used these in the K7N2. I noticed that there more than a few that

  • Errors Opening and Installing Adobe Acrobat Pro

    Originally mine was a single problem with the following error after attempting to open Adobe Acrobat Pro 7.0, "An error has been detected with a required application library and the product cannot continue. Please reinstall the application." Now afte