Two pages of Alpha mixed C ++ source code

xiaoxiao2021-03-06  36

HRESULT DDRVAL;

DDRVAL = lpBackBuffer-> Bltfast (0, 0, LPDDsone, & RC, DDBLTFAST_WAIT); // Background Bit map is sent to the background buffer

IF (DDRVAL! = DD_OK)

{

MSG ("BLT FAILED! Err = 135971476", DDRVAL);

Return;

}

DDSURFACEDESC DDSD, DDSD2;

ZeromeMory (& DDSD, SIZEOF (DDSD));

Ddsd.dwsize = sizeof (ddsd);

ZeromeMory (& DDSD2, SIZEOF (DDSD2));

DDSD2.DWSIZE = SizeOf (DDSD2);

DDRVAL = LPBACKBUFFER-> LOCK (NULL, & DDSD, DDLOCK_WAIT, NULL); // Lock Bar Buffer

IF (DDRVAL! = DD_OK)

{

MSG ("Lock Failed"); // Locking Taiwan buffer failed, exiting the program

Postmessage (WM_CLOSE);

Return;

}

DDRVAL = LPDDSTWO-> LOCK (NULL, & DDSD2, DDLOCK_WAIT, NULL); // Locks the surface of the foreground bitmap

IF (DDRVAL! = DD_OK)

{

MSG ("Lock Failed");

Postmessage (WM_CLOSE);

Return;

}

Byte * bitmap = (byte *) DDSD.lpsurface; // Get the starting point position of the background bitmap in memory

BYTE * bitmap2 = (byte *) DDSD2.lpsurface; // Get the starting point position in the inner memory

Int alpha;

INT POS, POS1;

Static Double Rate1 = 0.05, Rate2 = 0.0;

IF (Rate1> 1.0) Rate1 = 0.0;

Rate2 = 1.0-rate1;

For (int y = newRect1.top; y <= newRect1.bottom; y )

{// newRect1 is the CRECT object, store the display position of the foreground bitmap in the screen

POS = NewRect1.Left * 4 y * DDSD.LPITCH;

POS1 = (Y-NewRect1.top) * DDSD2.LPITCH;

For (int x = newRect1.Left; x <= newRect1.right; x )

{

// red

Alpha = (int) Bitmap2 [POS1] * RATE1;

Bitmap [POS] = (int) Bitmap [POS] * Rate2 Alpha;

IF ((int) Bitmap [POS]> 255) Bitmap [POS] = 255;

POS ; POS1 ;

// Green

Alpha = (int) Bitmap2 [POS1] * RATE1;

Bitmap [POS] = (int) Bitmap [POS] * Rate2 Alpha;

IF ((int) Bitmap [POS]> 255) Bitmap [POS] = 255;

POS ; POS1 ;

// blue

Alpha = (int) Bitmap2 [POS1] * RATE1;

Bitmap [POS] = (int) Bitmap [POS] * Rate2 Alpha;

IF ((int) Bitmap [POS]> 255) Bitmap [POS] = 255;

POS ; POS1 ; // Reverse

POS ; POS1 ;

}

}

Rate1 = 0.05;

LPBACKBUFFER-> Unlock (& ​​DDSD); // Unlock surface

LPDDSTWO-> UNLOCK (& DDSD2); // Unlock surface

CGAMewWnd :: flip (); // Turning surface

转载请注明原文地址:https://www.9cbs.com/read-58434.html

New Post(0)