Create a 16-Bit Bitmap Under wince to implement fast bitblt

Source: Internet
Author: User

If the format of the bitmap created in wince is different from that of the screen device, the bitblt function is extremely slow. Therefore, you need to create a 16-bit color 565 format bitmap, the bitmap created using this method can provide quick bitblt rendering for 1 ms. Of course, if the device is not in the 565 color format, changeCodeIn the Color Mask bits bmicolors.

 

//////////////////////////////////////// /// // <Br/> // // @ brief creates a cached image. <Br/> // @ Param [out] The bitmap handle generated by phbitmap. <Br/> // @ Param [out] The data location in the bitmap generated by pdata. <Br/> // @ Param [in] HDC Target DC handle. <Br/> // @ Param [in] width: the width of the bitmap. <Br/> // @ Param [in] Height: the height of the bitmap. <Br/> // @ Param [in] bitcount the number of bits per pixel. <Br/> // @ attention the created bitmap is in the non-compressed format. <Br/> // @ author loongee <br/> /// @ date 2010/01/15 <br/> //////////////// //////////////////////////////////////// ///// // <br/> void createbufferbitmap (hbitmap * phbitmap, void ** pdata, <br/> HDC, long width, long height, word bitcount) <br/>{< br/> bitmapinfo & BMP info = * (bitmapinfo *) new byte [sizeof (BMP info) + sizeof (rgbquad) * 3]; <br/> BMP info. bmiheader. bisize = sizeof (bitmapinfoheader); <br/> BMP info. bmiheader. biwidth = width; <br/> BMP info. bmiheader. biheight = height; <br/> BMP info. bmiheader. biplanes = 1; <br/> BMP info. bmiheader. bibitcount = bitcount; <br/> If (bitcount = 16) <br/>{< br/> BMP info. bmiheader. bicompression = bi_bitfields; <br/> * (DWORD *) (& BMP info. bmicolors [0]) = 0xf800; <br/> * (DWORD *) (& BMP info. bmicolors [1]) = 0x07e0; <br/> * (DWORD *) (& BMP info. bmicolors [2]) = 0x001f; <br/>}< br/> else <br/>{< br/> BMP info. bmiheader. bicompression = bi_rgb; <br/>}< br/> BMP info. bmiheader. bisizeimage = 0; <br/> BMP info. bmiheader. bixpelspermeter = 1000; <br/> BMP info. bmiheader. biypelspermeter = 1000; <br/> BMP info. bmiheader. biclrused = 0; <br/> BMP info. bmiheader. biclrimportant = 0; <br/> * phbitmap = createdibsection (HDC, & BMP info, dib_rgb_colors <br/>, pdata, null, 0 ); <br/> Delete [] (byte *) & BMP Info; <br/>} 

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.