Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Transparency in GDI (paging Wiccaan)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Jun 24, 2008 2:41 am    Post subject: Transparency in GDI (paging Wiccaan) Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Jun 24, 2008 5:38 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Jun 24, 2008 5:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites