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.