×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    9

    Svg images, transparency and alpha blending

    Hi,

    I have set the skin image as the background of my application. Then I have an svg image drawn on top of the background.

    I would like to make the svg image kind of semi transparent so that the skin image would be visible through the svg image.

    Is transparency something constructed inside an svg image? I guess not. Isn't it something that can be defined when the image is actually drawn on the screen?

    How does alpha blending work in practice? I have tried to find documentation and reference implementations with not the best success.

    Br,
    HB
    Last edited by hubbabubba; 2006-07-07 at 07:46.

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: Svg images, transparency and alpha blending

    You can draw your image using a mask that is not black but grey. So if you use BitBltMasked() method and your mask is filled with RGB(125,125,125) the image will be drawn as half-transparent.
    Regards,
    ivey

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    9

    Re: Svg images, transparency and alpha blending

    Thanks...

    What do you actually mean by filling? I tried setting the color of the mask (iMask) to TRgb(125, 125, 125) but after it the image appeared all gray, like a shadow. I added some alpha (125, 125, 125, 125) and the gray shadow just got lighter.

    My .mk: c12,8 $(ICONDIR)\my_image.svg

    Construction:
    AknIconUtils::CreateIconL(iBitmap,
    iMask,
    KMyAppIcons,
    EMbmMyApp_my_image,
    EMbmMyApp_my_mask);
    TRgb rgb(125, 125, 125);
    AknIconUtils::SetIconColor( iMask, rgb );

    in Draw() in call CWindowGc::BitBltMasked with params iBitmap and iMask.

    Should I set the display mode or something for the image?

    No need to mention that I'm a dummy with this stuff...

    HB

    Quote Originally Posted by ivey
    You can draw your image using a mask that is not black but grey. So if you use BitBltMasked() method and your mask is filled with RGB(125,125,125) the image will be drawn as half-transparent.

  4. #4
    Registered User
    Join Date
    Jul 2006
    Posts
    9

    Re: Svg images, transparency and alpha blending

    Is it even possible to add transparency effect to an svg image from program code? I wonder becouse transparency (opacity) can also be defined in the svg file this way:

    <circle ... opacity="0.3"/>

    Or can I just change the shade of the mask somehow? CFbsBitmap doesn't have method for changes the shade of the bitmap. Ivey adviced me to "fill the mask" with rgb(125, 125, 125). How to do that?

    Br,
    HB

    Quote Originally Posted by hubbabubba
    Hi,

    I have set the skin image as the background of my application. Then I have an svg image drawn on top of the background.

    I would like to make the svg image kind of semi transparent so that the skin image would be visible through the svg image.

    Is transparency something constructed inside an svg image? I guess not. Isn't it something that can be defined when the image is actually drawn on the screen?

    How does alpha blending work in practice? I have tried to find documentation and reference implementations with not the best success.

    Br,
    HB

  5. #5
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: Svg images, transparency and alpha blending

    hubbabubba,

    I'm sorry, I misunderstood you a little bit.
    What as I suggested is for BMP-images. I mean that you can create 2 bitmaps in your preferred graphics editor - one bitmap is your image and the 2nd is a mask. The lighter shade of grey you use for your mask the more transparency you get when using BitBltMasked() or whatever method you use to draw a masked bitmap.
    Regards,
    ivey

  6. #6
    Registered User
    Join Date
    Jul 2006
    Posts
    9

    Re: Svg images, transparency and alpha blending

    Yep. I ended up modifying the svg file with my own little hands. I know nothing about the svg file syntax but I found out (by trying) that it's possible to affect transparency by modifying "opacity" parameters (value 0...1 where 0 is fully transparent). It looks nice now.

    Anyway thanks, Ivey!

    Br,
    HB

    Quote Originally Posted by ivey
    hubbabubba,

    I'm sorry, I misunderstood you a little bit.
    What as I suggested is for BMP-images. I mean that you can create 2 bitmaps in your preferred graphics editor - one bitmap is your image and the 2nd is a mask. The lighter shade of grey you use for your mask the more transparency you get when using BitBltMasked() or whatever method you use to draw a masked bitmap.

Similar Threads

  1. Transparency J2ME
    By davidmanpearl in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-06-15, 10:50
  2. BitBltMasked() function provide alpha transparency
    By saurbh_g in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-03-24, 09:13
  3. Error in Nokia UI API Guide: transparency?
    By baegsi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2003-08-11, 11:23
  4. drawPixels transparency bug on new Series 60 beta 0.2
    By marcilgen in forum Mobile Java General
    Replies: 0
    Last Post: 2003-03-26, 21:41

Posting Permissions

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