×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    RE: Mutable images and transparency

    I had the same problem, using com.nokia.mid.ui.DirectGraphics helped.

    Image myImage = Image.createImage ("/blah.png"
    Image mutableImage = Image.createImage (100, 100);
    Graphics gfx = mutableImage.getGraphics ();
    DirectGraphics dg = DirectUtils.getDirectGraphics(gfx);
    dg.drawImage (myImage, 0, 0, Graphics.TOP | Graphics.LEFT,0);
    ...
    //transparency is kept now, don't ask me why
    DirectGraphics dg = DirectUtils.getDirectGraphics(g);
    dg.drawImage (mutableImage, 0, 0, Graphics.TOP | Graphics.LEFT);

    hth, Dan

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    12

    Mutable images and transparency

    Really simple question (I think):

    I have a PNG which has a single index transparent colour (0xffffff). If I load the image and display it using Image.createImage(...) and Graphics.drawImage (...) it displays correctly (i.e. transparent, so the background is visible).

    e.g.
    Image myImage = Image.createImage ("/blah.png"
    ...
    // this looks correct
    g.drawImage (myImage, 0, 0, Graphics.TOP | Graphics.LEFT);

    HOWEVER if I create a new mutable Image using Image.createImage (width, height) and then clip and draw portions from the immutable image into it, and then draw the new mutable image, I lose the transparency information i.e. I have a big white box around the image

    e.g.

    Image myImage = Image.createImage ("/blah.png"
    Image mutableImage = Image.createImage (100, 100);
    Graphics gfx = mutableImage.getGraphics ();
    gfx.drawImage (myImage, 0, 0, Graphics.TOP | Graphics.LEFT);
    ...
    // this doesn't look correct
    g.drawImage (mutableImage, 0, 0, Graphics.TOP | Graphics.LEFT);

    Basically I'm writing a bitmap font system for a game menu, and I need a way to create mutable images containing menu elements (strings) that have been rendered. Is there a way to keep the transparency info, or to set it in the new mutable Image?

    thanks

    Ian

Posting Permissions

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