Windows Interface Programming 13th bitmap display special effects

Source: Internet
Author: User

This article supporting procedures: http://download.csdn.net/detail/morewindows/5177047

Reprinted please indicate the source, original address: http://blog.csdn.net/morewindows/article/details/8696730

Welcome to Weibo: http://weibo.com/MoreWindows

For Windows interface programming, the bitmap display special effect series directory is as follows:

1. The ninth part of Windows Interface Programming: bitmap display effect staggered

Http://blog.csdn.net/morewindows/article/details/8696720

2. Windows Interface Programming Article 10 bitmap display special effect blinds

Http://blog.csdn.net/morewindows/article/details/8696722

3. Windows Interface Programming 11th special bitmap display random block effects

Http://blog.csdn.net/morewindows/article/details/8696724

4. Windows Interface Programming 12th bitmap display special effects fly into effect and stretch Effect

Http://blog.csdn.net/morewindows/article/details/8696726

5. Windows Interface Programming 13th bitmap display special effects collection

Http://blog.csdn.net/morewindows/article/details/8696730

 

The previous four articles have introduced the cross effect, shutter effect, random block effect, flying effect and stretching Effect of Bitmap. The following uses a program to demonstrate these effects. Here is the main code (see: http://download.csdn.net/detail/morewindows/5177047 ). Dragacceptfiles in the code can refer to the Windows Interface Programming Article 7 file drag (drag and drop files) (http://blog.csdn.net/morewindows/article/details/8634451), mainly in order to drag the bitmap file into the window.

Lresult callback wndproc (hwnd, uint message, wparam, lparam) {static int s_nshow; static HDC s_hdcmem; static int s_nwidth, s_nheight; Switch (Message) {Case wm_create: {dragacceptfiles (hwnd, true); // load the bitmap hbitmap; hbitmap = (hbitmap) LoadImage (null, "107.bmp", image_bitmap, 0, 0, lr_loadfromfile | lr_createdibsection ); if (hbitmap = NULL) {MessageBox (hwnd, "LoadImage failed ", "Error", mb_iconerror); exit (0);} // bitmap hdchdc HDC = getdc (hwnd); s_hdcmem = createcompatibledc (HDC); SelectObject (s_hdcmem, hbitmap ); releasedc (hwnd, HDC); // calculate the bitmap width and height. Bitmap bm; GetObject (hbitmap, sizeof (BM), & BM); s_nwidth = BM. bmwidth; s_nheight = BM. bmheight; s_nshow = 0;} return 0; Case wm_keydown: Switch (wparam) {Case vk_escape: // exit sendmessage (hwnd, wm_destroy, 0, 0) when the ESC key is pressed ); return 0;} break; Case Wm_paint: {HDC; paintstruct pS; HDC = beginpaint (hwnd, & PS); Switch (s_nshow) {Case 0: bitblt (HDC, 0, 0, s_nwidth, s_nheight, s_hdcmem, 0, 0, srccopy); break; // horizontal staggered Case 1: animatedraw_staggeredhorizontal (HDC, s_hdcmem, s_nwidth, s_nheight); break; // vertical staggered Case 2: animatedraw_staggeredvertical (HDC, s_hdcmem, s_nwidth, s_nheight); break; // horizontal shutter Case 3: animatedraw_jalousiehorizontal (HDC, s_hdcmem, s_nwidt H, s_nheight); break; // vertical shutter case 4: blind (HDC, s_hdcmem, s_nwidth, s_nheight); break; // random block case 5: animatedraw_randomblocks (HDC, s_hdcmem, s_nwidth, s_nheight); break; // fly from top to bottom case 6: animatedraw_flyingtoptobottom (HDC, s_hdcmem, s_nwidth, s_nheight, 2, false); break; // fly in from bottom to top case 7: animatedraw_flyingbottomtotop (HDC, s_hdcmem, s_nwidth, s_nheight, 2, false); break; // fly in from left to right case 8: round (HDC, s_hdcmem, s_nwidth, s_nheight, 2, false); break; // fly from right to left case 9: animatedraw_flyingrighttoleft (HDC, s_hdcmem, s_nwidth, s_nheight, 2, false); break; // stretch top-down case 10: animatedraw_flyingtoptobottom (HDC, s_hdcmem, s_nwidth, s_nheight); break; // stretch bottom-up case 11: animatedraw_flyingbottomtotop (HDC, s_hdcmem, s_nwidth, s_nheight); break; // stretch from left to right case 12: animatedraw_flyingl Efttoright (HDC, s_hdcmem, s_nwidth, s_nheight); break; // stretch from right to left Case 13: histogram (HDC, s_hdcmem, s_nwidth, s_nheight); break;} If (s_nshow! = 0) {s_nshow = 0; invalidaterect (hwnd, null, false);} endpaint (hwnd, & PS);} return 0; Case wm_command: If (loword (wparam)> = 40001 & loword (wparam) <= 40013) {s_nshow = loword (wparam)-40000; invalidaterect (hwnd, null, true); Return 0;} break; // drag the third step dragqueryfile and dragqueryfilecase wm_dropfiles: {hdrop = (hdrop) wparam; uint nfilenum = dragqueryfile (hdrop, 0 xffffffff, null, 0 ); // The number of drag files char strfilename [max_path]; dragqueryfile (hdrop, 0, strfilename, max_path); // obtain the drag file name dragfinish (hdrop ); // release hdropdeletedc (s_hdcmem); // load the bitmap hbitmap; hbitmap = (hbitmap) LoadImage (null, strfilename, image_bitmap, 0, 0, lr_loadfromfile | lr_createdibsection ); // bitmap hdchdc HDC = getdc (hwnd); s_hdcmem = createcompatibledc (HDC); SelectObject (s_hdcmem, hbitmap); releasedc (hwnd, HDC ); // calculate bitmap bm; GetObject (hbitmap, sizeof (BM), & BM); s_nwidth = BM. bmwidth; s_nheight = BM. bmheight; invalidaterect (hwnd, null, true);} return 0; Case wm_destroy: deletedc (s_hdcmem); postquitmessage (0); Return 0;} return defwindowproc (hwnd, message, wparam, lparam );}

Below is a display of the program (the picture cannot be opened, please visit the http://blog.csdn.net/morewindows/article/details/8696730 ).

For more display effects, refer to the examples in the previous staggered effect, Louver effect, random block effect, flying effect and stretching effect blog.

This article supporting procedures: http://download.csdn.net/detail/morewindows/5177047

Reprinted please indicate the source, original address: http://blog.csdn.net/morewindows/article/details/8696730

Welcome to Weibo: http://weibo.com/MoreWindows

 

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.