Changeset 126 for trunk/src/helpers/gpih.c
- Timestamp:
- Dec 22, 2001, 12:10:30 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/gpih.c
r111 r126 62 62 // array for querying device capabilities (gpihQueryDisplayCaps) 63 63 LONG DisplayCaps[CAPS_DEVICE_POLYSET_POINTS] = {0}; 64 BOOL fCapsQueried = FALSE;64 BOOL G_fCapsQueried = FALSE; 65 65 66 66 /* … … 171 171 * This function will load all the device capabilities 172 172 * only once into a global array and re-use them afterwards. 173 * 174 *@@changed V0.9.16 (2001-12-18) [umoeller]: fixed multiple loads 173 175 */ 174 176 175 177 ULONG gpihQueryDisplayCaps(ULONG ulIndex) 176 178 { 177 if (! fCapsQueried)179 if (!G_fCapsQueried) 178 180 { 179 181 HPS hps = WinGetScreenPS(HWND_DESKTOP); 180 182 HDC hdc = GpiQueryDevice(hps); 181 183 DevQueryCaps(hdc, 0, CAPS_DEVICE_POLYSET_POINTS, &DisplayCaps[0]); 184 G_fCapsQueried = TRUE; // was missing V0.9.16 (2001-12-18) [umoeller] 182 185 } 183 186 … … 1459 1462 /* 1460 1463 *@@ gpihCreateBitmap: 1464 * calls gpihCreateBitmap2 with cPlanes and cBitCount == 0 1465 * for compatibility with exports. Widgets might 1466 * have used this func. 1467 * 1468 *@@changed V0.9.0 [umoeller]: function prototype changed to cx and cy 1469 *@@changed V0.9.16 (2001-12-18) [umoeller]: now using optimized gpihCreateBitmap2 1470 */ 1471 1472 HBITMAP gpihCreateBitmap(HPS hpsMem, // in: memory DC 1473 ULONG cx, // in: width of new bitmap 1474 ULONG cy) // in: height of new bitmap 1475 { 1476 return (gpihCreateBitmap2(hpsMem, 1477 cx, 1478 cy, 1479 0, 1480 0)); // current screen bit count 1481 } 1482 1483 /* 1484 *@@ gpihCreateBitmap2: 1461 1485 * creates a new bitmap for a given memory PS. 1462 1486 * This bitmap will have the cPlanes and bitcount … … 1472 1496 * Returns the bitmap handle or NULLHANDLE upon errors. 1473 1497 * 1474 *@@changed V0.9.0 [umoeller]: function prototype changed to cx and cy 1475 */ 1476 1477 HBITMAP gpihCreateBitmap(HPS hpsMem, // in: memory DC 1478 ULONG cx, // in: width of new bitmap 1479 ULONG cy) // in: height of new bitmap 1498 *@@added V0.9.16 (2001-12-18) [umoeller] 1499 */ 1500 1501 HBITMAP gpihCreateBitmap2(HPS hpsMem, // in: memory DC 1502 ULONG cx, // in: width of new bitmap 1503 ULONG cy, // in: height of new bitmap 1504 ULONG cPlanes, // in: color planes (usually 1); if 0, current screen is used 1505 ULONG cBitCount) // in: either 1, 4, or 24; if 0, current screen value 1480 1506 { 1481 1507 HBITMAP hbm = NULLHANDLE; 1482 1508 LONG alData[2]; 1483 1509 BITMAPINFOHEADER2 bih2; 1484 PBITMAPINFO2 pbmi = NULL;1510 // PBITMAPINFO2 pbmi = NULL; 1485 1511 1486 1512 // determine the device's plane/bit-count format; … … 1493 1519 bih2.cx = cx; // (prcl->xRight - prcl->xLeft); changed V0.9.0 1494 1520 bih2.cy = cy; // (prcl->yTop - prcl->yBottom); changed V0.9.0 1495 bih2.cPlanes = alData[0]; 1496 bih2.cBitCount = alData[1]; 1521 bih2.cPlanes = (cPlanes) ? cPlanes : alData[0]; 1522 bih2.cBitCount = (cBitCount) ? cBitCount : alData[1]; 1523 _Pmpf((__FUNCTION__ ": cPlanes %d, cBitCount %d", 1524 bih2.cPlanes, bih2.cBitCount)); 1497 1525 bih2.ulCompression = BCA_UNCOMP; 1498 1526 bih2.cbImage = ( ( (bih2.cx … … 1515 1543 bih2.ulIdentifier = 0; // application-specific data 1516 1544 1517 // allocate memory for info header 1518 if (DosAllocMem((PPVOID)&pbmi, 1519 sizeof(BITMAPINFO2) + 1520 (sizeof(RGB2) 1521 * (1 << bih2.cPlanes) 1522 * (1 << bih2.cBitCount) 1523 ), 1524 PAG_COMMIT | PAG_READ | PAG_WRITE) 1525 == NO_ERROR) 1526 { 1527 pbmi->cbFix = bih2.cbFix; 1528 pbmi->cx = bih2.cx; 1529 pbmi->cy = bih2.cy; 1530 pbmi->cPlanes = bih2.cPlanes; 1531 pbmi->cBitCount = bih2.cBitCount; 1532 pbmi->ulCompression = BCA_UNCOMP; 1533 pbmi->cbImage = ((bih2.cx+31)/32) * bih2.cy; 1534 pbmi->cxResolution = 70; 1535 pbmi->cyResolution = 70; 1536 pbmi->cclrUsed = 2; 1537 pbmi->cclrImportant = 0; 1538 pbmi->usUnits = BRU_METRIC; 1539 pbmi->usReserved = 0; 1540 pbmi->usRecording = BRA_BOTTOMUP; 1541 pbmi->usRendering = BRH_NOTHALFTONED; 1542 pbmi->cSize1 = 0; 1543 pbmi->cSize2 = 0; 1544 pbmi->ulColorEncoding = BCE_RGB; 1545 pbmi->ulIdentifier = 0; 1546 1547 // create a bit map that is compatible with the display 1548 hbm = GpiCreateBitmap(hpsMem, 1549 &bih2, 1550 FALSE, 1551 NULL, 1552 pbmi); 1553 1554 // free the memory we allocated previously; GPI has 1555 // allocated all the resources it needs itself, so 1556 // we can release this 1557 DosFreeMem(pbmi); 1558 } 1545 // create a bit map that is compatible with the display 1546 hbm = GpiCreateBitmap(hpsMem, 1547 &bih2, 1548 0, // do not initialize 1549 NULL, 1550 NULL); 1559 1551 } 1560 1552 … … 2086 2078 /* 2087 2079 *@@ gpihCreateXBitmap: 2080 * calls gpihCreateXBitmap2 with cPlanes and cBitCount == 0 2081 * for compatibility with exports. Widgets might 2082 * have used this func. 2083 * 2084 *@@added V0.9.12 (2001-05-20) [umoeller] 2085 *@@changed V0.9.16 (2001-12-18) [umoeller]: now using optimized gpihCreateXBitmap2 2086 */ 2087 2088 PXBITMAP gpihCreateXBitmap(HAB hab, // in: anchor block 2089 LONG cx, // in: bitmap width 2090 LONG cy) // in: bitmap height 2091 { 2092 return (gpihCreateXBitmap2(hab, 2093 cx, 2094 cy, 2095 0, 2096 0)); 2097 } 2098 2099 /* 2100 *@@ gpihCreateXBitmap: 2088 2101 * creates an XBitmap, which is returned in an 2089 2102 * _XBITMAP structure. … … 2124 2137 * to more than 100 lines. 2125 2138 * 2126 *@@added V0.9.12 (2001-05-20) [umoeller] 2127 */ 2128 2129 PXBITMAP gpihCreateXBitmap(HAB hab, // in: anchor block 2130 LONG cx, // in: bitmap width 2131 LONG cy) // in: bitmap height 2139 *@@added V0.9.16 (2001-12-18) [umoeller] 2140 */ 2141 2142 PXBITMAP gpihCreateXBitmap2(HAB hab, // in: anchor block 2143 LONG cx, // in: bitmap width 2144 LONG cy, // in: bitmap height 2145 ULONG cPlanes, // in: color planes (usually 1); if 0, current screen is used 2146 ULONG cBitCount) // in: either 1, 4, or 24; if 0, current screen value 2132 2147 { 2133 2148 BOOL fOK = FALSE; … … 2145 2160 &pbmp->hpsMem)) 2146 2161 { 2147 gpihSwitchToRGB(pbmp->hpsMem); 2148 if (pbmp->hbm = gpihCreateBitmap(pbmp->hpsMem, 2149 cx, 2150 cy)) 2162 if (cBitCount != 1) 2163 // not monochrome bitmap: 2164 gpihSwitchToRGB(pbmp->hpsMem); 2165 2166 if (pbmp->hbm = gpihCreateBitmap2(pbmp->hpsMem, 2167 cx, 2168 cy, 2169 cPlanes, 2170 cBitCount)) 2151 2171 { 2152 2172 if (GpiSetBitmap(pbmp->hpsMem, … … 2162 2182 2163 2183 return (pbmp); 2184 } 2185 2186 /* 2187 *@@ gpihDetachBitmap: 2188 * "detaches" the bitmap from the given XBITMAP. 2189 * This will deselect the bitmap from the internal 2190 * memory PS so it can be used with many OS/2 APIs 2191 * that require that the bitmap not be selected 2192 * into any memory PS. 2193 * 2194 * Note that it then becomes the responsibility 2195 * of the caller to explicitly call GpiDeleteBitmap 2196 * because it will not be deleted by gpihDestroyXBitmap. 2197 * 2198 *@@added V0.9.16 (2001-12-18) [umoeller] 2199 */ 2200 2201 HBITMAP gpihDetachBitmap(PXBITMAP pbmp) 2202 { 2203 HBITMAP hbm = pbmp->hbm; 2204 pbmp->hbm = NULLHANDLE; 2205 GpiSetBitmap(pbmp->hpsMem, NULLHANDLE); 2206 2207 return (hbm); 2164 2208 } 2165 2209
Note:
See TracChangeset
for help on using the changeset viewer.