1996-11-17 19:59:11 +01:00
|
|
|
/*
|
|
|
|
* GDI bit-blit operations
|
|
|
|
*
|
|
|
|
* Copyright 1993, 1994 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1996-11-17 19:59:11 +01:00
|
|
|
*/
|
|
|
|
|
1999-07-31 19:36:48 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
1996-11-17 19:59:11 +01:00
|
|
|
#include "gdi.h"
|
2002-03-27 22:13:40 +01:00
|
|
|
#include "mfdrv/metafiledrv.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1996-11-17 19:59:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(metafile);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1996-11-17 19:59:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_PatBlt
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL MFDRV_PatBlt( PHYSDEV dev, INT left, INT top, INT width, INT height, DWORD rop )
|
1996-11-17 19:59:11 +01:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
MFDRV_MetaParam6( dev, META_PATBLT, left, top, width, height, HIWORD(rop), LOWORD(rop) );
|
1996-11-17 19:59:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_BitBlt
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL MFDRV_BitBlt( PHYSDEV devDst, INT xDst, INT yDst, INT width, INT height,
|
|
|
|
PHYSDEV devSrc, INT xSrc, INT ySrc, DWORD rop )
|
1996-11-17 19:59:11 +01:00
|
|
|
{
|
2002-08-28 02:55:52 +02:00
|
|
|
return MFDRV_StretchBlt(devDst, xDst, yDst, width, height, devSrc,
|
|
|
|
xSrc, ySrc, width, height, rop);
|
1996-11-17 19:59:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-15 18:46:51 +02:00
|
|
|
|
1996-11-17 19:59:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_StretchBlt
|
1999-04-15 18:46:51 +02:00
|
|
|
* this function contains TWO ways for procesing StretchBlt in metafiles,
|
|
|
|
* decide between rdFunction values META_STRETCHBLT or META_DIBSTRETCHBLT
|
|
|
|
* via #define STRETCH_VIA_DIB
|
1996-11-17 19:59:11 +01:00
|
|
|
*/
|
1999-04-15 18:46:51 +02:00
|
|
|
#define STRETCH_VIA_DIB
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL MFDRV_StretchBlt( PHYSDEV devDst, INT xDst, INT yDst, INT widthDst,
|
|
|
|
INT heightDst, PHYSDEV devSrc, INT xSrc, INT ySrc,
|
1999-04-15 18:46:51 +02:00
|
|
|
INT widthSrc, INT heightSrc, DWORD rop )
|
1996-11-17 19:59:11 +01:00
|
|
|
{
|
1999-04-15 18:46:51 +02:00
|
|
|
BOOL ret;
|
|
|
|
DWORD len;
|
|
|
|
METARECORD *mr;
|
2002-08-16 02:42:06 +02:00
|
|
|
BITMAP BM;
|
2002-03-28 23:22:05 +01:00
|
|
|
METAFILEDRV_PDEVICE *physDevSrc = (METAFILEDRV_PDEVICE *)devSrc;
|
2002-06-01 01:06:46 +02:00
|
|
|
#ifdef STRETCH_VIA_DIB
|
1999-04-15 18:46:51 +02:00
|
|
|
LPBITMAPINFOHEADER lpBMI;
|
|
|
|
WORD nBPP;
|
2002-06-01 01:06:46 +02:00
|
|
|
#endif
|
2004-11-24 19:08:18 +01:00
|
|
|
HBITMAP hBitmap = GetCurrentObject(physDevSrc->hdc, OBJ_BITMAP);
|
|
|
|
|
|
|
|
if (GetObjectW(hBitmap, sizeof(BITMAP), &BM) != sizeof(BITMAP))
|
|
|
|
{
|
|
|
|
WARN("bad bitmap object %p passed for hdc %p\n", hBitmap, physDevSrc->hdc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-04-15 18:46:51 +02:00
|
|
|
#ifdef STRETCH_VIA_DIB
|
|
|
|
nBPP = BM.bmPlanes * BM.bmBitsPixel;
|
2002-08-28 02:55:52 +02:00
|
|
|
if(nBPP > 8) nBPP = 24; /* FIXME Can't get 16bpp to work for some reason */
|
2002-06-01 01:06:46 +02:00
|
|
|
len = sizeof(METARECORD) + 10 * sizeof(INT16)
|
2002-08-28 02:55:52 +02:00
|
|
|
+ sizeof(BITMAPINFOHEADER) + (nBPP <= 8 ? 1 << nBPP: 0) * sizeof(RGBQUAD)
|
|
|
|
+ DIB_GetDIBWidthBytes(BM.bmWidth, nBPP) * BM.bmHeight;
|
2000-02-16 23:47:24 +01:00
|
|
|
if (!(mr = HeapAlloc( GetProcessHeap(), 0, len)))
|
1999-04-15 18:46:51 +02:00
|
|
|
return FALSE;
|
|
|
|
mr->rdFunction = META_DIBSTRETCHBLT;
|
|
|
|
lpBMI=(LPBITMAPINFOHEADER)(mr->rdParm+10);
|
|
|
|
lpBMI->biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
lpBMI->biWidth = BM.bmWidth;
|
|
|
|
lpBMI->biHeight = BM.bmHeight;
|
|
|
|
lpBMI->biPlanes = 1;
|
2002-08-28 02:55:52 +02:00
|
|
|
lpBMI->biBitCount = nBPP;
|
|
|
|
lpBMI->biSizeImage = DIB_GetDIBWidthBytes(BM.bmWidth, nBPP) * lpBMI->biHeight;
|
|
|
|
lpBMI->biClrUsed = nBPP <= 8 ? 1 << nBPP : 0;
|
1999-04-15 18:46:51 +02:00
|
|
|
lpBMI->biCompression = BI_RGB;
|
2004-11-24 19:08:18 +01:00
|
|
|
lpBMI->biXPelsPerMeter = MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSX),3937,100);
|
|
|
|
lpBMI->biYPelsPerMeter = MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSY),3937,100);
|
1999-04-15 18:46:51 +02:00
|
|
|
lpBMI->biClrImportant = 0; /* 1 meter = 39.37 inch */
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("MF_StretchBltViaDIB->len = %ld rop=%lx PixYPM=%ld Caps=%d\n",
|
2004-11-24 19:08:18 +01:00
|
|
|
len,rop,lpBMI->biYPelsPerMeter,GetDeviceCaps(physDevSrc->hdc, LOGPIXELSY));
|
|
|
|
|
|
|
|
if (GetDIBits(physDevSrc->hdc, hBitmap, 0, (UINT)lpBMI->biHeight,
|
1999-04-15 18:46:51 +02:00
|
|
|
(LPSTR)lpBMI + DIB_BitmapInfoSize( (BITMAPINFO *)lpBMI,
|
|
|
|
DIB_RGB_COLORS ),
|
|
|
|
(LPBITMAPINFO)lpBMI, DIB_RGB_COLORS))
|
|
|
|
#else
|
|
|
|
len = sizeof(METARECORD) + 15 * sizeof(INT16) + BM.bmWidthBytes * BM.bmHeight;
|
2000-02-16 23:47:24 +01:00
|
|
|
if (!(mr = HeapAlloc( GetProcessHeap(), 0, len )))
|
1999-04-15 18:46:51 +02:00
|
|
|
return FALSE;
|
|
|
|
mr->rdFunction = META_STRETCHBLT;
|
|
|
|
*(mr->rdParm +10) = BM.bmWidth;
|
|
|
|
*(mr->rdParm +11) = BM.bmHeight;
|
|
|
|
*(mr->rdParm +12) = BM.bmWidthBytes;
|
|
|
|
*(mr->rdParm +13) = BM.bmPlanes;
|
|
|
|
*(mr->rdParm +14) = BM.bmBitsPixel;
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("len = %ld rop=%lx \n",len,rop);
|
2004-11-24 19:08:18 +01:00
|
|
|
if (GetBitmapBits( hBitmap, BM.bmWidthBytes * BM.bmHeight, mr->rdParm + 15))
|
2002-06-01 01:06:46 +02:00
|
|
|
#endif
|
1999-04-15 18:46:51 +02:00
|
|
|
{
|
|
|
|
mr->rdSize = len / sizeof(INT16);
|
|
|
|
*(mr->rdParm) = LOWORD(rop);
|
|
|
|
*(mr->rdParm + 1) = HIWORD(rop);
|
|
|
|
*(mr->rdParm + 2) = heightSrc;
|
|
|
|
*(mr->rdParm + 3) = widthSrc;
|
|
|
|
*(mr->rdParm + 4) = ySrc;
|
|
|
|
*(mr->rdParm + 5) = xSrc;
|
|
|
|
*(mr->rdParm + 6) = heightDst;
|
|
|
|
*(mr->rdParm + 7) = widthDst;
|
|
|
|
*(mr->rdParm + 8) = yDst;
|
|
|
|
*(mr->rdParm + 9) = xDst;
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = MFDRV_WriteRecord( devDst, mr, mr->rdSize * 2);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-04-15 18:46:51 +02:00
|
|
|
else
|
|
|
|
ret = FALSE;
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, mr);
|
1999-04-15 18:46:51 +02:00
|
|
|
return ret;
|
1996-11-17 19:59:11 +01:00
|
|
|
}
|
1999-04-15 18:46:51 +02:00
|
|
|
|
|
|
|
|
1999-04-19 18:45:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_StretchDIBits
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
INT MFDRV_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst,
|
1999-04-19 18:45:24 +02:00
|
|
|
INT heightDst, INT xSrc, INT ySrc, INT widthSrc,
|
|
|
|
INT heightSrc, const void *bits,
|
|
|
|
const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
|
|
|
|
{
|
|
|
|
DWORD len, infosize, imagesize;
|
|
|
|
METARECORD *mr;
|
|
|
|
|
|
|
|
infosize = DIB_BitmapInfoSize(info, wUsage);
|
|
|
|
imagesize = DIB_GetDIBImageBytes( info->bmiHeader.biWidth,
|
|
|
|
info->bmiHeader.biHeight,
|
|
|
|
info->bmiHeader.biBitCount );
|
|
|
|
|
|
|
|
len = sizeof(METARECORD) + 10 * sizeof(WORD) + infosize + imagesize;
|
2000-02-16 23:47:24 +01:00
|
|
|
mr = (METARECORD *)HeapAlloc( GetProcessHeap(), 0, len );
|
1999-04-19 18:45:24 +02:00
|
|
|
if(!mr) return 0;
|
|
|
|
|
|
|
|
mr->rdSize = len / 2;
|
|
|
|
mr->rdFunction = META_STRETCHDIB;
|
|
|
|
mr->rdParm[0] = LOWORD(dwRop);
|
|
|
|
mr->rdParm[1] = HIWORD(dwRop);
|
|
|
|
mr->rdParm[2] = wUsage;
|
|
|
|
mr->rdParm[3] = (INT16)heightSrc;
|
|
|
|
mr->rdParm[4] = (INT16)widthSrc;
|
|
|
|
mr->rdParm[5] = (INT16)ySrc;
|
|
|
|
mr->rdParm[6] = (INT16)xSrc;
|
|
|
|
mr->rdParm[7] = (INT16)heightDst;
|
|
|
|
mr->rdParm[8] = (INT16)widthDst;
|
|
|
|
mr->rdParm[9] = (INT16)yDst;
|
|
|
|
mr->rdParm[10] = (INT16)xDst;
|
|
|
|
memcpy(mr->rdParm + 11, info, infosize);
|
|
|
|
memcpy(mr->rdParm + 11 + infosize / 2, bits, imagesize);
|
2002-03-28 23:22:05 +01:00
|
|
|
MFDRV_WriteRecord( dev, mr, mr->rdSize * 2 );
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, mr );
|
1999-04-19 18:45:24 +02:00
|
|
|
return heightSrc;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-04-19 18:45:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_SetDIBitsToDeivce
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
INT MFDRV_SetDIBitsToDevice( PHYSDEV dev, INT xDst, INT yDst, DWORD cx,
|
1999-04-19 18:45:24 +02:00
|
|
|
DWORD cy, INT xSrc, INT ySrc, UINT startscan,
|
|
|
|
UINT lines, LPCVOID bits, const BITMAPINFO *info,
|
|
|
|
UINT coloruse )
|
|
|
|
|
|
|
|
{
|
|
|
|
DWORD len, infosize, imagesize;
|
|
|
|
METARECORD *mr;
|
|
|
|
|
|
|
|
infosize = DIB_BitmapInfoSize(info, coloruse);
|
|
|
|
imagesize = DIB_GetDIBImageBytes( info->bmiHeader.biWidth,
|
|
|
|
info->bmiHeader.biHeight,
|
|
|
|
info->bmiHeader.biBitCount );
|
|
|
|
|
|
|
|
len = sizeof(METARECORD) + 8 * sizeof(WORD) + infosize + imagesize;
|
2000-02-16 23:47:24 +01:00
|
|
|
mr = (METARECORD *)HeapAlloc( GetProcessHeap(), 0, len );
|
1999-04-19 18:45:24 +02:00
|
|
|
if(!mr) return 0;
|
|
|
|
|
|
|
|
mr->rdSize = len / 2;
|
|
|
|
mr->rdFunction = META_SETDIBTODEV;
|
|
|
|
mr->rdParm[0] = coloruse;
|
|
|
|
mr->rdParm[1] = lines;
|
|
|
|
mr->rdParm[2] = startscan;
|
|
|
|
mr->rdParm[3] = (INT16)ySrc;
|
|
|
|
mr->rdParm[4] = (INT16)xSrc;
|
|
|
|
mr->rdParm[5] = (INT16)cy;
|
|
|
|
mr->rdParm[6] = (INT16)cx;
|
|
|
|
mr->rdParm[7] = (INT16)yDst;
|
|
|
|
mr->rdParm[8] = (INT16)xDst;
|
|
|
|
memcpy(mr->rdParm + 9, info, infosize);
|
|
|
|
memcpy(mr->rdParm + 9 + infosize / 2, bits, imagesize);
|
2002-03-28 23:22:05 +01:00
|
|
|
MFDRV_WriteRecord( dev, mr, mr->rdSize * 2 );
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, mr );
|
1999-04-19 18:45:24 +02:00
|
|
|
return lines;
|
|
|
|
}
|