Changeset 127 for trunk/src/helpers/gpih.c
- Timestamp:
- Jan 5, 2002, 8:11:10 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/gpih.c
r126 r127 1555 1555 1556 1556 /* 1557 *@@ gpihCreateBmpFromPS:1558 * this creates a new bitmap and copies a screen rectangle1559 * into it. Consider this a "screen capture" function.1560 *1561 * The new bitmap (which is returned) is compatible with the1562 * device associated with hpsScreen. This function calls1563 * gpihCreateMemPS and gpihCreateBitmap to have it created.1564 * The memory PS is only temporary and freed again.1565 *1566 * This returns the handle of the new bitmap,1567 * which can then be used for WinDrawBitmap and such, or1568 * NULLHANDLE upon errors.1569 *1570 *@@changed V0.9.12 (2001-05-20) [umoeller]: fixed excessive mem PS size1571 */1572 1573 HBITMAP gpihCreateBmpFromPS(HAB hab, // in: anchor block1574 HPS hpsScreen, // in: screen PS to copy from1575 PRECTL prcl) // in: rectangle to copy1576 {1577 1578 /* To copy an image from a display screen to a bit map:1579 1. Associate the memory device context with a presentation space.1580 2. Create a bit map.1581 3. Select the bit map into the memory device context by calling GpiSetBitmap.1582 4. Determine the location (in device coordinates) of the image.1583 5. Call GpiBitBlt and copy the image to the bit map. */1584 1585 HDC hdcMem;1586 HPS hpsMem;1587 HBITMAP hbm = NULLHANDLE;1588 POINTL aptl[3];1589 1590 SIZEL szlPage = {prcl->xRight - prcl->xLeft,1591 prcl->yTop - prcl->yBottom}; // fixed V0.9.12 (2001-05-20) [umoeller]1592 if (gpihCreateMemPS(hab,1593 &szlPage,1594 &hdcMem,1595 &hpsMem))1596 {1597 if ((hbm = gpihCreateBitmap(hpsMem,1598 szlPage.cx,1599 szlPage.cy)))1600 {1601 // Associate the bit map and the memory presentation space.1602 if (GpiSetBitmap(hpsMem, hbm)1603 != HBM_ERROR)1604 {1605 // Copy the screen to the bit map.1606 aptl[0].x = 0; // lower-left corner of destination rectangle1607 aptl[0].y = 0;1608 aptl[1].x = prcl->xRight; // upper-right corner for both1609 aptl[1].y = prcl->yTop;1610 aptl[2].x = prcl->xLeft; // lower-left corner of source rectangle1611 aptl[2].y = prcl->yBottom;1612 1613 if (GpiBitBlt(hpsMem,1614 hpsScreen,1615 sizeof(aptl) / sizeof(POINTL), // Number of points in aptl1616 aptl,1617 ROP_SRCCOPY,1618 BBO_IGNORE)1619 == GPI_ERROR)1620 {1621 // error during bitblt:1622 GpiDeleteBitmap(hbm);1623 hbm = NULLHANDLE; // for return code1624 }1625 }1626 else1627 {1628 // error selecting bitmap for hpsMem:1629 GpiDeleteBitmap(hbm);1630 hbm = NULLHANDLE; // for return code1631 }1632 }1633 1634 GpiDestroyPS(hpsMem);1635 DevCloseDC(hdcMem);1636 } // end if (hdcMem = DevOpenDC())1637 1638 return (hbm);1639 }1640 1641 /*1642 1557 *@@ gpihCreateHalftonedBitmap: 1643 1558 * this creates a half-toned copy of the … … 2246 2161 } 2247 2162 2248 2163 /* 2164 *@@ gpihCreateBmpFromPS: 2165 * this creates a new bitmap and copies a screen rectangle 2166 * into it. Consider this a "screen capture" function. 2167 * 2168 * The new bitmap (which is returned) is compatible with the 2169 * device associated with hpsScreen. This function calls 2170 * gpihCreateMemPS and gpihCreateBitmap to have it created. 2171 * The memory PS is only temporary and freed again. 2172 * 2173 * This returns the handle of the new bitmap, 2174 * which can then be used for WinDrawBitmap and such, or 2175 * NULLHANDLE upon errors. 2176 * 2177 *@@changed V0.9.12 (2001-05-20) [umoeller]: fixed excessive mem PS size 2178 *@@changed V0.9.16 (2001-01-04) [umoeller]: now creating XBITMAP 2179 */ 2180 2181 PXBITMAP gpihCreateBmpFromPS(HAB hab, // in: anchor block 2182 HPS hpsScreen, // in: screen PS to copy from 2183 PRECTL prcl) // in: rectangle to copy 2184 { 2185 2186 /* To copy an image from a display screen to a bit map: 2187 1. Associate the memory device context with a presentation space. 2188 2. Create a bit map. 2189 3. Select the bit map into the memory device context by calling GpiSetBitmap. 2190 4. Determine the location (in device coordinates) of the image. 2191 5. Call GpiBitBlt and copy the image to the bit map. */ 2192 2193 PXBITMAP pBmp; 2194 2195 if (pBmp = gpihCreateXBitmap(hab, 2196 prcl->xRight - prcl->xLeft, 2197 prcl->yTop - prcl->yBottom)) 2198 { 2199 POINTL aptl[3]; 2200 // Copy the screen to the bit map. 2201 aptl[0].x = 0; // lower-left corner of destination rectangle 2202 aptl[0].y = 0; 2203 aptl[1].x = prcl->xRight; // upper-right corner for both 2204 aptl[1].y = prcl->yTop; 2205 aptl[2].x = prcl->xLeft; // lower-left corner of source rectangle 2206 aptl[2].y = prcl->yBottom; 2207 2208 if (GpiBitBlt(pBmp->hpsMem, 2209 hpsScreen, 2210 sizeof(aptl) / sizeof(POINTL), // Number of points in aptl 2211 aptl, 2212 ROP_SRCCOPY, 2213 BBO_IGNORE) 2214 == GPI_ERROR) 2215 { 2216 // error during bitblt: 2217 gpihDestroyXBitmap(&pBmp); 2218 } 2219 } 2220 2221 return (pBmp); 2222 } 2223
Note:
See TracChangeset
for help on using the changeset viewer.