MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / BitmapAlphaBlend

Function BitmapAlphaBlend

src/Helpers.c:276–295  ·  view source on GitHub ↗

============================================================================= BitmapAlphaBlend() Perform alpha blending to color channel only

Source from the content-addressed store, hash-verified

274// Perform alpha blending to color channel only
275//
276BOOL BitmapAlphaBlend ( HBITMAP hbmp, COLORREF crDest, BYTE alpha )
277{
278 BITMAP bmp;
279 if ( GetObject ( hbmp, sizeof ( BITMAP ), &bmp ) ) {
280 if ( bmp.bmBitsPixel == 32 ) {
281 int x, y;
282 RGBQUAD *prgba = bmp.bmBits;
283 for ( y = 0; y < bmp.bmHeight; y++ ) {
284 for ( x = 0; x < bmp.bmWidth; x++ ) {
285 prgba[x].rgbRed = ( ( prgba[x].rgbRed * alpha ) + ( GetRValue ( crDest ) * ( 255 - alpha ) ) ) >> 8;
286 prgba[x].rgbGreen = ( ( prgba[x].rgbGreen * alpha ) + ( GetGValue ( crDest ) * ( 255 - alpha ) ) ) >> 8;
287 prgba[x].rgbBlue = ( ( prgba[x].rgbBlue * alpha ) + ( GetBValue ( crDest ) * ( 255 - alpha ) ) ) >> 8;
288 }
289 prgba = ( RGBQUAD * ) ( ( LPBYTE ) prgba + bmp.bmWidthBytes );
290 }
291 return TRUE;
292 }
293 }
294 return FALSE;
295}
296
297
298//=============================================================================

Callers 1

CreateBarsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected