Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ graphics
Is it possible in C++ builder to use a monochrome bitmap as a transparency mask? I know builder has transparency feature, but I want some places to be more transparent than others.
Thank you, Daniel Smile | :)
Posted 18-May-10 1:41am
Edited 18-May-10 1:45am
Moak11.4K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I'm not experienced on C++ builder, however transparency features are usually implemented basing on the underlying OS support.
 
Microsoft Windows could handle transparency in two ways:
 
    • thru GDI, by setting a specific RGB color as transparent. This way each pixel of the given color is treated as completely transparent and other pixels will be completely opaque
    • thru GDI+, by using images with a valid alpha channel. This ways each pixel has 4 bytes associated with it: the red, green, blue and alpha values. The alpha value of each pixel determine how that pixel is opaque: a value of 0 mean that the pixel is completely transparent and a value of 255 means that the pixel is completely opaque
 
Said that, you can use GDI+ to render a semi-transparent image, and if you want to use a gray-scale bitmap as transparency mask, you should first load your image on a GDI+ context, then modify each pixel to set their alpha value to the value of the correspondant pixel from the gray-scale bitmap.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 349
2 Richard MacCutchan 220
3 BillWoodruff 209
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 19 May 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100