📄 group__bmp__fns.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>MiniGUI V1.6.10 API Reference: BITMAP and blitting operations</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.2 --><div class="qindex"><a class="qindex" href="index.htm">Main Page</a> | <a class="qindex" href="modules.htm">Modules</a> | <a class="qindex" href="classes.htm">Alphabetical List</a> | <a class="qindex" href="annotated.htm">Data Structures</a> | <a class="qindex" href="dirs.htm">Directories</a> | <a class="qindex" href="files.htm">File List</a> | <a class="qindex" href="functions.htm">Data Fields</a> | <a class="qindex" href="globals.htm">Globals</a> | <a class="qindex" href="pages.htm">Related Pages</a></div><h1>BITMAP and blitting operations<br><small>[<a class="el" href="group__gdi__fns.htm">GDI functions</a>]</small></h1><h2>Functions</h2><ul><li>MG_EXPORT <a class="el" href="group__simple__types.htm#ga0">BOOL</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga0">GetBitmapFromDC</a> (<a class="el" href="group__handles.htm#ga2">HDC</a> hdc, int x, int y, int w, int h, <a class="el" href="struct__BITMAP.htm">BITMAP</a> *bmp)<dl class="el"><dd class="mdescRight">Gets image box on a DC and saves it into a BITMAP object. <a href="#ga0"></a><br></dl><li>MG_EXPORT <a class="el" href="group__simple__types.htm#ga0">BOOL</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga1">FillBoxWithBitmap</a> (<a class="el" href="group__handles.htm#ga2">HDC</a> hdc, int x, int y, int w, int h, const <a class="el" href="struct__BITMAP.htm">BITMAP</a> *bmp)<dl class="el"><dd class="mdescRight">Fills a box with a BITMAP object. <a href="#ga1"></a><br></dl><li>MG_EXPORT <a class="el" href="group__simple__types.htm#ga0">BOOL</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga2">FillBoxWithBitmapPart</a> (<a class="el" href="group__handles.htm#ga2">HDC</a> hdc, int x, int y, int w, int h, int bw, int bh, const <a class="el" href="struct__BITMAP.htm">BITMAP</a> *bmp, int xo, int yo)<dl class="el"><dd class="mdescRight">Fills a box with a part of a bitmap oject. <a href="#ga2"></a><br></dl><li>MG_EXPORT void GUIAPI <a class="el" href="group__bmp__fns.htm#ga3">BitBlt</a> (<a class="el" href="group__handles.htm#ga2">HDC</a> hsdc, int sx, int sy, int sw, int sh, <a class="el" href="group__handles.htm#ga2">HDC</a> hddc, int dx, int dy, <a class="el" href="group__win32__types.htm#ga4">DWORD</a> dwRop)<dl class="el"><dd class="mdescRight">Performs a bit-block transfer from a device context into another device context. <a href="#ga3"></a><br></dl><li>MG_EXPORT void GUIAPI <a class="el" href="group__bmp__fns.htm#ga4">StretchBlt</a> (<a class="el" href="group__handles.htm#ga2">HDC</a> hsdc, int sx, int sy, int sw, int sh, <a class="el" href="group__handles.htm#ga2">HDC</a> hddc, int dx, int dy, int dw, int dh, <a class="el" href="group__win32__types.htm#ga4">DWORD</a> dwRop)<dl class="el"><dd class="mdescRight">Copies a bitmap from a source rectangle into a destination rectangle, streches the bitmap if necessary. <a href="#ga4"></a><br></dl><li>MG_EXPORT <a class="el" href="group__simple__types.htm#ga0">BOOL</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga5">ScaleBitmap</a> (<a class="el" href="struct__BITMAP.htm">BITMAP</a> *dst, const <a class="el" href="struct__BITMAP.htm">BITMAP</a> *src)<dl class="el"><dd class="mdescRight">Scales a BITMAP object into another BITMAP object by using DDA algorithm. <a href="#ga5"></a><br></dl><li>MG_EXPORT <a class="el" href="group__gdi__types.htm#ga8">gal_pixel</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga6">GetPixelInBitmap</a> (const <a class="el" href="struct__BITMAP.htm">BITMAP</a> *bmp, int x, int y)<dl class="el"><dd class="mdescRight">Returns the pixel value in a BITMAP object. <a href="#ga6"></a><br></dl><li>MG_EXPORT <a class="el" href="group__simple__types.htm#ga0">BOOL</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga7">SetPixelInBitmap</a> (const <a class="el" href="struct__BITMAP.htm">BITMAP</a> *bmp, int x, int y, <a class="el" href="group__gdi__types.htm#ga8">gal_pixel</a> pixel)<dl class="el"><dd class="mdescRight">Sets pixel value in a BITMAP object. <a href="#ga7"></a><br></dl><li>MG_EXPORT <a class="el" href="group__simple__types.htm#ga0">BOOL</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga8">SaveScreenRectContent</a> (const <a class="el" href="struct__RECT.htm">RECT</a> *rcWin, const char *filename)<dl class="el"><dd class="mdescRight">Saves content of a rectangle in the screen to a file. <a href="#ga8"></a><br></dl><li>MG_EXPORT <a class="el" href="group__simple__types.htm#ga0">BOOL</a> GUIAPI <a class="el" href="group__bmp__fns.htm#ga9">SaveMainWindowContent</a> (<a class="el" href="group__handles.htm#ga1">HWND</a> hWnd, const char *filename)<dl class="el"><dd class="mdescRight">Saves content of a main window to a file. <a href="#ga9"></a><br></dl></ul><hr><a name="_details"></a><h2>Detailed Description</h2>Example:<p><div class="fragment"><pre class="fragment">{ <span class="keywordtype">int</span> tox = 800, toy = 800; <span class="keywordtype">int</span> count; <a class="code" href="struct__BITMAP.htm">BITMAP</a> bitmap; <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> start_tick, end_tick; <span class="comment">/* Load the bitmap from the file. */</span> <span class="keywordflow">if</span> (<a class="code" href="group__bmp__load__fns.htm#ga63">LoadBitmap</a> (hdc, &bitmap, <span class="stringliteral">"res/icon.bmp"</span>)) <span class="keywordflow">return</span>; bitmap.<a class="code" href="struct__BITMAP.htm#o0">bmType</a> = BMP_TYPE_ALPHACHANNEL; <span class="comment">/* Fill a box with the bitmap with alpha channel. */</span> start_tick = <a class="code" href="group__timer__fns.htm#ga4">GetTickCount</a> (); count = 1000; <span class="keywordflow">while</span> (count--) { tox = rand() % 800; toy = rand() % 800; <span class="comment">/* Set a random alpha channel. */</span> bitmap.<a class="code" href="struct__BITMAP.htm#o3">bmAlpha</a> = rand() % 256; <span class="comment">/* Fill the box. */</span> <a class="code" href="group__bmp__fns.htm#ga1">FillBoxWithBitmap</a> (hdc, tox, toy, 0, 0, &bitmap); } end_tick = <a class="code" href="group__timer__fns.htm#ga4">GetTickCount</a> (); TellSpeed (hwnd, start_tick, end_tick, <span class="stringliteral">"Alpha Blended Bitmap"</span>, 1000); bitmap.<a class="code" href="struct__BITMAP.htm#o0">bmType</a> = BMP_TYPE_ALPHACHANNEL | BMP_TYPE_COLORKEY; <span class="comment">/* Set the color key (the transparent pixel) of the bitmap. */</span> bitmap.<a class="code" href="struct__BITMAP.htm#o4">bmColorKey</a> = <a class="code" href="group__bmp__fns.htm#ga6">GetPixelInBitmap</a> (&bitmap, 0, 0); <span class="comment">/* Fill a box with the bitmap with alpha channel and color key. */</span> start_tick = <a class="code" href="group__timer__fns.htm#ga4">GetTickCount</a> (); count = 1000; <span class="keywordflow">while</span> (count--) { tox = rand() % 800; toy = rand() % 800; <span class="comment">/* Set a random alpha channel. */</span> bitmap.<a class="code" href="struct__BITMAP.htm#o3">bmAlpha</a> = rand() % 256; <span class="comment">/* Fill the box. */</span> <a class="code" href="group__bmp__fns.htm#ga1">FillBoxWithBitmap</a> (hdc, tox, toy, 0, 0, &bitmap); } end_tick = <a class="code" href="group__timer__fns.htm#ga4">GetTickCount</a> (); TellSpeed (hwnd, start_tick, end_tick, <span class="stringliteral">"Alpha Blended Transparent Bitmap"</span>, 1000); <a class="code" href="group__bmp__load__fns.htm#ga8">UnloadBitmap</a> (&bitmap);}{ <span class="comment">/* Create a memory DC which hanve alpha per-pixel. */</span> mem_dc = <a class="code" href="group__dc__fns.htm#ga12">CreateMemDC</a> (400, 100, 16, MEMDC_FLAG_HWSURFACE | MEMDC_FLAG_SRCALPHA, 0x0000F000, 0x00000F00, 0x000000F0, 0x0000000F); <span class="comment">/* Set brush color and fill a box. */</span> <a class="code" href="group__dc__attrs.htm#ga31">SetBrushColor</a> (mem_dc, <a class="code" href="group__draw__fns.htm#ga15">RGBA2Pixel</a> (mem_dc, 0xFF, 0xFF, 0x00, 0xFF)); <a class="code" href="group__draw__fns.htm#ga40">FillBox</a> (mem_dc, 0, 0, 200, 50); <span class="comment">/* Set another brush color and fill a box */</span> <a class="code" href="group__dc__attrs.htm#ga31">SetBrushColor</a> (mem_dc, <a class="code" href="group__draw__fns.htm#ga15">RGBA2Pixel</a> (mem_dc, 0xFF, 0xFF, 0x00, 0x40)); <a class="code" href="group__draw__fns.htm#ga40">FillBox</a> (mem_dc, 200, 0, 200, 50); <span class="comment">/* Set another brush color and fill a box */</span> <a class="code" href="group__dc__attrs.htm#ga31">SetBrushColor</a> (mem_dc, <a class="code" href="group__draw__fns.htm#ga15">RGBA2Pixel</a> (mem_dc, 0xFF, 0xFF, 0x00, 0x80)); <a class="code" href="group__draw__fns.htm#ga40">FillBox</a> (mem_dc, 0, 50, 200, 50); <span class="comment">/* Set another brush color and fill a box */</span> <a class="code" href="group__dc__attrs.htm#ga31">SetBrushColor</a> (mem_dc, <a class="code" href="group__draw__fns.htm#ga15">RGBA2Pixel</a> (mem_dc, 0xFF, 0xFF, 0x00, 0xC0)); <a class="code" href="group__draw__fns.htm#ga40">FillBox</a> (mem_dc, 200, 50, 200, 50); <a class="code" href="group__dc__attrs.htm#ga29">SetBkMode</a> (mem_dc, BM_TRANSPARENT); <span class="comment">/* Set a text color and output the text */</span> <a class="code" href="group__dc__attrs.htm#ga32">SetTextColor</a> (mem_dc, <a class="code" href="group__draw__fns.htm#ga15">RGBA2Pixel</a> (mem_dc, 0x00, 0x00, 0x00, 0x80)); <a class="code" href="group__text__output__fns.htm#ga18">TabbedTextOut</a> (mem_dc, 0, 0, <span class="stringliteral">"Memory DC with alpha.\n"</span> <span class="stringliteral">"The source DC have alpha per-pixel."</span>); <span class="comment">/* Blitting to a client DC. */</span> start_tick = <a class="code" href="group__timer__fns.htm#ga4">GetTickCount</a> (); count = 100; <span class="keywordflow">while</span> (count--) { <a class="code" href="group__bmp__fns.htm#ga3">BitBlt</a> (mem_dc, 0, 0, 400, 100, hdc, rand () % 800, rand () % 800); } end_tick = <a class="code" href="group__timer__fns.htm#ga4">GetTickCount</a> (); TellSpeed (hwnd, start_tick, end_tick, <span class="stringliteral">"Alpha Blit"</span>, 100); <span class="comment">/* delete the momory DC. */</span> <a class="code" href="group__dc__fns.htm#ga19">DeleteMemDC</a> (mem_dc);}</pre></div> <hr><h2>Function Documentation</h2><a class="anchor" name="ga3" doxytag="gdi.h::BitBlt"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void GUIAPI BitBlt </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="group__handles.htm#ga2">HDC</a> </td> <td class="mdname" nowrap> <em>hsdc</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>sx</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>sy</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>sw</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>sh</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="group__handles.htm#ga2">HDC</a> </td> <td class="mdname" nowrap> <em>hddc</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>dx</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>dy</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="group__win32__types.htm#ga4">DWORD</a> </td> <td class="mdname" nowrap> <em>dwRop</em></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Performs a bit-block transfer from a device context into another device context. <p>This function performs a bit-block transfer of the color data cooresponding to a rectangle of pixels from the specified source device context <em>hsdc</em> into a destination device context <em>hddc</em>. <em></em>(sx,sy,sw,sh) specifies the rectangle in the source DC, and <em></em>(dx,dy) specifies the position of the rectangle in the destination DC. Note that the size of the two rectangles are identical.<p>Note that all coordinates should be in the device space.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>hsdc</em> </td><td>The source device context. </td></tr> <tr><td valign="top"></td><td valign="top"><em>sx</em> </td><td>The x coordinate of the upper-left corner of the rectangle in the source DC. </td></tr> <tr><td valign="top"></td><td valign="top"><em>sy</em> </td><td>The y coordinate of the upper-left corner of the rectangle in the source DC. </td></tr> <tr><td valign="top"></td><td valign="top"><em>sw</em> </td><td>The width of the source rectangle. </td></tr> <tr><td valign="top"></td><td valign="top"><em>sh</em> </td><td>The height of the source rectangle. </td></tr> <tr><td valign="top"></td><td valign="top"><em>hddc</em> </td><td>The destination device context <em>hddc</em>. </td></tr> <tr><td valign="top"></td><td valign="top"><em>dx</em> </td><td>The x coordinate of the upper-left corner of the rectangle in the destination DC. </td></tr> <tr><td valign="top"></td><td valign="top"><em>dy</em> </td><td>The y coordinate of the upper-left corner of the rectangle in the destination DC. </td></tr> <tr><td valign="top"></td><td valign="top"><em>dwRop</em> </td><td>The raster operation, currently ignored.</td></tr> </table></dl><dl compact><dt><b>Note:</b></dt><dd>If _USE_NEWGAL defined, the alpha and color key settings of the source DC will come into play.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__bmp__fns.htm#ga4">StretchBlt</a>, <a class="el" href="group__dc__fns.htm#ga17">SetMemDCAlpha</a>, <a class="el" href="group__dc__fns.htm#ga18">SetMemDCColorKey</a> </dd></dl> </td> </tr></table><a class="anchor" name="ga1" doxytag="gdi.h::FillBoxWithBitmap"></a><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -