| View previous topic :: View next topic |
| Author |
Message |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Jun 24, 2008 2:41 am Post subject: Transparency in GDI (paging Wiccaan) |
|
|
Any idea how this can be achieved? I'm using DIB's, so I'm primarily drawing by goofing with the bits.
Maybe transparency isn't the best term to describe it, maybe 'blending' is better? When two things overlap, instead of one just covering the other, I want them to blend together. I'm creating 32 bit DIB's, so how do I work the alpha channel into this?
I'm just drawing pixels like:
| Code: | void DrawPixel(DWORD x, DWORD y, COLORREF color){
bits[(y * SCREEN_WIDTH + x) * 4 + 2] = GetRValue(color);
bits[(y * SCREEN_WIDTH + x) * 4 + 1] = GetGValue(color);
bits[(y * SCREEN_WIDTH + x) * 4 ] = GetBValue(color);
} |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Jun 24, 2008 5:38 am Post subject: |
|
|
From my dibEngine (thanks to mircal):
| Code: | void dibEngine::PutPixelTrans( unsigned int x, unsigned int y, unsigned char r, unsigned char g, unsigned char b, float a )
{
unsigned int iOffset;
if( x >= 0 && x < ScreenWidth && y >= 0 && y < ScreenHeight )
{
iOffset = ( y * ScreenWidth + x );
lpCanvasBuffer[(iOffset * 4) ] = (unsigned char)(a*b+(1-a)*lpCanvasBuffer[(iOffset * 4) ]);
lpCanvasBuffer[(iOffset * 4)+1] = (unsigned char)(a*g+(1-a)*lpCanvasBuffer[(iOffset * 4)+1]);
lpCanvasBuffer[(iOffset * 4)+2] = (unsigned char)(a*r+(1-a)*lpCanvasBuffer[(iOffset * 4)+2]);
}
} |
_________________
- Retired. |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Jun 24, 2008 5:07 pm Post subject: |
|
|
Information on this seems pretty scarce, but I'll be reading more into blending and the different types.
Anyway, thanks a bunch for the kickstart.
Edit: I found a nice article on this. Gamedev is a great resource
http://www.gamedev.net/reference/articles/article817.asp |
|
| Back to top |
|
 |
|