Horizontal blinds: The image is divided into equal parts, each scan of the equal 1 like pixels after sleep for a period of time, and then scan the next pixel until each pixel is scanned.
Raindrop Effect: Read the last line of pixels in the bitmap, move from the top of the screen to the actual position of the pixel, and then read the first line of pixels, and so on.
The specific steps are as follows:
- 1. Add variables to the project:
CDC memdc;
CBitmap m_bitmap;
- 2. Add bitmap resources to the resource, ID is idb_bitmap1;
- 3. Add initialization code to the constructor:
m_bitmap.LoadBitmap(IDB_BITMAP1);
- 4. Add the following code to the OnDraw (cdc* PDC):
void Cmyview::ondraw (cdc* pDC)
{
cmydoc* PDoc = GetDocument ();
Assert_valid (PDOC);
int width; Width of bitmap
int height; The height of the bitmap
if (!MEMDC. GETSAFEHDC ())
{
MEMDC. CreateCompatibleDC (PDC);
MEMDC. SelectObject (&M_BITMAP);
}
Get Bitmap size information
BITMAP BM;
M_bitmap. Getbitmap (&BM);
Width=bm.bmwidth;
Height=bm.bmheight;
if (next==2)//Horizontal left scan
{
for (int i=0;i<width;i++)
{
Pdc->bitblt (i,0,1,height,&memdc,i,0,srccopy);
Sleep (1);
}
}
else if (next==1)//Horizontal scan Right
{
for (int i=width-1;i>=0;i--)
{
Pdc->bitblt (i,0,1,height,&memdc,i,0,srccopy);
Sleep (1);
}
}
else if (next==3)//Horizontal Blinds
{
20 pixel width per line
int num=width/20;
for (int i=0;i<20;i++)
{
Scan each one separately
for (int j=0;j<num;j++)
{
Pdc->bitblt (j*20+i,0,1,height,&memdc,j*20+i,0,srccopy);
}
Sleep (10);
}
}
else if (next==4)//Vertical Blinds
{
int num=height/20;
for (int i=0;i<20;i++)
{
Scan each one separately
for (int j=0;j<num;j++)
{
Pdc->bitblt (0,j*20+i,width,1,&memdc,0,j*20+i,srccopy);
}
Sleep (10);
}
}
else if (next==5)//Raindrop Effect
{
for (int i=height-1;i>=0;i--)
{
for (int j=0;j<i;j++)
{
Pdc->bitblt (0,j,width,1,&memdc,0,i,srccopy);
Sleep (10);
}
}
}
Todo:add Draw code for native
}
See source code for other implementation details.