Convert PNG to BMP in brew

Source: Internet
Author: User

A few days ago, I had been tossing pictures and thought brew's support for PNG was not very good, except for displaying that there was nothing else to do.
In fact, the setdestination method of the idisplay interface can be used to conveniently convert two types of images, except for the slow speed.

The code is not complex, as follows:

1 ibitmap * getbitmaphalf (displayweb * PME, iimage * pimage)
2 {
3 ibitmap * pscreen, * pbitmap, * pbitmap2;
4 itransform * ptransform;
5 aeeimageinfo Info;
6
7 iimage_getinfo (pimage, & info );
8
9 pscreen = idisplay_getdestination (PME-> PAPP-> A. m_pidisplay );
10 if (pscreen)
11 {
12 ibitmap_createcompatiblebitmap (pscreen, & pbitmap, info. CX, info. Cy );
13 ibitmap_createcompatiblebitmap (pscreen, & pbitmap2, info. CX, info. Cy );
14 if (pbitmap & pbitmap2)
15 {
16 idisplay_setdestination (PME-> PAPP-> A. m_pidisplay, pbitmap );
17 iimage_draw (pimage, 0, 0 );
18
19 ibitmap_queryinterface (pbitmap2, aeeclsid_transform, (void *) (itransform **) & ptransform );
20 if (ptransform)
21 {
22 itransform_transformbltsimple (ptransform, 0, pbitmap, 0, 0, info. CX, info. Cy, transform_scale_half, composite_keycolor );
23 itransform_release (ptransform );
24}
25 else
26 ibitmap_bltin (pbitmap2, 0, 0, info. CX/2, info. cy/2, pbitmap, 0, 0, aee_ro_copy );
27
28 idisplay_setdestination (PME-> PAPP-> A. m_pidisplay, null );
29
30 ibitmap_release (pbitmap );
31
32}
33 ibitmap_release (pscreen );
34}
35 return pbitmap2;
36}

It is easy to understand that two compatible bitmaps are created from the screen, one of which is used as the drawing target, and the other is painted as the conversion and deformation target, use the itransform interface to transform the previous Bitmap (painted with a PNG Image) and return the second bitmap.

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.