Changeset 232 for trunk/src/helpers/gpih.c
- Timestamp:
- Dec 5, 2002, 9:36:28 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/gpih.c
r229 r232 134 134 { 135 135 if (prcl) 136 {137 136 return ( (x >= prcl->xLeft) 138 137 && (x <= prcl->xRight) … … 140 139 && (y <= prcl->yTop) 141 140 ); 142 }143 141 144 142 return FALSE; … … 163 161 prcl->yTop += l; 164 162 } 163 } 164 165 /* 166 *@@ gpihCopyRectIncl: 167 * copies prclWin to prclGpi, making it 168 * inclusive-inclusive for use with GPI 169 * functions. 170 * 171 *@@added V1.0.1 (2002-11-30) [umoeller] 172 */ 173 174 VOID gpihCopyRectIncl(PRECTL prclGpi, // out: GPI rectangle 175 PRECTL prclWin) // in: WIN rectangle 176 { 177 prclGpi->xLeft = prclWin->xLeft; 178 prclGpi->yBottom = prclWin->yBottom; 179 prclGpi->xRight = prclWin->xRight - 1; 180 prclGpi->yTop = prclWin->yTop - 1; 165 181 } 166 182 … … 1687 1703 } 1688 1704 1705 static const BITMAPINFOHEADER2 G_bih2Template[] = 1706 { 1707 sizeof(BITMAPINFOHEADER2), // ULONG cbFix; 1708 0, // ULONG cx; // tbr 1709 0, // ULONG cy; // tbr 1710 0, // USHORT cPlanes; // tbr 1711 0, // USHORT cBitCount; // tbr 1712 BCA_UNCOMP, // ULONG ulCompression; 1713 0, // ULONG cbImage; 1714 70, // ULONG cxResolution; 1715 70, // ULONG cyResolution; 1716 2, // ULONG cclrUsed; 1717 0, // ULONG cclrImportant; 1718 BRU_METRIC, // USHORT usUnits; 1719 // measure units for cxResolution/cyResolution: pels per meter 1720 0, // USHORT usReserved; 1721 BRA_BOTTOMUP, // USHORT usRecording; 1722 // scan lines are bottom to top (default) 1723 1724 BRH_NOTHALFTONED, // USHORT usRendering; 1725 // other algorithms aren't documented anyway 1726 0, // ULONG cSize1; 1727 // parameter for halftoning (undocumented anyway) 1728 0, // ULONG cSize2; 1729 // parameter for halftoning (undocumented anyway) 1730 BCE_RGB, // ULONG ulColorEncoding; 1731 // only possible value 1732 0 // ULONG ulIdentifier; 1733 // application-specific data 1734 }; 1735 1689 1736 /* 1690 1737 *@@ gpihCreateBitmap2: … … 1703 1750 * 1704 1751 *@@added V0.9.16 (2001-12-18) [umoeller] 1752 *@@changed V1.0.1 (2002-11-30) [umoeller]: optimized 1705 1753 */ 1706 1754 … … 1711 1759 ULONG cBitCount) // in: either 1, 4, or 24; if 0, current screen value 1712 1760 { 1713 HBITMAP hbm = NULLHANDLE;1714 1761 LONG alData[2]; 1715 1762 BITMAPINFOHEADER2 bih2; 1716 // PBITMAPINFO2 pbmi = NULL;1717 1763 1718 1764 // determine the device's plane/bit-count format; … … 1721 1767 if (GpiQueryDeviceBitmapFormats(hpsMem, 2, alData)) 1722 1768 { 1723 // set up the BITMAPINFOHEADER2 and BITMAPINFO2 structures 1724 bih2.cbFix = (ULONG)sizeof(BITMAPINFOHEADER2); 1769 // copy values from global template V1.0.1 (2002-11-30) [umoeller] 1770 memcpy(&bih2, &G_bih2Template, sizeof(bih2)); 1771 1772 // fix variable fields V1.0.1 (2002-11-30) [umoeller] 1725 1773 bih2.cx = cx; 1726 1774 bih2.cy = cy; 1727 1775 bih2.cPlanes = (cPlanes) ? cPlanes : alData[0]; 1728 1776 bih2.cBitCount = (cBitCount) ? cBitCount : alData[1]; 1729 bih2.ulCompression = BCA_UNCOMP;1730 1777 bih2.cbImage = ( ( (bih2.cx 1731 1778 * (1 << bih2.cPlanes) … … 1734 1781 ) / 32 1735 1782 ) * bih2.cy; 1736 bih2.cxResolution = 70;1737 bih2.cyResolution = 70;1738 bih2.cclrUsed = 2;1739 bih2.cclrImportant = 0;1740 bih2.usUnits = BRU_METRIC; // measure units for cxResolution/cyResolution: pels per meter1741 bih2.usReserved = 0;1742 bih2.usRecording = BRA_BOTTOMUP; // scan lines are bottom to top (default)1743 bih2.usRendering = BRH_NOTHALFTONED; // other algorithms aren't documented anyway1744 bih2.cSize1 = 0; // parameter for halftoning (undocumented anyway)1745 bih2.cSize2 = 0; // parameter for halftoning (undocumented anyway)1746 bih2.ulColorEncoding = BCE_RGB; // only possible value1747 bih2.ulIdentifier = 0; // application-specific data1748 1783 1749 1784 // create a bit map that is compatible with the display 1750 hbm =GpiCreateBitmap(hpsMem,1751 &bih2,1752 0, // do not initialize1753 NULL, // init data1754 NULL);1785 return GpiCreateBitmap(hpsMem, 1786 &bih2, 1787 0, // do not initialize 1788 NULL, // init data 1789 NULL); 1755 1790 } 1756 1791 1757 return hbm; 1792 return NULLHANDLE; 1793 } 1794 1795 /* 1796 *@@ gpihQueryBitmapSize: 1797 * returns the width and height of the given bitmap. 1798 * 1799 *@@added V1.0.1 (2002-11-30) [umoeller] 1800 */ 1801 1802 BOOL gpihQueryBitmapSize(HBITMAP hbm, // in: bitmap handle for query 1803 PSIZEL pszl) // out: size (cx, cy) of bitmap 1804 { 1805 BITMAPINFOHEADER2 bmi2; 1806 // query bitmap info 1807 bmi2.cbFix = sizeof(bmi2); 1808 if ( (hbm) 1809 && (GpiQueryBitmapInfoHeader(hbm, &bmi2)) 1810 ) 1811 { 1812 pszl->cx = bmi2.cx; 1813 pszl->cy = bmi2.cy; 1814 return TRUE; 1815 } 1816 1817 return FALSE; 1758 1818 } 1759 1819 … … 1776 1836 * 1777 1837 *@added V0.9.0 1838 *@@changed V1.0.1 (2002-11-30) [umoeller]: optimized 1778 1839 */ 1779 1840 … … 1786 1847 HDC hdcMem; 1787 1848 HPS hpsMem; 1788 BITMAPINFOHEADER2 bmi;1789 1790 if ( hbmSource)1849 SIZEL szlPage; 1850 1851 if (gpihQueryBitmapSize(hbmSource, &szlPage)) // V1.0.1 (2002-11-30) [umoeller] 1791 1852 { 1792 SIZEL szlPage;1793 // query bitmap info1794 bmi.cbFix = sizeof(bmi);1795 GpiQueryBitmapInfoHeader(hbmSource, &bmi);1796 1797 szlPage.cx = bmi.cx;1798 szlPage.cy = bmi.cy;1799 1853 if (gpihCreateMemPS(hab, &szlPage, &hdcMem, &hpsMem)) 1800 1854 { 1801 1855 if ((hbmReturn = gpihCreateBitmap(hpsMem, 1802 bmi.cx,1803 bmi.cy)))1856 szlPage.cx, 1857 szlPage.cy))) 1804 1858 { 1805 1859 if (GpiSetBitmap(hpsMem, hbmReturn) != HBM_ERROR) … … 1811 1865 // aptl[0]: target bottom-left, is all 0 1812 1866 // aptl[1]: target top-right (inclusive!) 1813 aptl[1].x = bmi.cx - 1;1814 aptl[1].y = bmi.cy - 1;1867 aptl[1].x = szlPage.cx - 1; 1868 aptl[1].y = szlPage.cy - 1; 1815 1869 // aptl[2]: source bottom-left, is all 0 1816 1870 1817 1871 // aptl[3]: source top-right (exclusive!) 1818 aptl[3].x = bmi.cx;1819 aptl[3].y = bmi.cy;1872 aptl[3].x = szlPage.cx; 1873 aptl[3].y = szlPage.cy; 1820 1874 GpiWCBitBlt(hpsMem, // target HPS (bmp selected) 1821 1875 hbmSource, … … 1832 1886 1833 1887 GpiMove(hpsMem, &aptl[0]); // still 0, 0 1834 aptl[0].x = bmi.cx - 1;1835 aptl[0].y = bmi.cy - 1;1888 aptl[0].x = szlPage.cx - 1; 1889 aptl[0].y = szlPage.cy - 1; 1836 1890 GpiSetColor(hpsMem, lColorGray); 1837 1891 GpiSetPattern(hpsMem, PATSYM_HALFTONE); … … 2326 2380 * 2327 2381 *@added V0.9.0 2382 *@@changed V1.0.1 (2002-11-30) [umoeller]: optimized 2328 2383 */ 2329 2384 … … 2334 2389 BOOL fProportional) // in: preserve proportions when stretching? 2335 2390 { 2336 BITMAPINFOHEADER2 bih2;2391 SIZEL szlBmp; 2337 2392 POINTL aptl[4]; 2338 2393 BOOL fCalculated = FALSE; 2339 2394 2395 if (!gpihQueryBitmapSize(hbmSource, &szlBmp)) // V1.0.1 (2002-11-30) [umoeller] 2396 return GPI_ERROR; 2397 2340 2398 memset(aptl, 0, sizeof(POINTL) * 4); 2341 2342 bih2.cbFix = sizeof(bih2);2343 GpiQueryBitmapInfoHeader(hbmSource,2344 &bih2);2345 2399 2346 2400 // aptl[2]: source bottom-left, is all 0 2347 2401 // aptl[3]: source top-right (exclusive!) 2348 aptl[3].x = bih2.cx;2349 aptl[3].y = bih2.cy;2402 aptl[3].x = szlBmp.cx; 2403 aptl[3].y = szlBmp.cy; 2350 2404 2351 2405 if (fProportional) … … 2356 2410 // large 2357 2411 2358 ULONG ulPropSource = ( bih2.cx * 1000)2359 / bih2.cy;2412 ULONG ulPropSource = (szlBmp.cx * 1000) 2413 / szlBmp.cy; 2360 2414 // e.g. if the bmp is 200 x 100, we now have 2000 2361 2415 ULONG ulPropTarget = ((prclTarget->xRight - prclTarget->xLeft) * 1000) … … 2430 2484 2431 2485 /* 2432 * gpihIcon2Bitmap:2433 * this paints the given icon/pointer into2434 * a bitmap. Note that if the bitmap is2435 * larget than the system icon size, only2436 * the rectangle of the icon will be filled2437 * with lBkgndColor.2438 *2439 * Returns FALSE upon errors.2440 *2441 *added V0.9.0 [umoeller]2442 *changed V0.9.16 (2001-10-15) [umoeller]: added pptlLowerLeft2443 *changed V0.9.16 (2001-10-15) [umoeller]: fixed inclusive/exclusive confusion (sigh...)2444 *changed V0.9.19 (2002-06-13) [umoeller]: fixed funny colors when scaling2445 *removed V0.9.19 (2002-06-18) [umoeller]2446 */2447 2448 #if 02449 2450 BOOL gpihIcon2Bitmap(HPS hpsMem, // in: target memory PS with bitmap selected into it2451 HPOINTER hptr, // in: source icon2452 LONG lBkgndColor, // in: background color for transparent areas2453 PPOINTL pptlLowerLeft, // in: lower left corner of where to paint (ptr can be NULL)2454 ULONG ulIconSize) // in: icon size (should be the value of WinQuerySysValue(HWND_DESKTOP, SV_CXICON))2455 {2456 BOOL brc = FALSE;2457 POINTERINFO pi;2458 2459 // Each icon consists of two (really three)2460 // bitmaps, which are stored in the POINTERINFO2461 // structure:2462 // pi.hbmColor is the actual bitmap to be2463 // drawn. The parts that are2464 // to be transparent or inverted2465 // are black in this image.2466 // pi.hbmPointer has twice the height of2467 // hbmColor. The upper bitmap2468 // contains an XOR mask (for2469 // inverting parts), the lower2470 // bitmap an AND mask (for2471 // transparent parts).2472 if (WinQueryPointerInfo(hptr, &pi))2473 {2474 POINTL ptlLowerLeft = {0, 0};2475 POINTL aptl[4];2476 memset(aptl, 0, sizeof(POINTL) * 4);2477 2478 if (pptlLowerLeft)2479 // lower left specified: V0.9.16 (2001-10-15) [umoeller]2480 memcpy(&ptlLowerLeft, pptlLowerLeft, sizeof(POINTL));2481 2482 // aptl[0]: target bottom-left, is all 02483 aptl[0].x = ptlLowerLeft.x;2484 aptl[0].y = ptlLowerLeft.y;2485 2486 // aptl[1]: target top-right (inclusive!)2487 // V0.9.16 (2001-10-15) [umoeller]: fixed rectangle confusion2488 aptl[1].x = ptlLowerLeft.x + ulIconSize - 1;2489 aptl[1].y = ptlLowerLeft.y + ulIconSize - 1;2490 2491 // aptl[2]: source bottom-left, is all 02492 2493 // aptl[3]: source top-right (exclusive!)2494 // V0.9.16 (2001-10-15) [umoeller]: fixed rectangle confusion2495 aptl[3].x = ulIconSize; // + 1;2496 aptl[3].y = ulIconSize; // + 1;2497 2498 GpiSetColor(hpsMem, CLR_WHITE);2499 GpiSetBackColor(hpsMem, CLR_BLACK);2500 2501 // GpiErase(hpsMem);2502 2503 // V0.9.19 (2002-06-13) [umoeller]:2504 // use BBO_IGNORE instead of BBO_OR or we get funny colors2505 // when scaling down2506 2507 // work on the AND image2508 GpiWCBitBlt(hpsMem, // target2509 pi.hbmPointer, // src bmp2510 4L, // must always be 42511 &aptl[0], // point array2512 ROP_SRCAND, // source AND target2513 BBO_IGNORE); // V0.9.19 (2002-06-13) [umoeller]2514 2515 // paint the real image2516 if (pi.hbmColor)2517 GpiWCBitBlt(hpsMem,2518 pi.hbmColor,2519 4L, // must always be 42520 &aptl[0], // point array2521 ROP_SRCPAINT, // source OR target2522 BBO_IGNORE); // V0.9.19 (2002-06-13) [umoeller]2523 2524 GpiSetColor(hpsMem, lBkgndColor);2525 // work on the XOR image2526 aptl[2].y = ulIconSize; // exclusive2527 aptl[3].y = (ulIconSize * 2); // /* + 1; */ // exclusive2528 // V0.9.16 (2001-10-15) [umoeller]: fixed rectangle confusion2529 GpiWCBitBlt(hpsMem,2530 pi.hbmPointer,2531 4L, // must always be 42532 &aptl[0], // point array2533 ROP_SRCINVERT,2534 BBO_IGNORE); // V0.9.19 (2002-06-13) [umoeller]2535 2536 brc = TRUE;2537 }2538 2539 return brc;2540 }2541 2542 #endif2543 2544 /*2545 2486 *@@ gpihDrawPointer: 2546 2487 * replacement for WinDrawPointer that can do clipping. … … 2585 2526 *@@changed V0.9.20 (2002-07-31) [umoeller]: optimized, saved one GpiQueryBitmapInfoHeader 2586 2527 *@@changed V0.9.20 (2002-08-04) [umoeller]: added DP_HALFTONED 2528 *@@changed V1.0.1 (2002-11-30) [umoeller]: optimized 2587 2529 */ 2588 2530 … … 2604 2546 POINTL aptl[4]; 2605 2547 HBITMAP hbmThis; 2606 BITMAPINFOHEADER2 bmiAndXor,2607 bmiColor;2548 SIZEL szlAndXor, // V1.0.1 (2002-11-30) [umoeller] 2549 szlColor; 2608 2550 2609 2551 // A HPOINTER really consists of two bitmaps, … … 2716 2658 ) 2717 2659 { 2718 bmiAndXor.cbFix = sizeof(bmiAndXor); 2719 GpiQueryBitmapInfoHeader(hbmThis, &bmiAndXor); 2660 gpihQueryBitmapSize(hbmThis, &szlAndXor); // V1.0.1 (2002-11-30) [umoeller] 2720 2661 2721 2662 // use only half the bitmap height 2722 cySrc = bmiAndXor.cy / 2;2663 cySrc = szlAndXor.cy / 2; 2723 2664 2724 2665 // aptl[2]: source bottom-left 2725 2666 aptl[2].x = 0 2726 + lClipLeft * bmiAndXor.cx / cxIcon;2667 + lClipLeft * szlAndXor.cx / cxIcon; 2727 2668 aptl[2].y = cySrc 2728 2669 + lClipBottom * cySrc / cyIcon; 2729 2670 2730 2671 // aptl[3]: source top-right (exclusive!) 2731 aptl[3].x = bmiAndXor.cx2732 - lClipRight * bmiAndXor.cx / cxIcon;2733 aptl[3].y = bmiAndXor.cy2672 aptl[3].x = szlAndXor.cx 2673 - lClipRight * szlAndXor.cx / cxIcon; 2674 aptl[3].y = szlAndXor.cy 2734 2675 - lClipTop * cySrc / cyIcon; 2735 2676 … … 2753 2694 ) 2754 2695 { 2755 bmiColor.cbFix = sizeof(bmiColor); 2756 GpiQueryBitmapInfoHeader(hbmThis, &bmiColor); 2696 gpihQueryBitmapSize(hbmThis, &szlColor); // V1.0.1 (2002-11-30) [umoeller] 2757 2697 2758 2698 // aptl[2]: source bottom-left 2759 2699 aptl[2].x = 0 2760 + lClipLeft * bmiColor.cx / cxIcon;2700 + lClipLeft * szlColor.cx / cxIcon; 2761 2701 aptl[2].y = 0 2762 + lClipBottom * bmiColor.cy / cyIcon;2702 + lClipBottom * szlColor.cy / cyIcon; 2763 2703 2764 2704 // aptl[3]: source top-right (exclusive!) 2765 aptl[3].x = bmiColor.cx2766 - lClipRight * bmiColor.cx / cxIcon;2767 aptl[3].y = bmiColor.cy2768 - lClipTop * bmiColor.cy / cyIcon;2705 aptl[3].x = szlColor.cx 2706 - lClipRight * szlColor.cx / cxIcon; 2707 aptl[3].y = szlColor.cy 2708 - lClipTop * szlColor.cy / cyIcon; 2769 2709 2770 2710 GpiWCBitBlt(hps, // target … … 2787 2727 ) 2788 2728 { 2789 /* we queried this one above V0.9.20 (2002-07-31) [umoeller] 2790 bmiAndXor.cbFix = sizeof(bmiAndXor); 2791 GpiQueryBitmapInfoHeader(hbmThis, &bmiAndXor); 2792 */ 2729 // we queried the size of this one above V0.9.20 (2002-07-31) [umoeller] 2793 2730 2794 2731 // use only half the bitmap height 2795 cySrc = bmiAndXor.cy / 2;2732 cySrc = szlAndXor.cy / 2; 2796 2733 2797 2734 // aptl[2]: source bottom-left 2798 2735 aptl[2].x = 0 2799 + lClipLeft * bmiAndXor.cx / cxIcon;2736 + lClipLeft * szlAndXor.cx / cxIcon; 2800 2737 aptl[2].y = 0 2801 2738 + lClipBottom * cySrc / cyIcon; 2802 2739 2803 2740 // aptl[3]: source top-right (exclusive!) 2804 aptl[3].x = bmiAndXor.cx2805 - lClipRight * bmiAndXor.cx / cxIcon;2741 aptl[3].x = szlAndXor.cx 2742 - lClipRight * szlAndXor.cx / cxIcon; 2806 2743 aptl[3].y = cySrc 2807 2744 - lClipTop * cySrc / cyIcon;
Note:
See TracChangeset
for help on using the changeset viewer.