Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2008

    Png image and alpha blending


    I can not manage to get aplha blending working.
    I'm loading CFbsBitmaps from png files, create a mask with EGray256 as mentioned in spec, and use CFbsBitGc::BitBltMasked() to display them.

    Here's a partial piece of code extracted from my app :

    Image creation :
    CImageDecoder::TOptions options = (CImageDecoder::TOptions) 
    CImageDecoder::EOptionAlwaysThread | 
    TRAPD(err, idecoder = CImageDecoder::FileNewL(CEikonEnv::Static()->FsSession(), 
    if(err != 0) 
    return err;
    TFrameInfo iFrameInfo = idecoder->FrameInfo(0);
    TBool transparencyPossible = (iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible) > 0;
    TBool alphaChannel = (iFrameInfo.iFlags & TFrameInfo::EAlphaChannel) > 0;
    TInt bpp = iFrameInfo.iBitsPerPixel;
    myBitmap->Create(iFrameInfo.iOverallSizeInPixels,iFrameInfo.iFrameDisplayMode ); 
    myBitmapMask = new (ELeave)CFbsBitmap; 
    CleanupStack::PushL( myBitmapMask ); 
    myBitmapMask->Create( iFrameInfo.iOverallSizeInPixels, EGray256  ); 
    TRAPD(err1,idecoder->Convert( &aStatus, *myBitmap,*myBitmapMask ));  
    User::WaitForRequest( aStatus ); 
    image rendering :
        myBitMapMask, EFalse);
    and the result is I don't see anything on screen (but no crash)
    (once, when I got things wrong, I don't remember what exacly, I saw white rectangles where my image should be, but the behaviour is differente here)

    I'm trying to run this on the SDK emulator. (3rd Ed)

    Is this normal that iFrameInfo.iBitsPerPixel gives me 24 (shouldn't it be 32? or is this variable only dealing with the rgb color channels?)

    flags TFrameInfo::ETransparencyPossible and TFrameInfo::EAlphaChannel are set.

    Anyone can tell if there's anything wrong with this code?
    (I know I'm not using an active object, but it works without, if I don't request alpha blending)


  2. #2
    Registered User
    Join Date
    Sep 2008

    Re: Png image and alpha blending

    Sorry, I've just noticed that the parameters given to BitBltMasked() were wrong.

    Not their type, but the actual object instances passed in are not the ones created by the code I wrote above.

    (This is part of a bigger app, and new CFbsBitmaps must have been created out of the first one to take only parts of them. Thus the mask does not seem to have been initialized when calling BitBltMasked() (0x30303030 smtg like that), though the "main" bitmap itself is correct).

    I'll try to fix that and say if it works after all.

  3. #3
    Registered User
    Join Date
    Sep 2008

    Re: Png image and alpha blending

    I've tried to use this code to display a png image within a sdk example (Graphics, which handles sprites), and it works, the image is transparent where it should be.

    But within my app where bitmaps are partially copied into others to build new images, I have a weird behaviour. All my images a semi transparent, with odd colors... still investigating on that.

    Well, I just posted this to confirm that the code stated above seems to be working in a regular case, for those wondering how to achieve alpha blending with a png.

Similar Threads

  1. Image opactiy problem N71, N80 (getRGB loses alpha)
    By angeldt in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2010-01-27, 12:24
  2. unable to save and retreive the alpha value of image
    By vineetbillorey in forum Mobile Java General
    Replies: 6
    Last Post: 2009-03-04, 10:57
  3. --- ???save image problem??? ---
    By ferenn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2007-10-01, 14:33
  4. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  5. Svg images, transparency and alpha blending
    By hubbabubba in forum Symbian
    Replies: 5
    Last Post: 2006-07-07, 12:32

Posting Permissions

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