×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Dec 2004
    Location
    quezon city philippines
    Posts
    25

    Question HELP: Mutable Image to Immutable Image?

    Im trying to create an immutable image from a mutable one.
    But I've encountered problems. The image that is displayed
    is either white or black. HEre is a copy of my code which
    attempts to create an immutable image from a mutable one.

    public Image addTextToImage(Image src, String text){
    // The string text is the text to be drawn to the image

    int w = src.getWidth(); // width of the copy image
    int h = src.getHeight();// height of the copy image

    // the folowing code creates a mutable image form an immutable image (src)
    // this snipet i got from the MIDP API

    Image copy = Image.createImage(w,h);
    Graphics g = copy.getGraphics();
    g.drawImage(src,0,0,Graphics.TOP | Graphics.LEFT);


    g.drawString(text, 40, 80,...);

    // i try to get the pixel data of the mutable image that was drawn
    // earlier using drawRGB
    // as i read in the API, pixel data is stored to the int[] parameter of
    // drawRGB

    g.drawRGB(pixels,...);

    // I use pixels to re-create an immutable version of the
    //mutable image
    // hoping that the string i drew to the Image is also copied

    Image imgWithString = Image.createRGBImage(pixels,w,h, true);
    // please take notice of the last parameter of the
    // createRGBImage method
    // when true, the Image that is returned is all white
    // when false, the image is all black

    return imgWithString;

    }// end of addTextToImage method

    can someone help me with this? Thanks in advance

  2. #2
    Registered User
    Join Date
    Dec 2004
    Location
    quezon city philippines
    Posts
    25

    I think i figured out how...

    I was able to figure out how to create Immutable images from mutable ones..so sorry for the bother..but has anybody had difficulty with anything involving getRGB and running them on the Series 60 MIDP Concept emulator? I have..

    The emulator either hangs OR
    throws an alert: "Bad Field Signature".

    My program runs just fine on the "DefaultColorPhone" emulator available with java wireless toolkit 2.2. Can someone explain why?

Posting Permissions

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