Graphic Display special effects algorithm

Source: Internet
Author: User
Tags sleep

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.