comparison os2/dw.c @ 1243:c191a562c14a

Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2. Added new strech option to the test program to test this functionality. OS/2 version is untested and I am not sure I got the math right... GTK and Mac versions to come soon.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 19 Oct 2011 08:14:05 +0000
parents 365f92e85771
children db26b9622769
comparison
equal deleted inserted replaced
1242:8e37ebb3fab7 1243:c191a562c14a
8939 * xsrc: X coordinate of source. 8939 * xsrc: X coordinate of source.
8940 * ysrc: Y coordinate of source. 8940 * ysrc: Y coordinate of source.
8941 */ 8941 */
8942 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) 8942 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
8943 { 8943 {
8944 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1);
8945 }
8946
8947 /*
8948 * Copies from one surface to another allowing for stretching.
8949 * Parameters:
8950 * dest: Destination window handle.
8951 * destp: Destination pixmap. (choose only one).
8952 * xdest: X coordinate of destination.
8953 * ydest: Y coordinate of destination.
8954 * width: Width of the target area.
8955 * height: Height of the target area.
8956 * src: Source window handle.
8957 * srcp: Source pixmap. (choose only one).
8958 * xsrc: X coordinate of source.
8959 * ysrc: Y coordinate of source.
8960 * srcwidth: Width of area to copy.
8961 * srcheight: Height of area to copy.
8962 * Returns:
8963 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
8964 */
8965 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
8966 {
8944 HPS hpsdest; 8967 HPS hpsdest;
8945 HPS hpssrc; 8968 HPS hpssrc;
8946 POINTL ptl[4]; 8969 POINTL ptl[4];
8947 int destheight, srcheight; 8970 int dheight, sheight;
8948 8971 int count = 3;
8972
8949 if(dest) 8973 if(dest)
8950 { 8974 {
8951 hpsdest = WinGetPS(dest); 8975 hpsdest = WinGetPS(dest);
8952 destheight = _get_height(dest); 8976 dheight = _get_height(dest);
8953 } 8977 }
8954 else if(destp) 8978 else if(destp)
8955 { 8979 {
8956 hpsdest = destp->hps; 8980 hpsdest = destp->hps;
8957 destheight = destp->height; 8981 dheight = destp->height;
8958 } 8982 }
8959 else 8983 else
8960 return; 8984 return DW_ERROR_GENERAL;
8961 8985
8962 if(src) 8986 if(src)
8963 { 8987 {
8964 hpssrc = WinGetPS(src); 8988 hpssrc = WinGetPS(src);
8965 srcheight = _get_height(src); 8989 sheight = _get_height(src);
8966 } 8990 }
8967 else if(srcp) 8991 else if(srcp)
8968 { 8992 {
8969 hpssrc = srcp->hps; 8993 hpssrc = srcp->hps;
8970 srcheight = srcp->height; 8994 sheight = srcp->height;
8971 } 8995 }
8972 else 8996 else
8973 { 8997 {
8974 if(!destp) 8998 if(!destp)
8975 WinReleasePS(hpsdest); 8999 WinReleasePS(hpsdest);
8976 return; 9000 return DW_ERROR_GENERAL;
8977 } 9001 }
8978 9002
8979 ptl[0].x = xdest; 9003 ptl[0].x = xdest;
8980 ptl[0].y = (destheight - ydest) - height; 9004 ptl[0].y = (dheight - ydest) - height;
8981 ptl[1].x = ptl[0].x + width; 9005 ptl[1].x = ptl[0].x + width;
8982 ptl[1].y = destheight - ydest; 9006 ptl[1].y = dheight - ydest;
8983 ptl[2].x = xsrc; 9007 ptl[2].x = xsrc;
8984 ptl[2].y = srcheight - (ysrc + height); 9008 ptl[2].y = sheight - (ysrc + height);
8985 ptl[3].x = ptl[2].x + width; 9009 if(srcwidth != -1 && srcheigth != -1)
8986 ptl[3].y = ptl[2].y + height; 9010 {
9011 count = 4;
9012 ptl[3].x = ptl[2].x + srcwidth;
9013 ptl[3].y = ptl[2].y + srcheight;
9014 }
8987 9015
8988 /* Handle transparency if requested */ 9016 /* Handle transparency if requested */
8989 if(srcp && srcp->transcolor != DW_CLR_DEFAULT) 9017 if(srcp && srcp->transcolor != DW_CLR_DEFAULT)
8990 { 9018 {
8991 IMAGEBUNDLE newIb, oldIb; 9019 IMAGEBUNDLE newIb, oldIb;
8992 /* Transparent color is put into the background color */ 9020 /* Transparent color is put into the background color */
8993 GpiSetBackColor(hpsdest, srcp->transcolor); 9021 GpiSetBackColor(hpsdest, srcp->transcolor);
8994 GpiQueryAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, (PBUNDLE)&oldIb); 9022 GpiQueryAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, (PBUNDLE)&oldIb);
8995 newIb.usBackMixMode = BM_SRCTRANSPARENT; 9023 newIb.usBackMixMode = BM_SRCTRANSPARENT;
8996 GpiSetAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, 0, (PBUNDLE)&newIb); 9024 GpiSetAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, 0, (PBUNDLE)&newIb);
8997 GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE); 9025 GpiBitBlt(hpsdest, hpssrc, count, ptl, ROP_SRCCOPY, BBO_IGNORE);
8998 GpiSetAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, 0, (PBUNDLE)&oldIb); 9026 GpiSetAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, 0, (PBUNDLE)&oldIb);
8999 } 9027 }
9000 else 9028 else
9001 { 9029 {
9002 /* Otherwise use the regular BitBlt call */ 9030 /* Otherwise use the regular BitBlt call */
9003 GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE); 9031 GpiBitBlt(hpsdest, hpssrc, count, ptl, ROP_SRCCOPY, BBO_IGNORE);
9004 } 9032 }
9005 9033
9006 if(!destp) 9034 if(!destp)
9007 WinReleasePS(hpsdest); 9035 WinReleasePS(hpsdest);
9008 if(!srcp) 9036 if(!srcp)
9009 WinReleasePS(hpssrc); 9037 WinReleasePS(hpssrc);
9038 return DW_ERROR_NONE;
9010 } 9039 }
9011 9040
9012 /* Run DosBeep() in a separate thread so it doesn't block */ 9041 /* Run DosBeep() in a separate thread so it doesn't block */
9013 void _beepthread(void *data) 9042 void _beepthread(void *data)
9014 { 9043 {