1998-10-24 12:44:05 +02:00
|
|
|
/*
|
|
|
|
* PostScript driver bitmap functions
|
|
|
|
*
|
|
|
|
* Copyright 1998 Huw D M Davies
|
|
|
|
*
|
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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-10-24 12:44:05 +02:00
|
|
|
*/
|
|
|
|
|
2003-05-19 21:06:47 +02:00
|
|
|
#include <assert.h>
|
2003-11-03 23:14:46 +01:00
|
|
|
#include <stdlib.h>
|
2003-05-19 21:06:47 +02:00
|
|
|
|
1998-10-24 12:44:05 +02:00
|
|
|
#include "psdrv.h"
|
1999-03-23 14:46:04 +01:00
|
|
|
#include "winbase.h"
|
2002-03-28 23:22:05 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-23 14:46:04 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-03-23 14:46:04 +01:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
/* Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned. */
|
2007-03-17 11:43:46 +01:00
|
|
|
static inline int get_dib_width_bytes( int width, int depth )
|
2002-03-28 23:22:05 +01:00
|
|
|
{
|
|
|
|
int words;
|
|
|
|
|
|
|
|
switch(depth)
|
|
|
|
{
|
|
|
|
case 1: words = (width + 31) / 32; break;
|
|
|
|
case 4: words = (width + 7) / 8; break;
|
|
|
|
case 8: words = (width + 3) / 4; break;
|
|
|
|
case 15:
|
|
|
|
case 16: words = (width + 1) / 2; break;
|
|
|
|
case 24: words = (width * 3 + 3)/4; break;
|
|
|
|
default:
|
|
|
|
WARN("(%d): Unsupported depth\n", depth );
|
|
|
|
/* fall through */
|
|
|
|
case 32: words = width; break;
|
|
|
|
}
|
|
|
|
return 4 * words;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the bitmap info from either an INFOHEADER or COREHEADER bitmap */
|
|
|
|
static BOOL get_bitmap_info( const void *ptr, LONG *width, LONG *height, WORD *bpp, WORD *compr )
|
|
|
|
{
|
|
|
|
const BITMAPINFOHEADER *header = ptr;
|
|
|
|
|
|
|
|
switch(header->biSize)
|
|
|
|
{
|
|
|
|
case sizeof(BITMAPCOREHEADER):
|
|
|
|
{
|
2004-11-30 22:02:46 +01:00
|
|
|
const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)header;
|
2002-03-28 23:22:05 +01:00
|
|
|
*width = core->bcWidth;
|
|
|
|
*height = core->bcHeight;
|
|
|
|
*bpp = core->bcBitCount;
|
|
|
|
*compr = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case sizeof(BITMAPINFOHEADER):
|
|
|
|
case sizeof(BITMAPV4HEADER):
|
|
|
|
case sizeof(BITMAPV5HEADER):
|
|
|
|
/* V4 and V5 structures are a superset of the INFOHEADER structure */
|
|
|
|
*width = header->biWidth;
|
|
|
|
*height = header->biHeight;
|
|
|
|
*bpp = header->biBitCount;
|
|
|
|
*compr = header->biCompression;
|
|
|
|
return TRUE;
|
|
|
|
default:
|
2006-10-13 11:25:03 +02:00
|
|
|
ERR("(%d): unknown/wrong size for header\n", header->biSize );
|
2002-03-28 23:22:05 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-23 14:46:04 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* PSDRV_WriteImageHeader
|
|
|
|
*
|
|
|
|
* Helper for PSDRV_StretchDIBits
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Uses level 2 PostScript
|
|
|
|
*/
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
static BOOL PSDRV_WriteImageHeader(PSDRV_PDEVICE *physDev, const BITMAPINFO *info, INT xDst,
|
1999-03-23 14:46:04 +01:00
|
|
|
INT yDst, INT widthDst, INT heightDst,
|
|
|
|
INT widthSrc, INT heightSrc)
|
|
|
|
{
|
|
|
|
COLORREF map[256];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
switch(info->bmiHeader.biBitCount) {
|
|
|
|
case 8:
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteIndexColorSpaceBegin(physDev, 255);
|
1999-03-23 14:46:04 +01:00
|
|
|
for(i = 0; i < 256; i++) {
|
|
|
|
map[i] = info->bmiColors[i].rgbRed |
|
|
|
|
info->bmiColors[i].rgbGreen << 8 |
|
|
|
|
info->bmiColors[i].rgbBlue << 16;
|
|
|
|
}
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteRGB(physDev, map, 256);
|
|
|
|
PSDRV_WriteIndexColorSpaceEnd(physDev);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteIndexColorSpaceBegin(physDev, 15);
|
1999-03-23 14:46:04 +01:00
|
|
|
for(i = 0; i < 16; i++) {
|
|
|
|
map[i] = info->bmiColors[i].rgbRed |
|
|
|
|
info->bmiColors[i].rgbGreen << 8 |
|
|
|
|
info->bmiColors[i].rgbBlue << 16;
|
|
|
|
}
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteRGB(physDev, map, 16);
|
|
|
|
PSDRV_WriteIndexColorSpaceEnd(physDev);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteIndexColorSpaceBegin(physDev, 1);
|
1999-03-23 14:46:04 +01:00
|
|
|
for(i = 0; i < 2; i++) {
|
|
|
|
map[i] = info->bmiColors[i].rgbRed |
|
|
|
|
info->bmiColors[i].rgbGreen << 8 |
|
|
|
|
info->bmiColors[i].rgbBlue << 16;
|
|
|
|
}
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteRGB(physDev, map, 2);
|
|
|
|
PSDRV_WriteIndexColorSpaceEnd(physDev);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
case 24:
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
PSCOLOR pscol;
|
|
|
|
pscol.type = PSCOLOR_RGB;
|
|
|
|
pscol.value.rgb.r = pscol.value.rgb.g = pscol.value.rgb.b = 0.0;
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteSetColor(physDev, &pscol);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("Not implemented yet\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-11-02 20:25:51 +01:00
|
|
|
PSDRV_WriteImage(physDev, info->bmiHeader.biBitCount, xDst, yDst,
|
|
|
|
widthDst, heightDst, widthSrc, heightSrc, FALSE);
|
2003-05-19 21:06:47 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* PSDRV_WriteImageMaskHeader
|
|
|
|
*
|
|
|
|
* Helper for PSDRV_StretchDIBits
|
|
|
|
*
|
|
|
|
* We use the imagemask operator for 1bpp bitmaps since the output
|
|
|
|
* takes much less time for the printer to render.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Uses level 2 PostScript
|
|
|
|
*/
|
|
|
|
|
|
|
|
static BOOL PSDRV_WriteImageMaskHeader(PSDRV_PDEVICE *physDev, const BITMAPINFO *info, INT xDst,
|
|
|
|
INT yDst, INT widthDst, INT heightDst,
|
|
|
|
INT widthSrc, INT heightSrc)
|
|
|
|
{
|
|
|
|
COLORREF map[2];
|
|
|
|
PSCOLOR bkgnd, foregnd;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
assert(info->bmiHeader.biBitCount == 1);
|
|
|
|
|
|
|
|
for(i = 0; i < 2; i++) {
|
|
|
|
map[i] = info->bmiColors[i].rgbRed |
|
|
|
|
info->bmiColors[i].rgbGreen << 8 |
|
|
|
|
info->bmiColors[i].rgbBlue << 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We'll write the mask with -ve polarity so that
|
|
|
|
the foregnd color corresponds to a bit equal to
|
|
|
|
0 in the bitmap.
|
|
|
|
*/
|
|
|
|
PSDRV_CreateColor(physDev, &foregnd, map[0]);
|
|
|
|
PSDRV_CreateColor(physDev, &bkgnd, map[1]);
|
|
|
|
|
|
|
|
PSDRV_WriteGSave(physDev);
|
|
|
|
PSDRV_WriteNewPath(physDev);
|
|
|
|
PSDRV_WriteRectangle(physDev, xDst, yDst, widthDst, heightDst);
|
|
|
|
PSDRV_WriteSetColor(physDev, &bkgnd);
|
|
|
|
PSDRV_WriteFill(physDev);
|
|
|
|
PSDRV_WriteGRestore(physDev);
|
|
|
|
|
|
|
|
PSDRV_WriteSetColor(physDev, &foregnd);
|
2004-11-02 20:25:51 +01:00
|
|
|
PSDRV_WriteImage(physDev, 1, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc, TRUE);
|
2003-05-19 21:06:47 +02:00
|
|
|
|
1999-03-23 14:46:04 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
1998-10-24 12:44:05 +02:00
|
|
|
|
2003-12-08 22:40:27 +01:00
|
|
|
static inline DWORD max_rle_size(DWORD size)
|
|
|
|
{
|
|
|
|
return size + (size + 127) / 128 + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD max_ascii85_size(DWORD size)
|
|
|
|
{
|
|
|
|
return (size + 3) / 4 * 5;
|
|
|
|
}
|
1998-10-24 12:44:05 +02:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* PSDRV_StretchDIBits
|
1999-03-23 14:46:04 +01:00
|
|
|
*
|
|
|
|
* BUGS
|
1999-12-25 23:56:13 +01:00
|
|
|
* Doesn't work correctly if xSrc isn't byte aligned - this affects 1 and 4
|
|
|
|
* bit depths.
|
1999-03-23 14:46:04 +01:00
|
|
|
* Compression not implemented.
|
1998-10-24 12:44:05 +02:00
|
|
|
*/
|
2009-03-11 14:10:13 +01:00
|
|
|
INT CDECL PSDRV_StretchDIBits( PSDRV_PDEVICE *physDev, INT xDst, INT yDst, INT widthDst,
|
|
|
|
INT heightDst, INT xSrc, INT ySrc,
|
|
|
|
INT widthSrc, INT heightSrc, const void *bits,
|
|
|
|
const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
|
1998-10-24 12:44:05 +02:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
LONG fullSrcWidth, fullSrcHeight;
|
2009-11-18 13:20:17 +01:00
|
|
|
INT stride;
|
1999-03-23 14:46:04 +01:00
|
|
|
WORD bpp, compression;
|
|
|
|
INT line;
|
2002-05-02 03:39:48 +02:00
|
|
|
POINT pt[2];
|
2003-12-08 22:40:27 +01:00
|
|
|
const BYTE *src_ptr;
|
|
|
|
BYTE *dst_ptr, *bitmap, *rle, *ascii85;
|
|
|
|
DWORD rle_len, ascii85_len, bitmap_size;
|
1999-03-23 14:46:04 +01:00
|
|
|
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("%p (%d,%d %dx%d) -> (%d,%d %dx%d)\n", physDev->hdc,
|
1999-03-23 14:46:04 +01:00
|
|
|
xSrc, ySrc, widthSrc, heightSrc, xDst, yDst, widthDst, heightDst);
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
if (!get_bitmap_info( info, &fullSrcWidth, &fullSrcHeight, &bpp, &compression )) return FALSE;
|
1999-03-23 14:46:04 +01:00
|
|
|
|
2009-11-18 13:20:17 +01:00
|
|
|
stride = get_dib_width_bytes(fullSrcWidth, bpp);
|
2009-11-18 17:39:27 +01:00
|
|
|
if(fullSrcHeight < 0) stride = -stride; /* top-down */
|
1999-03-23 14:46:04 +01:00
|
|
|
|
2006-10-13 11:25:03 +02:00
|
|
|
TRACE("full size=%dx%d bpp=%d compression=%d rop=%08x\n", fullSrcWidth,
|
2003-05-19 21:06:47 +02:00
|
|
|
fullSrcHeight, bpp, compression, dwRop);
|
1998-10-24 12:44:05 +02:00
|
|
|
|
|
|
|
|
1999-03-23 14:46:04 +01:00
|
|
|
if(compression != BI_RGB) {
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("Compression not supported\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-05-02 03:39:48 +02:00
|
|
|
pt[0].x = xDst;
|
|
|
|
pt[0].y = yDst;
|
|
|
|
pt[1].x = xDst + widthDst;
|
|
|
|
pt[1].y = yDst + heightDst;
|
|
|
|
LPtoDP( physDev->hdc, pt, 2 );
|
|
|
|
xDst = pt[0].x;
|
|
|
|
yDst = pt[0].y;
|
|
|
|
widthDst = pt[1].x - pt[0].x;
|
|
|
|
heightDst = pt[1].y - pt[0].y;
|
1999-03-23 14:46:04 +01:00
|
|
|
|
|
|
|
switch(bpp) {
|
|
|
|
|
|
|
|
case 1:
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_SetClip(physDev);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteGSave(physDev);
|
2003-05-19 21:06:47 +02:00
|
|
|
|
|
|
|
/* Use imagemask rather than image */
|
|
|
|
PSDRV_WriteImageMaskHeader(physDev, info, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc);
|
2003-12-08 22:40:27 +01:00
|
|
|
src_ptr = bits;
|
2009-11-18 17:39:27 +01:00
|
|
|
if(stride < 0) src_ptr += (fullSrcHeight + 1) * stride;
|
2009-11-18 13:20:17 +01:00
|
|
|
src_ptr += (ySrc * stride);
|
1999-12-25 23:56:13 +01:00
|
|
|
if(xSrc & 7)
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("This won't work...\n");
|
2003-12-08 22:40:27 +01:00
|
|
|
bitmap_size = heightSrc * ((widthSrc + 7) / 8);
|
|
|
|
dst_ptr = bitmap = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
|
2009-11-18 13:20:17 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, src_ptr += stride, dst_ptr += ((widthSrc + 7) / 8))
|
2003-12-08 22:40:27 +01:00
|
|
|
memcpy(dst_ptr, src_ptr + xSrc / 8, (widthSrc + 7) / 8);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_SetClip(physDev);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteGSave(physDev);
|
|
|
|
PSDRV_WriteImageHeader(physDev, info, xDst, yDst, widthDst, heightDst,
|
1999-03-23 14:46:04 +01:00
|
|
|
widthSrc, heightSrc);
|
2003-12-08 22:40:27 +01:00
|
|
|
src_ptr = bits;
|
2009-11-18 17:39:27 +01:00
|
|
|
if(stride < 0) src_ptr += (fullSrcHeight + 1) * stride;
|
2009-11-18 13:20:17 +01:00
|
|
|
src_ptr += (ySrc * stride);
|
1999-12-25 23:56:13 +01:00
|
|
|
if(xSrc & 1)
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("This won't work...\n");
|
2003-12-08 22:40:27 +01:00
|
|
|
bitmap_size = heightSrc * ((widthSrc + 1) / 2);
|
|
|
|
dst_ptr = bitmap = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
|
2009-11-18 13:20:17 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, src_ptr += stride, dst_ptr += ((widthSrc + 1) / 2))
|
2003-12-08 22:40:27 +01:00
|
|
|
memcpy(dst_ptr, src_ptr + xSrc/2, (widthSrc+1)/2);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_SetClip(physDev);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteGSave(physDev);
|
|
|
|
PSDRV_WriteImageHeader(physDev, info, xDst, yDst, widthDst, heightDst,
|
1999-03-23 14:46:04 +01:00
|
|
|
widthSrc, heightSrc);
|
2003-12-08 22:40:27 +01:00
|
|
|
src_ptr = bits;
|
2009-11-18 17:39:27 +01:00
|
|
|
if(stride < 0) src_ptr += (fullSrcHeight + 1) * stride;
|
2009-11-18 13:20:17 +01:00
|
|
|
src_ptr += (ySrc * stride);
|
2003-12-08 22:40:27 +01:00
|
|
|
bitmap_size = heightSrc * widthSrc;
|
|
|
|
dst_ptr = bitmap = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
|
2009-11-18 13:20:17 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, src_ptr += stride, dst_ptr += widthSrc)
|
2003-12-08 22:40:27 +01:00
|
|
|
memcpy(dst_ptr, src_ptr + xSrc, widthSrc);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
case 16:
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_SetClip(physDev);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteGSave(physDev);
|
|
|
|
PSDRV_WriteImageHeader(physDev, info, xDst, yDst, widthDst, heightDst,
|
1999-03-23 14:46:04 +01:00
|
|
|
widthSrc, heightSrc);
|
|
|
|
|
2003-12-08 22:40:27 +01:00
|
|
|
|
|
|
|
src_ptr = bits;
|
2009-11-18 17:39:27 +01:00
|
|
|
if(stride < 0) src_ptr += (fullSrcHeight + 1) * stride;
|
2009-11-18 13:20:17 +01:00
|
|
|
src_ptr += (ySrc * stride);
|
2004-11-30 22:02:46 +01:00
|
|
|
bitmap_size = heightSrc * widthSrc * 3;
|
2003-12-08 22:40:27 +01:00
|
|
|
dst_ptr = bitmap = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
|
|
|
|
|
2009-11-18 13:20:17 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, src_ptr += stride) {
|
2003-12-08 22:40:27 +01:00
|
|
|
const WORD *words = (const WORD *)src_ptr + xSrc;
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < widthSrc; i++) {
|
|
|
|
BYTE r, g, b;
|
|
|
|
|
|
|
|
/* We want 0x0 -- 0x1f to map to 0x0 -- 0xff */
|
|
|
|
r = words[i] >> 10 & 0x1f;
|
|
|
|
r = r << 3 | r >> 2;
|
|
|
|
g = words[i] >> 5 & 0x1f;
|
|
|
|
g = g << 3 | g >> 2;
|
|
|
|
b = words[i] & 0x1f;
|
|
|
|
b = b << 3 | b >> 2;
|
|
|
|
dst_ptr[0] = r;
|
|
|
|
dst_ptr[1] = g;
|
|
|
|
dst_ptr[2] = b;
|
|
|
|
dst_ptr += 3;
|
|
|
|
}
|
|
|
|
}
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_SetClip(physDev);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteGSave(physDev);
|
|
|
|
PSDRV_WriteImageHeader(physDev, info, xDst, yDst, widthDst, heightDst,
|
1999-03-23 14:46:04 +01:00
|
|
|
widthSrc, heightSrc);
|
|
|
|
|
2003-12-08 22:40:27 +01:00
|
|
|
src_ptr = bits;
|
2009-11-18 17:39:27 +01:00
|
|
|
if(stride < 0) src_ptr += (fullSrcHeight + 1) * stride;
|
2009-11-18 13:20:17 +01:00
|
|
|
src_ptr += (ySrc * stride);
|
2003-12-08 22:40:27 +01:00
|
|
|
bitmap_size = heightSrc * widthSrc * 3;
|
|
|
|
dst_ptr = bitmap = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
|
2009-11-18 13:20:17 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, src_ptr += stride) {
|
2003-12-08 22:40:27 +01:00
|
|
|
const BYTE *byte = src_ptr + xSrc * 3;
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < widthSrc; i++) {
|
|
|
|
dst_ptr[0] = byte[i * 3 + 2];
|
|
|
|
dst_ptr[1] = byte[i * 3 + 1];
|
|
|
|
dst_ptr[2] = byte[i * 3];
|
|
|
|
dst_ptr += 3;
|
|
|
|
}
|
|
|
|
}
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 32:
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_SetClip(physDev);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteGSave(physDev);
|
|
|
|
PSDRV_WriteImageHeader(physDev, info, xDst, yDst, widthDst, heightDst,
|
1999-03-23 14:46:04 +01:00
|
|
|
widthSrc, heightSrc);
|
|
|
|
|
2003-12-08 22:40:27 +01:00
|
|
|
src_ptr = bits;
|
2009-11-18 17:39:27 +01:00
|
|
|
if(stride < 0) src_ptr += (fullSrcHeight + 1) * stride;
|
2009-11-18 13:20:17 +01:00
|
|
|
src_ptr += (ySrc * stride);
|
2003-12-08 22:40:27 +01:00
|
|
|
bitmap_size = heightSrc * widthSrc * 3;
|
|
|
|
dst_ptr = bitmap = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
|
2009-11-18 13:20:17 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, src_ptr += stride) {
|
2003-12-08 22:40:27 +01:00
|
|
|
const BYTE *byte = src_ptr + xSrc * 4;
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < widthSrc; i++) {
|
|
|
|
dst_ptr[0] = byte[i * 4 + 2];
|
|
|
|
dst_ptr[1] = byte[i * 4 + 1];
|
|
|
|
dst_ptr[2] = byte[i * 4];
|
|
|
|
dst_ptr += 3;
|
|
|
|
}
|
|
|
|
}
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("Unsupported depth\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
2003-12-08 22:40:27 +01:00
|
|
|
|
|
|
|
rle = HeapAlloc(GetProcessHeap(), 0, max_rle_size(bitmap_size));
|
|
|
|
rle_len = RLE_encode(bitmap, bitmap_size, rle);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bitmap);
|
|
|
|
ascii85 = HeapAlloc(GetProcessHeap(), 0, max_ascii85_size(rle_len));
|
|
|
|
ascii85_len = ASCII85_encode(rle, rle_len, ascii85);
|
|
|
|
HeapFree(GetProcessHeap(), 0, rle);
|
|
|
|
PSDRV_WriteData(physDev, ascii85, ascii85_len);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ascii85);
|
|
|
|
PSDRV_WriteSpool(physDev, "~>\n", 3);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteGRestore(physDev);
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_ResetClip(physDev);
|
2003-11-03 23:14:46 +01:00
|
|
|
return abs(heightSrc);
|
1998-10-24 12:44:05 +02:00
|
|
|
}
|