Changeset 70 for trunk/src/helpers/gpih.c
- Timestamp:
- May 20, 2001, 5:38:55 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/gpih.c
r63 r70 1479 1479 bih2.usReserved = 0; 1480 1480 bih2.usRecording = BRA_BOTTOMUP; // scan lines are bottom to top (default) 1481 bih2.usRendering = BRH_NOTHALFTONED; // other algorithms aren't documented anyway s1482 bih2.cSize1 = 0; // parameter for halftoning (undocumented anyway s)1483 bih2.cSize2 = 0; // parameter for halftoning (undocumented anyway s)1481 bih2.usRendering = BRH_NOTHALFTONED; // other algorithms aren't documented anyway 1482 bih2.cSize1 = 0; // parameter for halftoning (undocumented anyway) 1483 bih2.cSize2 = 0; // parameter for halftoning (undocumented anyway) 1484 1484 bih2.ulColorEncoding = BCE_RGB; // only possible value 1485 1485 bih2.ulIdentifier = 0; // application-specific data … … 1545 1545 * which can then be used for WinDrawBitmap and such, or 1546 1546 * NULLHANDLE upon errors. 1547 * 1548 *@@changed V0.9.12 (2001-05-20) [umoeller]: fixed excessive mem PS size 1547 1549 */ 1548 1550 … … 1564 1566 POINTL aptl[3]; 1565 1567 1566 SIZEL szlPage = {0, 0}; 1567 if (gpihCreateMemPS(hab, &szlPage, &hdcMem, &hpsMem)) 1568 SIZEL szlPage = {prcl->xRight - prcl->xLeft, 1569 prcl->yTop - prcl->yBottom}; // fixed V0.9.12 (2001-05-20) [umoeller] 1570 if (gpihCreateMemPS(hab, 1571 &szlPage, 1572 &hdcMem, 1573 &hpsMem)) 1568 1574 { 1569 1575 if ((hbm = gpihCreateBitmap(hpsMem, 1570 prcl->xRight - prcl->xLeft,1571 prcl->yTop - prcl->yBottom)))1576 szlPage.cx, 1577 szlPage.cy))) 1572 1578 { 1573 1579 // Associate the bit map and the memory presentation space. … … 1595 1601 hbm = NULLHANDLE; // for return code 1596 1602 } 1597 } else { 1603 } 1604 else 1605 { 1598 1606 // error selecting bitmap for hpsMem: 1599 1607 GpiDeleteBitmap(hbm); … … 2019 2027 } 2020 2028 2029 /* 2030 *@@category: Helpers\PM helpers\GPI helpers\XBitmaps 2031 * Extended bitmaps. See gpihCreateXBitmap for an introduction. 2032 */ 2033 2034 /* ****************************************************************** 2035 * 2036 * XBitmap functions 2037 * 2038 ********************************************************************/ 2039 2040 /* 2041 *@@ gpihCreateXBitmap: 2042 * creates an XBitmap, which is returned in an 2043 * _XBITMAP structure. 2044 * 2045 * The problem with all the GPI bitmap functions 2046 * is that they are quite complex and it is easy 2047 * to forget one of the "disassociate" and "deselect" 2048 * functions, which then simply leads to enormous 2049 * resource leaks in the application. 2050 * 2051 * This function may relieve this a bit. This 2052 * creates a memory DC, an memory PS, and a bitmap, 2053 * and selects the bitmap into the memory PS. 2054 * You can then use any GPI function on the memory 2055 * PS to draw into the bitmap. Use the fields from 2056 * _XBITMAP for that. 2057 * 2058 * The bitmap is created in RGB mode. 2059 * 2060 * Use gpihDestroyXBitmap to destroy the XBitmap 2061 * again. 2062 * 2063 * Example: 2064 * 2065 + PXBITMAP pbmp = gpihCreateXBitmap(hab, 100, 100); 2066 + if (pbmp) 2067 + { 2068 + GpiMove(pbmp->hpsMem, ...); 2069 + GpiBox(pbmp->hpsMem, ...); 2070 + 2071 + WinDrawBitmap(hpsScreen, 2072 + pbmp->hbm, // bitmap handle 2073 + ...); 2074 + gpihDestroyXBitmap(&pbmp); 2075 + } 2076 * 2077 * Without the gpih* functions, the above would expand 2078 * to more than 100 lines. 2079 * 2080 *@@added V0.9.12 (2001-05-20) [umoeller] 2081 */ 2082 2083 PXBITMAP gpihCreateXBitmap(HAB hab, // in: anchor block 2084 LONG cx, // in: bitmap width 2085 LONG cy) // in: bitmap height 2086 { 2087 BOOL fOK = FALSE; 2088 PXBITMAP pbmp = (PXBITMAP)malloc(sizeof(XBITMAP)); 2089 if (pbmp) 2090 { 2091 memset(pbmp, 0, sizeof(XBITMAP)); 2092 2093 // create memory PS for bitmap 2094 pbmp->szl.cx = cx; 2095 pbmp->szl.cy = cy; 2096 if (gpihCreateMemPS(hab, 2097 &pbmp->szl, 2098 &pbmp->hdcMem, 2099 &pbmp->hpsMem)) 2100 { 2101 gpihSwitchToRGB(pbmp->hpsMem); 2102 if (pbmp->hbm = gpihCreateBitmap(pbmp->hpsMem, 2103 cx, 2104 cy)) 2105 { 2106 if (GpiSetBitmap(pbmp->hpsMem, 2107 pbmp->hbm) 2108 != HBM_ERROR) 2109 fOK = TRUE; 2110 } 2111 } 2112 2113 if (!fOK) 2114 gpihDestroyXBitmap(&pbmp); 2115 } 2116 2117 return (pbmp); 2118 } 2119 2120 /* 2121 *@@ gpihDestroyXBitmap: 2122 * destroys an XBitmap created with gpihCreateXBitmap. 2123 * 2124 * To be on the safe side, this sets the 2125 * bitmap pointer to NULL as well. 2126 * 2127 *@@added V0.9.12 (2001-05-20) [umoeller] 2128 */ 2129 2130 VOID gpihDestroyXBitmap(PXBITMAP *ppbmp) 2131 { 2132 if (ppbmp) 2133 { 2134 PXBITMAP pbmp; 2135 if (pbmp = *ppbmp) 2136 { 2137 if (pbmp->hbm) 2138 { 2139 if (pbmp->hpsMem) 2140 GpiSetBitmap(pbmp->hpsMem, NULLHANDLE); 2141 GpiDeleteBitmap(pbmp->hbm); 2142 } 2143 if (pbmp->hpsMem) 2144 { 2145 GpiAssociate(pbmp->hpsMem, NULLHANDLE); 2146 GpiDestroyPS(pbmp->hpsMem); 2147 } 2148 if (pbmp->hdcMem) 2149 DevCloseDC(pbmp->hdcMem); 2150 2151 free(pbmp); 2152 2153 *ppbmp = NULL; 2154 } 2155 } 2156 } 2157 2158
Note:
See TracChangeset
for help on using the changeset viewer.