×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    16

    image transparency gets lost with DirectUtils.createImage

    hi there,

    i already wrote this topic to another forum here at forum.nokia.com but i think it was in the wrong folder...

    my problem: i load a transparent .png image from a resource file. then i want to draw parts of the image into a new image. therefore i create a new image with

    Image mutableImg = DirectUtils.createImage(w,h,0x00000000);

    this should be an empty tranparent image. then i get the graphics context:

    Graphics g = mutableImg.getGraphics();

    and draw the loaded one to the new image:

    g.drawImage(loadedImage, xOff, yOff, TOP|LEFT);

    i used to test all that on the nokia 7210 device and the emulator and everything was fine.

    but now while converting it to series 60 the resulting image is no longer transparent when using Graphics.drawImage. it has a black background. If i use DirectGraphics.drawImage the result is transparent, but this drawImage-method is much slower than the standard Graphics' image drawing method.

    is there any other solution? is this only a series 60 problem or occurs this error also on a series 40 device?

    thanks for help,

    markus.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    3
    Same problem down here...

    Noticed that the Series 60s have Nokia UI 0.9.2 instead of the Nokia UI 1.0 that the 7210 emu has. It might be possible that only the newer phones and N-UI support a native Graphics::drawImage(...) transparency handling.

    Another thing might be the shared/different bit depths of resource PNG files. I tried several combinations with no luck.

    Its pretty annoying but only solutions seems to be using DirectGraphics all over...

    At least some word from Nokia would solve the questioning.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    16
    my results during the last days:

    if you load an image (transparent png) from a resource file and draw it with Graphics.drawImage everything is fine, only if you manipulate the image before using the nokia API then this possibility to draw the image gets lost. you have to use DirectGraphics then.

    i've tested transparency on the following real devices (maybe it's interesting). you CAN manipulate images with the nokia UI API and then draw them with the standard Graphics-object WITHOUT transparency gets lost on the following series 40 devices:

    + 6100
    + 6610
    + 6800
    + 7210
    + 7250

    i don't know if it's works on the other series 40 ones, because i didn't have the possibility to test it on them, but i think it will work on all series 40 devices.

    definitely NOT working is it on the series 60 real devices:

    + 3650
    + 7650


    greets,
    markus.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    5
    I don't even get that to work. The transparency seems to get hopelessly lost when I make the image mutable, even if I use DirectGraphics to draw it. The following results in a white border where transparency should be. It's placed in the paint-handler..

    protected synchronized void paint( Graphics g )
    {

    // create mutable copy of resource image

    Image img = Image.createImage( 16, 16 );
    Image vehicle1_image = Std.image_make( "/images/alla_crushed.png" );
    Graphics gfx = img.getGraphics();
    gfx.drawImage( vehicle1_image, 0,0,0 );

    // fill screen with green
    g.setColor(0x00ff00);
    g.fillRect( 0, 0, 100, 100 );

    // get DirectGraphics
    DirectGraphics dg = DirectUtils.getDirectGraphics( g );

    // draw
    dg.drawImage( img,16,16,0,0 );

    }


    what am I doing wrong?

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    16
    you should use

    Image img = DirectUtils.createImage(16, 16 ,0x00000000);

    to create an image with transparent background...

    hope that helps...

    greets,
    markus

  6. #6
    Registered User
    Join Date
    Apr 2003
    Posts
    19
    Just throwing something out from the recesses of my memory (have the memory of a goldfish, by the way). I think I remember someone posting something on this board saying that the masking information was the other way around on the Series 60 - ie, someone has messed up.

    So instead of [Image mutableImg = DirectUtils.createImage(w,h,0x00000000);]

    You would try [Image mutableImg = DirectUtils.createImage(w,h,0xffffffff); ]

    May be hogwash, but if someone wants to give it a go and let us know.

    Danny.
    Tin Can Games.

    www.tincangames.com

Posting Permissions

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