1998-11-06 12:03:00 +01:00
|
|
|
/*
|
|
|
|
* X11DRV device-independent bitmaps
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-11-06 12:03:00 +01:00
|
|
|
*/
|
|
|
|
|
1999-02-04 12:11:01 +01:00
|
|
|
#include "config.h"
|
2008-01-24 10:21:17 +01:00
|
|
|
#include "wine/port.h"
|
1999-02-04 12:11:01 +01:00
|
|
|
|
2003-11-21 22:50:59 +01:00
|
|
|
#include <X11/Xlib.h>
|
1999-10-25 00:13:47 +02:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
2002-09-24 05:17:31 +02:00
|
|
|
#include <X11/extensions/XShm.h>
|
1999-10-25 00:13:47 +02:00
|
|
|
# ifdef HAVE_SYS_SHM_H
|
|
|
|
# include <sys/shm.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_SYS_IPC_H
|
|
|
|
# include <sys/ipc.h>
|
|
|
|
# endif
|
|
|
|
#endif /* defined(HAVE_LIBXXSHM) */
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-03-19 15:29:50 +01:00
|
|
|
#include <stdlib.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2005-04-13 16:45:27 +02:00
|
|
|
#include "wingdi.h"
|
1999-02-04 12:11:01 +01:00
|
|
|
#include "x11drv.h"
|
2008-03-10 17:22:08 +01:00
|
|
|
#include "wine/exception.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2005-04-20 18:24:13 +02:00
|
|
|
static struct list dibs_list = LIST_INIT(dibs_list);
|
|
|
|
|
|
|
|
static CRITICAL_SECTION dibs_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG dibs_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &dibs_cs,
|
|
|
|
{ &dibs_cs_debug.ProcessLocksList, &dibs_cs_debug.ProcessLocksList },
|
2005-09-09 12:19:44 +02:00
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": dibs_cs") }
|
2005-04-20 18:24:13 +02:00
|
|
|
};
|
|
|
|
static CRITICAL_SECTION dibs_cs = { &dibs_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
static PVOID dibs_handler;
|
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
static int ximageDepthTable[32];
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-01-15 23:30:50 +01:00
|
|
|
/* This structure holds the arguments for DIB_SetImageBits() */
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-08-06 08:12:22 +02:00
|
|
|
X11DRV_PDEVICE *physDev;
|
|
|
|
LPCVOID bits;
|
|
|
|
XImage *image;
|
|
|
|
PALETTEENTRY *palentry;
|
|
|
|
int lines;
|
|
|
|
DWORD infoWidth;
|
|
|
|
WORD depth;
|
|
|
|
WORD infoBpp;
|
|
|
|
WORD compression;
|
2010-06-02 15:52:20 +02:00
|
|
|
ColorShifts *shifts;
|
2009-08-06 08:12:22 +02:00
|
|
|
RGBQUAD *colorMap;
|
|
|
|
int nColorMap;
|
|
|
|
Drawable drawable;
|
|
|
|
GC gc;
|
|
|
|
int xSrc;
|
|
|
|
int ySrc;
|
|
|
|
int xDest;
|
|
|
|
int yDest;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
DWORD rMask;
|
|
|
|
DWORD gMask;
|
|
|
|
DWORD bMask;
|
|
|
|
enum x11drv_shm_mode shm_mode;
|
|
|
|
int dibpitch;
|
|
|
|
DWORD sizeImage;
|
|
|
|
X_PHYSBITMAP *physBitmap;
|
2001-01-15 23:30:50 +01:00
|
|
|
} X11DRV_DIB_IMAGEBITS_DESCR;
|
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
|
2001-10-04 20:16:37 +02:00
|
|
|
enum Rle_EscapeCodes
|
|
|
|
{
|
|
|
|
RLE_EOL = 0, /* End of line */
|
|
|
|
RLE_END = 1, /* End of bitmap */
|
|
|
|
RLE_DELTA = 2 /* Delta */
|
|
|
|
};
|
|
|
|
|
2004-11-02 06:23:49 +01:00
|
|
|
|
2007-10-12 17:44:13 +02:00
|
|
|
static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *,INT);
|
2005-03-31 21:13:03 +02:00
|
|
|
|
2004-11-02 06:23:49 +01:00
|
|
|
/*
|
|
|
|
Some of the following helper functions are duplicated in
|
|
|
|
dlls/gdi/dib.c
|
|
|
|
*/
|
|
|
|
|
2008-02-21 17:44:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DIB_DoProtectDIBSection
|
|
|
|
*/
|
|
|
|
static void X11DRV_DIB_DoProtectDIBSection( X_PHYSBITMAP *physBitmap, DWORD new_prot )
|
|
|
|
{
|
|
|
|
DWORD old_prot;
|
|
|
|
|
|
|
|
VirtualProtect(physBitmap->base, physBitmap->size, new_prot, &old_prot);
|
|
|
|
TRACE("Changed protection from %d to %d\n", old_prot, new_prot);
|
|
|
|
}
|
|
|
|
|
1998-11-06 12:03:00 +01:00
|
|
|
/***********************************************************************
|
2001-05-11 02:17:47 +02:00
|
|
|
* X11DRV_DIB_GetXImageWidthBytes
|
|
|
|
*
|
|
|
|
* Return the width of an X image in bytes
|
1998-11-06 12:03:00 +01:00
|
|
|
*/
|
2007-03-17 11:47:28 +01:00
|
|
|
static inline int X11DRV_DIB_GetXImageWidthBytes( int width, int depth )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
if (!depth || depth > 32) goto error;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
if (!ximageDepthTable[depth-1])
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
XImage *testimage = XCreateImage( gdi_display, visual, depth,
|
|
|
|
ZPixmap, 0, NULL, 1, 1, 32, 20 );
|
|
|
|
if (testimage)
|
|
|
|
{
|
|
|
|
ximageDepthTable[depth-1] = testimage->bits_per_pixel;
|
|
|
|
XDestroyImage( testimage );
|
|
|
|
}
|
|
|
|
else ximageDepthTable[depth-1] = -1;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
2001-05-11 02:17:47 +02:00
|
|
|
if (ximageDepthTable[depth-1] != -1)
|
|
|
|
return (4 * ((width * ximageDepthTable[depth-1] + 31) / 32));
|
|
|
|
|
|
|
|
error:
|
|
|
|
WARN( "(%d): Unsupported depth\n", depth );
|
|
|
|
return 4 * width;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-14 00:31:46 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetDIBWidthBytes
|
|
|
|
*
|
|
|
|
* Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned.
|
|
|
|
*/
|
|
|
|
static int X11DRV_DIB_GetDIBWidthBytes( int width, int depth )
|
|
|
|
{
|
2011-08-29 12:03:21 +02:00
|
|
|
return ((width * depth + 31) / 8) & ~3;
|
2004-01-14 00:31:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2008-05-02 13:43:14 +02:00
|
|
|
* bitmap_info_size
|
2004-01-14 00:31:46 +01:00
|
|
|
*
|
|
|
|
* Return the size of the bitmap info structure including color table.
|
|
|
|
*/
|
2008-05-02 13:43:14 +02:00
|
|
|
int bitmap_info_size( const BITMAPINFO * info, WORD coloruse )
|
2004-01-14 00:31:46 +01:00
|
|
|
{
|
2010-05-14 17:17:46 +02:00
|
|
|
unsigned int colors, size, masks = 0;
|
2004-01-14 00:31:46 +01:00
|
|
|
|
|
|
|
if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
|
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
|
2004-01-14 00:31:46 +01:00
|
|
|
colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
|
|
|
|
return sizeof(BITMAPCOREHEADER) + colors *
|
|
|
|
((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
|
|
|
|
}
|
|
|
|
else /* assume BITMAPINFOHEADER */
|
|
|
|
{
|
|
|
|
colors = info->bmiHeader.biClrUsed;
|
|
|
|
if (!colors && (info->bmiHeader.biBitCount <= 8))
|
|
|
|
colors = 1 << info->bmiHeader.biBitCount;
|
2008-05-02 13:43:14 +02:00
|
|
|
if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
|
2010-05-14 17:17:46 +02:00
|
|
|
size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
|
|
|
|
return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
|
2004-01-14 00:31:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-06 12:03:00 +01:00
|
|
|
/***********************************************************************
|
2001-05-11 02:17:47 +02:00
|
|
|
* X11DRV_DIB_CreateXImage
|
1998-11-06 12:03:00 +01:00
|
|
|
*
|
2001-05-11 02:17:47 +02:00
|
|
|
* Create an X image.
|
1998-11-06 12:03:00 +01:00
|
|
|
*/
|
2001-05-11 02:17:47 +02:00
|
|
|
XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
int width_bytes;
|
2008-08-29 13:34:11 +02:00
|
|
|
XImage *image = NULL;
|
|
|
|
void *data;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
width_bytes = X11DRV_DIB_GetXImageWidthBytes( width, depth );
|
2008-08-29 13:34:11 +02:00
|
|
|
data = HeapAlloc( GetProcessHeap(), 0, height * width_bytes );
|
|
|
|
if (data) image = XCreateImage( gdi_display, visual, depth, ZPixmap, 0,
|
|
|
|
data, width, height, 32, width_bytes );
|
|
|
|
if (!image) HeapFree( GetProcessHeap(), 0, data );
|
2001-05-11 02:17:47 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
return image;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
|
2008-08-29 13:34:11 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_DestroyXImage
|
|
|
|
*
|
|
|
|
* Destroy an X image created with X11DRV_DIB_CreateXImage.
|
|
|
|
*/
|
|
|
|
void X11DRV_DIB_DestroyXImage( XImage *image )
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, image->data );
|
|
|
|
image->data = NULL;
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XDestroyImage( image );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-18 17:10:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetColorCount
|
|
|
|
*
|
|
|
|
* Computes the number of colors for the bitmap palette.
|
|
|
|
* Should not be called for a >8-bit deep bitmap.
|
|
|
|
*/
|
|
|
|
static unsigned int X11DRV_DIB_GetColorCount(const BITMAPINFO *info)
|
|
|
|
{
|
2011-08-04 13:22:53 +02:00
|
|
|
unsigned int colors = min( info->bmiHeader.biClrUsed, 256 );
|
|
|
|
if (!colors) colors = 1 << info->bmiHeader.biBitCount;
|
2007-10-18 17:10:06 +02:00
|
|
|
return colors;
|
|
|
|
}
|
|
|
|
|
2004-11-02 06:23:49 +01:00
|
|
|
|
2006-03-02 13:13:28 +01:00
|
|
|
static inline BOOL colour_is_brighter(RGBQUAD c1, RGBQUAD c2)
|
|
|
|
{
|
|
|
|
return (c1.rgbRed * c1.rgbRed + c1.rgbGreen * c1.rgbGreen + c1.rgbBlue * c1.rgbBlue) >
|
|
|
|
(c2.rgbRed * c2.rgbRed + c2.rgbGreen * c2.rgbGreen + c2.rgbBlue * c2.rgbBlue);
|
|
|
|
}
|
|
|
|
|
1998-11-06 12:03:00 +01:00
|
|
|
/***********************************************************************
|
2000-11-25 22:42:00 +01:00
|
|
|
* X11DRV_DIB_GenColorMap
|
1998-11-06 12:03:00 +01:00
|
|
|
*
|
2000-11-25 22:42:00 +01:00
|
|
|
* Fills the color map of a bitmap palette. Should not be called
|
1998-11-06 12:03:00 +01:00
|
|
|
* for a >8-bit deep bitmap.
|
|
|
|
*/
|
2005-07-24 19:10:38 +02:00
|
|
|
static int *X11DRV_DIB_GenColorMap( X11DRV_PDEVICE *physDev, int *colorMapping,
|
2011-08-04 13:22:53 +02:00
|
|
|
WORD coloruse, WORD depth, const void *colorPtr, int start, int end )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2000-11-25 22:42:00 +01:00
|
|
|
int i;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
|
|
|
if (coloruse == DIB_RGB_COLORS)
|
|
|
|
{
|
2011-08-04 13:22:53 +02:00
|
|
|
const RGBQUAD * rgb = colorPtr;
|
2006-11-08 19:57:37 +01:00
|
|
|
|
2011-08-04 13:22:53 +02:00
|
|
|
if (depth == 1) /* Monochrome */
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2011-08-04 13:22:53 +02:00
|
|
|
BOOL invert = FALSE;
|
|
|
|
RGBQUAD table[2];
|
2006-11-08 19:57:37 +01:00
|
|
|
|
2011-08-04 13:22:53 +02:00
|
|
|
if (GetDIBColorTable( physDev->dev.hdc, 0, 2, table ) == 2)
|
|
|
|
invert = !colour_is_brighter(table[1], table[0]);
|
2006-11-08 19:57:37 +01:00
|
|
|
|
2011-08-04 13:22:53 +02:00
|
|
|
for (i = start; i < end; i++, rgb++)
|
|
|
|
colorMapping[i] = ((rgb->rgbRed + rgb->rgbGreen +
|
|
|
|
rgb->rgbBlue > 255*3/2 && !invert) ||
|
|
|
|
(rgb->rgbRed + rgb->rgbGreen +
|
|
|
|
rgb->rgbBlue <= 255*3/2 && invert));
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
2011-08-04 13:22:53 +02:00
|
|
|
else
|
|
|
|
for (i = start; i < end; i++, rgb++)
|
|
|
|
colorMapping[i] = X11DRV_PALETTE_LookupPixel(physDev->color_shifts, RGB(rgb->rgbRed,
|
|
|
|
rgb->rgbGreen,
|
|
|
|
rgb->rgbBlue));
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
else /* DIB_PAL_COLORS */
|
|
|
|
{
|
2009-01-19 10:23:40 +01:00
|
|
|
const WORD * index = colorPtr;
|
2000-12-22 02:07:57 +01:00
|
|
|
|
2007-10-18 17:10:06 +02:00
|
|
|
for (i = start; i < end; i++, index++)
|
|
|
|
colorMapping[i] = X11DRV_PALETTE_ToPhysical( physDev, PALETTEINDEX(*index) );
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return colorMapping;
|
|
|
|
}
|
|
|
|
|
2000-11-25 22:42:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_BuildColorMap
|
|
|
|
*
|
|
|
|
* Build the color map from the bitmap palette. Should not be called
|
|
|
|
* for a >8-bit deep bitmap.
|
|
|
|
*/
|
2006-03-02 13:13:28 +01:00
|
|
|
static int *X11DRV_DIB_BuildColorMap( X11DRV_PDEVICE *physDev, WORD coloruse, WORD depth,
|
|
|
|
const BITMAPINFO *info, int *nColors )
|
2000-11-25 22:42:00 +01:00
|
|
|
{
|
2000-12-22 02:07:57 +01:00
|
|
|
const void *colorPtr;
|
2000-11-25 22:42:00 +01:00
|
|
|
int *colorMapping;
|
|
|
|
|
2004-11-02 06:23:49 +01:00
|
|
|
|
2007-10-18 17:10:06 +02:00
|
|
|
*nColors = X11DRV_DIB_GetColorCount(info);
|
|
|
|
if (!*nColors) return NULL;
|
2000-11-25 22:42:00 +01:00
|
|
|
|
2007-10-18 17:10:06 +02:00
|
|
|
colorPtr = (const BYTE*)info + (WORD)info->bmiHeader.biSize;
|
|
|
|
if (!(colorMapping = HeapAlloc(GetProcessHeap(), 0, *nColors * sizeof(int) )))
|
2005-03-24 22:01:35 +01:00
|
|
|
return NULL;
|
2000-11-25 22:42:00 +01:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
return X11DRV_DIB_GenColorMap( physDev, colorMapping, coloruse, depth,
|
2011-08-04 13:22:53 +02:00
|
|
|
colorPtr, 0, *nColors);
|
2000-11-25 22:42:00 +01:00
|
|
|
}
|
|
|
|
|
1998-11-06 12:03:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_MapColor
|
|
|
|
*/
|
2005-07-24 19:10:38 +02:00
|
|
|
static int X11DRV_DIB_MapColor( int *physMap, int nPhysMap, int phys, int oldcol )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2008-12-04 23:26:05 +01:00
|
|
|
int color;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2000-05-18 02:03:09 +02:00
|
|
|
if ((oldcol < nPhysMap) && (physMap[oldcol] == phys))
|
|
|
|
return oldcol;
|
|
|
|
|
1998-11-06 12:03:00 +01:00
|
|
|
for (color = 0; color < nPhysMap; color++)
|
|
|
|
if (physMap[color] == phys)
|
|
|
|
return color;
|
|
|
|
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("Strange color %08x\n", phys);
|
1998-11-06 12:03:00 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-14 13:51:01 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* X11DRV_DIB_GetNearestIndex
|
|
|
|
*
|
|
|
|
* Helper for X11DRV_DIB_GetDIBits.
|
|
|
|
* Returns the nearest colour table index for a given RGB.
|
|
|
|
* Nearest is defined by minimizing the sum of the squares.
|
|
|
|
*/
|
|
|
|
static INT X11DRV_DIB_GetNearestIndex(RGBQUAD *colormap, int numColors, BYTE r, BYTE g, BYTE b)
|
|
|
|
{
|
|
|
|
INT i, best = -1, diff, bestdiff = -1;
|
|
|
|
RGBQUAD *color;
|
|
|
|
|
|
|
|
for(color = colormap, i = 0; i < numColors; color++, i++) {
|
|
|
|
diff = (r - color->rgbRed) * (r - color->rgbRed) +
|
|
|
|
(g - color->rgbGreen) * (g - color->rgbGreen) +
|
|
|
|
(b - color->rgbBlue) * (b - color->rgbBlue);
|
|
|
|
if(diff == 0)
|
|
|
|
return i;
|
|
|
|
if(best == -1 || diff < bestdiff) {
|
|
|
|
best = i;
|
|
|
|
bestdiff = diff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return best;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* X11DRV_DIB_MaskToShift
|
|
|
|
*
|
|
|
|
* Helper for X11DRV_DIB_GetDIBits.
|
2002-06-01 01:06:46 +02:00
|
|
|
* Returns the by how many bits to shift a given color so that it is
|
2001-10-17 21:41:54 +02:00
|
|
|
* in the proper position.
|
|
|
|
*/
|
2003-11-25 04:27:37 +01:00
|
|
|
INT X11DRV_DIB_MaskToShift(DWORD mask)
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
int shift;
|
|
|
|
|
|
|
|
if (mask==0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
shift=0;
|
|
|
|
while ((mask&1)==0) {
|
|
|
|
mask>>=1;
|
|
|
|
shift++;
|
|
|
|
}
|
|
|
|
return shift;
|
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2005-11-30 18:26:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_CheckMask
|
|
|
|
*
|
|
|
|
* Check RGB mask if it is either 0 or matches visual's mask.
|
|
|
|
*/
|
|
|
|
static inline int X11DRV_DIB_CheckMask(int red_mask, int green_mask, int blue_mask)
|
|
|
|
{
|
|
|
|
return ( red_mask == 0 && green_mask == 0 && blue_mask == 0 ) ||
|
|
|
|
( red_mask == visual->red_mask && green_mask == visual->green_mask &&
|
|
|
|
blue_mask == visual->blue_mask );
|
|
|
|
}
|
|
|
|
|
1998-11-06 12:03:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_SetImageBits_1
|
|
|
|
*
|
|
|
|
* SetDIBits for a 1-bit deep DIB.
|
|
|
|
*/
|
|
|
|
static void X11DRV_DIB_SetImageBits_1( int lines, const BYTE *srcbits,
|
|
|
|
DWORD srcwidth, DWORD dstwidth, int left,
|
2009-08-29 21:43:51 +02:00
|
|
|
int *colors, XImage *bmpImage, int linebytes)
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width;
|
2001-10-17 21:41:54 +02:00
|
|
|
const BYTE* srcbyte;
|
|
|
|
BYTE srcval, extra;
|
|
|
|
DWORD i, x;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
if (lines < 0 ) {
|
|
|
|
lines = -lines;
|
|
|
|
srcbits = srcbits + linebytes * (lines - 1);
|
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((extra = (left & 7)) != 0) {
|
|
|
|
left &= ~7;
|
|
|
|
dstwidth += extra;
|
|
|
|
}
|
|
|
|
srcbits += left >> 3;
|
2004-08-12 22:02:39 +02:00
|
|
|
width = min(srcwidth, dstwidth);
|
2001-10-17 21:41:54 +02:00
|
|
|
|
|
|
|
/* ==== pal 1 dib -> any bmp format ==== */
|
|
|
|
for (h = lines-1; h >=0; h--) {
|
|
|
|
srcbyte=srcbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (i = width/8, x = left; i > 0; i--) {
|
2001-10-17 21:41:54 +02:00
|
|
|
srcval=*srcbyte++;
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[ srcval >> 7] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[(srcval >> 6) & 1] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[(srcval >> 5) & 1] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[(srcval >> 4) & 1] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[(srcval >> 3) & 1] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[(srcval >> 2) & 1] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[(srcval >> 1) & 1] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[ srcval & 1] );
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if (width % 8){
|
2003-03-31 03:32:47 +02:00
|
|
|
srcval=*srcbyte;
|
2004-08-12 22:02:39 +02:00
|
|
|
switch (width & 7)
|
2003-03-31 03:32:47 +02:00
|
|
|
{
|
|
|
|
case 7: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
|
2011-10-17 21:29:58 +02:00
|
|
|
/* fall through */
|
2003-03-31 03:32:47 +02:00
|
|
|
case 6: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
|
2011-10-17 21:29:58 +02:00
|
|
|
/* fall through */
|
2003-03-31 03:32:47 +02:00
|
|
|
case 5: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
|
2011-10-17 21:29:58 +02:00
|
|
|
/* fall through */
|
2003-03-31 03:32:47 +02:00
|
|
|
case 4: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
|
2011-10-17 21:29:58 +02:00
|
|
|
/* fall through */
|
2003-03-31 03:32:47 +02:00
|
|
|
case 3: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
|
2011-10-17 21:29:58 +02:00
|
|
|
/* fall through */
|
2003-03-31 03:32:47 +02:00
|
|
|
case 2: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]); srcval<<=1;
|
2011-10-17 21:29:58 +02:00
|
|
|
/* fall through */
|
2003-03-31 03:32:47 +02:00
|
|
|
case 1: XPutPixel(bmpImage, x++, h, colors[srcval >> 7]);
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
srcbits += linebytes;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetImageBits_1
|
|
|
|
*
|
|
|
|
* GetDIBits for a 1-bit deep DIB.
|
|
|
|
*/
|
|
|
|
static void X11DRV_DIB_GetImageBits_1( int lines, BYTE *dstbits,
|
1999-09-14 13:51:01 +02:00
|
|
|
DWORD dstwidth, DWORD srcwidth,
|
2002-06-01 01:06:46 +02:00
|
|
|
RGBQUAD *colors, PALETTEENTRY *srccolors,
|
2009-08-29 21:43:51 +02:00
|
|
|
XImage *bmpImage, int linebytes )
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
1999-09-19 14:04:17 +02:00
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(dstwidth, srcwidth);
|
1999-09-03 18:49:17 +02:00
|
|
|
|
1999-09-19 14:04:17 +02:00
|
|
|
if (lines < 0 ) {
|
|
|
|
lines = -lines;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits = dstbits + linebytes * (lines - 1);
|
|
|
|
linebytes = -linebytes;
|
1999-09-19 14:04:17 +02:00
|
|
|
}
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth)
|
|
|
|
{
|
1999-09-14 13:51:01 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 1 or 4 bmp -> pal 1 dib ==== */
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
for (h=lines-1; h>=0; h--) {
|
|
|
|
BYTE dstval;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
|
|
|
srcval=srccolors[XGetPixel(bmpImage, x, h)];
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
srcval.peRed,
|
|
|
|
srcval.peGreen,
|
|
|
|
srcval.peBlue) << (7 - (x & 7)));
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2009-02-28 14:07:52 +01:00
|
|
|
*dstbyte++=dstval;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2009-02-28 14:07:52 +01:00
|
|
|
/* pad with 0 to DWORD alignment */
|
|
|
|
for (x = (x+7)&~7; x < ((width + 31) & ~31); x+=8)
|
|
|
|
*dstbyte++ = 0;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-09-14 13:51:01 +02:00
|
|
|
case 8:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask, bmpImage->green_mask, bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 bmp -> pal 1 dib ==== */
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE* srcpixel;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
2007-10-23 15:32:38 +02:00
|
|
|
srcval=srccolors[*srcpixel++];
|
2001-10-17 21:41:54 +02:00
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
srcval.peRed,
|
|
|
|
srcval.peGreen,
|
|
|
|
srcval.peBlue) << (7-(x&7)) );
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
|
|
|
case 15:
|
2001-12-21 20:18:30 +01:00
|
|
|
case 16:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
const void* srcbits;
|
|
|
|
const WORD* srcpixel;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (bmpImage->red_mask==0x7c00) {
|
|
|
|
/* ==== rgb 555 bmp -> pal 1 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
((srcval >> 7) & 0xf8) | /* r */
|
|
|
|
((srcval >> 12) & 0x07),
|
|
|
|
((srcval >> 2) & 0xf8) | /* g */
|
|
|
|
((srcval >> 7) & 0x07),
|
|
|
|
((srcval << 3) & 0xf8) | /* b */
|
|
|
|
((srcval >> 2) & 0x07) ) << (7-(x&7)) );
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0x7c00) {
|
|
|
|
/* ==== bgr 555 bmp -> pal 1 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
2011-10-24 07:51:30 +02:00
|
|
|
BYTE dstval;
|
2001-12-21 20:18:30 +01:00
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2011-10-24 07:51:30 +02:00
|
|
|
WORD srcval;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
((srcval << 3) & 0xf8) | /* r */
|
|
|
|
((srcval >> 2) & 0x07),
|
|
|
|
((srcval >> 2) & 0xf8) | /* g */
|
|
|
|
((srcval >> 7) & 0x07),
|
|
|
|
((srcval >> 7) & 0xf8) | /* b */
|
|
|
|
((srcval >> 12) & 0x07) ) << (7-(x&7)) );
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (bmpImage->red_mask==0xf800) {
|
|
|
|
/* ==== rgb 565 bmp -> pal 1 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
((srcval >> 8) & 0xf8) | /* r */
|
|
|
|
((srcval >> 13) & 0x07),
|
|
|
|
((srcval >> 3) & 0xfc) | /* g */
|
|
|
|
((srcval >> 9) & 0x03),
|
|
|
|
((srcval << 3) & 0xf8) | /* b */
|
|
|
|
((srcval >> 2) & 0x07) ) << (7-(x&7)) );
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0xf800) {
|
|
|
|
/* ==== bgr 565 bmp -> pal 1 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
((srcval << 3) & 0xf8) | /* r */
|
|
|
|
((srcval >> 2) & 0x07),
|
|
|
|
((srcval >> 3) & 0xfc) | /* g */
|
|
|
|
((srcval >> 9) & 0x03),
|
|
|
|
((srcval >> 8) & 0xf8) | /* b */
|
|
|
|
((srcval >> 13) & 0x07) ) << (7-(x&7)) );
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
1999-09-14 13:51:01 +02:00
|
|
|
case 32:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE *srcbyte;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
int bytes_per_pixel;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
bytes_per_pixel=(bmpImage->bits_per_pixel==24?3:4);
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (bmpImage->blue_mask==0xff) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 or 0888 bmp -> pal 1 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
srcbyte[2],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[0]) << (7-(x&7)) );
|
|
|
|
srcbyte+=bytes_per_pixel;
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* ==== bgr 888 or 0888 bmp -> pal 1 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 2,
|
|
|
|
srcbyte[0],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[2]) << (7-(x&7)) );
|
|
|
|
srcbyte+=bytes_per_pixel;
|
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
default:
|
1999-09-14 13:51:01 +02:00
|
|
|
notsupported:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
BYTE* dstbyte;
|
2005-12-01 13:12:36 +01:00
|
|
|
BYTE neg = 0;
|
2001-10-17 21:41:54 +02:00
|
|
|
unsigned long white = (1 << bmpImage->bits_per_pixel) - 1;
|
|
|
|
|
|
|
|
/* ==== any bmp format -> pal 1 dib ==== */
|
2005-12-01 13:12:36 +01:00
|
|
|
if ((unsigned)colors[0].rgbRed+colors[0].rgbGreen+colors[0].rgbBlue >=
|
|
|
|
(unsigned)colors[1].rgbRed+colors[1].rgbGreen+colors[1].rgbBlue )
|
|
|
|
neg = 1;
|
|
|
|
|
|
|
|
WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 1 bit DIB, "
|
|
|
|
"%s color mapping\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
bmpImage->bits_per_pixel, bmpImage->red_mask,
|
2005-12-01 13:12:36 +01:00
|
|
|
bmpImage->green_mask, bmpImage->blue_mask,
|
|
|
|
neg?"negative":"direct" );
|
2001-10-17 21:41:54 +02:00
|
|
|
|
|
|
|
for (h=lines-1; h>=0; h--) {
|
|
|
|
BYTE dstval;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2005-12-01 13:12:36 +01:00
|
|
|
dstval|=((XGetPixel( bmpImage, x, h) >= white) ^ neg) << (7 - (x&7));
|
2001-10-17 21:41:54 +02:00
|
|
|
if ((x&7)==7) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&7)!=0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-19 16:15:41 +02:00
|
|
|
}
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_SetImageBits_4
|
|
|
|
*
|
|
|
|
* SetDIBits for a 4-bit deep DIB.
|
|
|
|
*/
|
|
|
|
static void X11DRV_DIB_SetImageBits_4( int lines, const BYTE *srcbits,
|
|
|
|
DWORD srcwidth, DWORD dstwidth, int left,
|
2009-08-29 21:43:51 +02:00
|
|
|
int *colors, XImage *bmpImage, int linebytes)
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width;
|
2001-10-17 21:41:54 +02:00
|
|
|
const BYTE* srcbyte;
|
|
|
|
DWORD i, x;
|
|
|
|
|
|
|
|
if (lines < 0 ) {
|
|
|
|
lines = -lines;
|
|
|
|
srcbits = srcbits + linebytes * (lines - 1);
|
|
|
|
linebytes = -linebytes;
|
1999-02-09 15:11:59 +01:00
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
if (left & 1) {
|
|
|
|
left--;
|
|
|
|
dstwidth++;
|
|
|
|
}
|
|
|
|
srcbits += left >> 1;
|
2004-08-12 22:02:39 +02:00
|
|
|
width = min(srcwidth, dstwidth);
|
2001-10-17 21:41:54 +02:00
|
|
|
|
|
|
|
/* ==== pal 4 dib -> any bmp format ==== */
|
|
|
|
for (h = lines-1; h >= 0; h--) {
|
|
|
|
srcbyte=srcbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (i = width/2, x = left; i > 0; i--) {
|
2001-10-17 21:41:54 +02:00
|
|
|
BYTE srcval=*srcbyte++;
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[srcval >> 4] );
|
|
|
|
XPutPixel( bmpImage, x++, h, colors[srcval & 0x0f] );
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if (width & 1)
|
2001-10-17 21:41:54 +02:00
|
|
|
XPutPixel( bmpImage, x, h, colors[*srcbyte >> 4] );
|
|
|
|
srcbits += linebytes;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetImageBits_4
|
|
|
|
*
|
|
|
|
* GetDIBits for a 4-bit deep DIB.
|
|
|
|
*/
|
1999-09-14 13:51:01 +02:00
|
|
|
static void X11DRV_DIB_GetImageBits_4( int lines, BYTE *dstbits,
|
|
|
|
DWORD srcwidth, DWORD dstwidth,
|
2002-06-01 01:06:46 +02:00
|
|
|
RGBQUAD *colors, PALETTEENTRY *srccolors,
|
2009-08-29 21:43:51 +02:00
|
|
|
XImage *bmpImage, int linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
1999-09-14 13:51:01 +02:00
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
1998-11-06 12:03:00 +01:00
|
|
|
|
1999-09-14 13:51:01 +02:00
|
|
|
if (lines < 0 )
|
|
|
|
{
|
|
|
|
lines = -lines;
|
|
|
|
dstbits = dstbits + ( linebytes * (lines-1) );
|
|
|
|
linebytes = -linebytes;
|
1999-02-09 15:11:59 +01:00
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth) {
|
|
|
|
case 1:
|
|
|
|
case 4:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 1 or 4 bmp -> pal 4 dib ==== */
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
for (h = lines-1; h >= 0; h--) {
|
|
|
|
BYTE dstval;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
|
|
|
srcval=srccolors[XGetPixel(bmpImage, x, h)];
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcval.peRed,
|
|
|
|
srcval.peGreen,
|
|
|
|
srcval.peBlue) << (4-((x&1)<<2)));
|
|
|
|
if ((x&1)==1) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&1)!=0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-09-14 13:51:01 +02:00
|
|
|
case 8:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 bmp -> pal 4 dib ==== */
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE *srcpixel;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
2007-10-23 15:32:38 +02:00
|
|
|
srcval = srccolors[*srcpixel++];
|
2001-10-17 21:41:54 +02:00
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcval.peRed,
|
|
|
|
srcval.peGreen,
|
|
|
|
srcval.peBlue) << (4*(1-(x&1))) );
|
|
|
|
if ((x&1)==1) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&1)!=0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
|
|
|
case 15:
|
2001-12-21 20:18:30 +01:00
|
|
|
case 16:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
const void* srcbits;
|
|
|
|
const WORD* srcpixel;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (bmpImage->red_mask==0x7c00) {
|
|
|
|
/* ==== rgb 555 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
((srcval >> 7) & 0xf8) | /* r */
|
|
|
|
((srcval >> 12) & 0x07),
|
|
|
|
((srcval >> 2) & 0xf8) | /* g */
|
|
|
|
((srcval >> 7) & 0x07),
|
|
|
|
((srcval << 3) & 0xf8) | /* b */
|
|
|
|
((srcval >> 2) & 0x07) ) << ((1-(x&1))<<2) );
|
|
|
|
if ((x&1)==1) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&1)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0x7c00) {
|
|
|
|
/* ==== bgr 555 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
WORD dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
((srcval << 3) & 0xf8) | /* r */
|
|
|
|
((srcval >> 2) & 0x07),
|
|
|
|
((srcval >> 2) & 0xf8) | /* g */
|
|
|
|
((srcval >> 7) & 0x07),
|
|
|
|
((srcval >> 7) & 0xf8) | /* b */
|
|
|
|
((srcval >> 12) & 0x07) ) << ((1-(x&1))<<2) );
|
|
|
|
if ((x&1)==1) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&1)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (bmpImage->red_mask==0xf800) {
|
|
|
|
/* ==== rgb 565 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
BYTE dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
((srcval >> 8) & 0xf8) | /* r */
|
|
|
|
((srcval >> 13) & 0x07),
|
|
|
|
((srcval >> 3) & 0xfc) | /* g */
|
|
|
|
((srcval >> 9) & 0x03),
|
|
|
|
((srcval << 3) & 0xf8) | /* b */
|
|
|
|
((srcval >> 2) & 0x07) ) << ((1-(x&1))<<2) );
|
|
|
|
if ((x&1)==1) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&1)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0xf800) {
|
|
|
|
/* ==== bgr 565 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
WORD dstval;
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
|
|
|
dstval=0;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
dstval|=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
((srcval << 3) & 0xf8) | /* r */
|
|
|
|
((srcval >> 2) & 0x07),
|
|
|
|
((srcval >> 3) & 0xfc) | /* g */
|
|
|
|
((srcval >> 9) & 0x03),
|
|
|
|
((srcval >> 8) & 0xf8) | /* b */
|
|
|
|
((srcval >> 13) & 0x07) ) << ((1-(x&1))<<2) );
|
|
|
|
if ((x&1)==1) {
|
|
|
|
*dstbyte++=dstval;
|
|
|
|
dstval=0;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if ((width&1)!=0) {
|
2001-12-21 20:18:30 +01:00
|
|
|
*dstbyte=dstval;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
|
|
|
if (bmpImage->bits_per_pixel==24) {
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE *srcbyte;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (bmpImage->blue_mask==0xff) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width/2; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* Do 2 pixels at a time */
|
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[2],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[0]) << 4) |
|
|
|
|
X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[5],
|
|
|
|
srcbyte[4],
|
|
|
|
srcbyte[3]);
|
|
|
|
srcbyte+=6;
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if (width&1) {
|
2007-10-23 15:30:30 +02:00
|
|
|
/* And then the odd pixel */
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[2],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[0]) << 4);
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* ==== bgr 888 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width/2; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* Do 2 pixels at a time */
|
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[0],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[2]) << 4) |
|
|
|
|
X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[3],
|
|
|
|
srcbyte[4],
|
|
|
|
srcbyte[5]);
|
|
|
|
srcbyte+=6;
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if (width&1) {
|
2007-10-23 15:30:30 +02:00
|
|
|
/* And then the odd pixel */
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[0],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[2]) << 4);
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
/* Fall through */
|
|
|
|
|
1999-09-14 13:51:01 +02:00
|
|
|
case 32:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE *srcbyte;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (bmpImage->blue_mask==0xff) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 0888 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width/2; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* Do 2 pixels at a time */
|
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[2],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[0]) << 4) |
|
|
|
|
X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[6],
|
|
|
|
srcbyte[5],
|
|
|
|
srcbyte[4]);
|
|
|
|
srcbyte+=8;
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if (width&1) {
|
2007-10-23 15:30:30 +02:00
|
|
|
/* And then the odd pixel */
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[2],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[0]) << 4);
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* ==== bgr 0888 bmp -> pal 4 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width/2; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* Do 2 pixels at a time */
|
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[0],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[2]) << 4) |
|
|
|
|
X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[4],
|
|
|
|
srcbyte[5],
|
|
|
|
srcbyte[6]);
|
|
|
|
srcbyte+=8;
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if (width&1) {
|
2007-10-23 15:30:30 +02:00
|
|
|
/* And then the odd pixel */
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=(X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 16,
|
|
|
|
srcbyte[0],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[2]) << 4);
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
default:
|
1999-09-14 13:51:01 +02:00
|
|
|
notsupported:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
/* ==== any bmp format -> pal 4 dib ==== */
|
2001-12-21 20:18:30 +01:00
|
|
|
WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 4 bit DIB\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
bmpImage->bits_per_pixel, bmpImage->red_mask,
|
|
|
|
bmpImage->green_mask, bmpImage->blue_mask );
|
|
|
|
for (h=lines-1; h>=0; h--) {
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<(width & ~1); x+=2) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=(X11DRV_DIB_MapColor((int*)colors, 16, XGetPixel(bmpImage, x, h), 0) << 4) |
|
|
|
|
X11DRV_DIB_MapColor((int*)colors, 16, XGetPixel(bmpImage, x+1, h), 0);
|
|
|
|
}
|
2004-08-12 22:02:39 +02:00
|
|
|
if (width & 1) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=(X11DRV_DIB_MapColor((int *)colors, 16, XGetPixel(bmpImage, x, h), 0) << 4);
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_SetImageBits_8
|
|
|
|
*
|
|
|
|
* SetDIBits for an 8-bit deep DIB.
|
|
|
|
*/
|
|
|
|
static void X11DRV_DIB_SetImageBits_8( int lines, const BYTE *srcbits,
|
|
|
|
DWORD srcwidth, DWORD dstwidth, int left,
|
2000-12-06 21:15:43 +01:00
|
|
|
const int *colors, XImage *bmpImage,
|
2009-08-29 21:43:51 +02:00
|
|
|
int linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2001-10-17 21:41:54 +02:00
|
|
|
const BYTE* srcbyte;
|
|
|
|
BYTE* dstbits;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
|
|
|
{
|
|
|
|
lines = -lines;
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits = srcbits + linebytes * (lines-1);
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits += left;
|
|
|
|
srcbyte = srcbits;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2000-05-07 22:24:08 +02:00
|
|
|
switch (bmpImage->depth) {
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
/* Some X servers might have 32 bit/ 16bit deep pixel */
|
2004-08-12 22:02:39 +02:00
|
|
|
if (lines && width && (bmpImage->bits_per_pixel == 16) &&
|
2002-08-14 23:07:40 +02:00
|
|
|
(ImageByteOrder(gdi_display)==LSBFirst) )
|
2000-05-07 22:24:08 +02:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 dib -> rgb or bgr 555 or 565 bmp ==== */
|
2007-11-09 12:45:58 +01:00
|
|
|
dstbits=(BYTE*)bmpImage->data+left*2+(lines-1)*bmpImage->bytes_per_line;
|
2000-05-07 22:24:08 +02:00
|
|
|
for (h = lines ; h--; ) {
|
2007-11-09 12:45:58 +01:00
|
|
|
DWORD* dstpixel=(DWORD*)dstbits;
|
|
|
|
for (x=0; x<width/2; x++) {
|
|
|
|
/* Do 2 pixels at a time */
|
|
|
|
*dstpixel++=(colors[srcbyte[1]] << 16) | colors[srcbyte[0]];
|
|
|
|
srcbyte+=2;
|
|
|
|
}
|
|
|
|
if (width&1) {
|
|
|
|
/* And then the odd pixel */
|
|
|
|
*((WORD*)dstpixel)=colors[srcbyte[0]];
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbyte = (srcbits += linebytes);
|
|
|
|
dstbits -= bmpImage->bytes_per_line;
|
2000-05-07 22:24:08 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2001-03-05 20:59:29 +01:00
|
|
|
case 24:
|
2001-10-17 21:41:54 +02:00
|
|
|
case 32:
|
2004-08-12 22:02:39 +02:00
|
|
|
if (lines && width && (bmpImage->bits_per_pixel == 32) &&
|
2002-08-14 23:07:40 +02:00
|
|
|
(ImageByteOrder(gdi_display)==LSBFirst) )
|
2001-03-05 20:59:29 +01:00
|
|
|
{
|
2005-08-15 12:47:23 +02:00
|
|
|
dstbits=(BYTE*)bmpImage->data+left*4+(lines-1)*bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 dib -> rgb or bgr 0888 bmp ==== */
|
2001-03-05 20:59:29 +01:00
|
|
|
for (h = lines ; h--; ) {
|
2007-11-09 12:45:58 +01:00
|
|
|
DWORD* dstpixel=(DWORD*)dstbits;
|
|
|
|
for (x=0; x<width; x++) {
|
|
|
|
*dstpixel++=colors[*srcbyte++];
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbyte = (srcbits += linebytes);
|
|
|
|
dstbits -= bmpImage->bytes_per_line;
|
2001-03-05 20:59:29 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2000-05-07 22:24:08 +02:00
|
|
|
default:
|
2001-10-17 21:41:54 +02:00
|
|
|
break; /* use slow generic case below */
|
2000-05-07 22:24:08 +02:00
|
|
|
}
|
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 dib -> any bmp format ==== */
|
|
|
|
for (h=lines-1; h>=0; h--) {
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=left; x<width+left; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
XPutPixel(bmpImage, x, h, colors[*srcbyte++]);
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbyte = (srcbits += linebytes);
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetImageBits_8
|
|
|
|
*
|
|
|
|
* GetDIBits for an 8-bit deep DIB.
|
|
|
|
*/
|
1999-09-14 13:51:01 +02:00
|
|
|
static void X11DRV_DIB_GetImageBits_8( int lines, BYTE *dstbits,
|
|
|
|
DWORD srcwidth, DWORD dstwidth,
|
2002-06-01 01:06:46 +02:00
|
|
|
RGBQUAD *colors, PALETTEENTRY *srccolors,
|
2009-08-29 21:43:51 +02:00
|
|
|
XImage *bmpImage, int linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2001-10-17 21:41:54 +02:00
|
|
|
BYTE* dstbyte;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
|
|
|
{
|
1998-11-06 12:03:00 +01:00
|
|
|
lines = -lines;
|
1999-09-14 13:51:01 +02:00
|
|
|
dstbits = dstbits + ( linebytes * (lines-1) );
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
|
|
|
* Hack for now
|
|
|
|
* This condition is true when GetImageBits has been called by
|
|
|
|
* UpdateDIBSection. For now, GetNearestIndex is too slow to support
|
2006-05-12 00:06:31 +02:00
|
|
|
* 256 colormaps, so we'll just use it for GetDIBits calls.
|
|
|
|
* (In some cases, in an updateDIBSection, the returned colors are bad too)
|
2001-10-17 21:41:54 +02:00
|
|
|
*/
|
1999-09-19 16:15:41 +02:00
|
|
|
if (!srccolors) goto updatesection;
|
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth) {
|
1999-09-14 13:51:01 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
|
|
|
|
/* ==== pal 1 bmp -> pal 8 dib ==== */
|
|
|
|
/* ==== pal 4 bmp -> pal 8 dib ==== */
|
|
|
|
for (h=lines-1; h>=0; h--) {
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
|
|
|
srcval=srccolors[XGetPixel(bmpImage, x, h)];
|
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex(colors, 256,
|
|
|
|
srcval.peRed,
|
|
|
|
srcval.peGreen,
|
|
|
|
srcval.peBlue);
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 bmp -> pal 8 dib ==== */
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE* srcpixel;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
2007-10-23 15:32:38 +02:00
|
|
|
srcval=srccolors[*srcpixel++];
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex(colors, 256,
|
|
|
|
srcval.peRed,
|
|
|
|
srcval.peGreen,
|
|
|
|
srcval.peBlue);
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
1999-09-14 13:51:01 +02:00
|
|
|
break;
|
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 15:
|
2001-12-21 20:18:30 +01:00
|
|
|
case 16:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
const void* srcbits;
|
|
|
|
const WORD* srcpixel;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (bmpImage->red_mask==0x7c00) {
|
|
|
|
/* ==== rgb 555 bmp -> pal 8 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 256,
|
|
|
|
((srcval >> 7) & 0xf8) | /* r */
|
|
|
|
((srcval >> 12) & 0x07),
|
|
|
|
((srcval >> 2) & 0xf8) | /* g */
|
|
|
|
((srcval >> 7) & 0x07),
|
|
|
|
((srcval << 3) & 0xf8) | /* b */
|
|
|
|
((srcval >> 2) & 0x07) );
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0x7c00) {
|
|
|
|
/* ==== bgr 555 bmp -> pal 8 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 256,
|
|
|
|
((srcval << 3) & 0xf8) | /* r */
|
|
|
|
((srcval >> 2) & 0x07),
|
|
|
|
((srcval >> 2) & 0xf8) | /* g */
|
|
|
|
((srcval >> 7) & 0x07),
|
|
|
|
((srcval >> 7) & 0xf8) | /* b */
|
|
|
|
((srcval >> 12) & 0x07) );
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (bmpImage->red_mask==0xf800) {
|
|
|
|
/* ==== rgb 565 bmp -> pal 8 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 256,
|
|
|
|
((srcval >> 8) & 0xf8) | /* r */
|
|
|
|
((srcval >> 13) & 0x07),
|
|
|
|
((srcval >> 3) & 0xfc) | /* g */
|
|
|
|
((srcval >> 9) & 0x03),
|
|
|
|
((srcval << 3) & 0xf8) | /* b */
|
|
|
|
((srcval >> 2) & 0x07) );
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0xf800) {
|
|
|
|
/* ==== bgr 565 bmp -> pal 8 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-12-21 20:18:30 +01:00
|
|
|
WORD srcval;
|
|
|
|
srcval=*srcpixel++;
|
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 256,
|
|
|
|
((srcval << 3) & 0xf8) | /* r */
|
|
|
|
((srcval >> 2) & 0x07),
|
|
|
|
((srcval >> 3) & 0xfc) | /* g */
|
|
|
|
((srcval >> 9) & 0x03),
|
|
|
|
((srcval >> 8) & 0xf8) | /* b */
|
|
|
|
((srcval >> 13) & 0x07) );
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits += linebytes;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE *srcbyte;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
int bytes_per_pixel;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
bytes_per_pixel=(bmpImage->bits_per_pixel==24?3:4);
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (bmpImage->blue_mask==0xff) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 or 0888 bmp -> pal 8 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 256,
|
|
|
|
srcbyte[2],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[0]);
|
|
|
|
srcbyte+=bytes_per_pixel;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* ==== bgr 888 or 0888 bmp -> pal 8 dib ==== */
|
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcbyte=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte++=X11DRV_DIB_GetNearestIndex
|
|
|
|
(colors, 256,
|
|
|
|
srcbyte[0],
|
|
|
|
srcbyte[1],
|
|
|
|
srcbyte[2]);
|
|
|
|
srcbyte+=bytes_per_pixel;
|
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-09-14 13:51:01 +02:00
|
|
|
notsupported:
|
2001-12-21 20:18:30 +01:00
|
|
|
WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 8 bit DIB\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
bmpImage->depth, bmpImage->red_mask,
|
|
|
|
bmpImage->green_mask, bmpImage->blue_mask );
|
1999-09-19 16:15:41 +02:00
|
|
|
updatesection:
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== any bmp format -> pal 8 dib ==== */
|
|
|
|
for (h=lines-1; h>=0; h--) {
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=0; x<width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstbyte=X11DRV_DIB_MapColor
|
|
|
|
((int*)colors, 256,
|
|
|
|
XGetPixel(bmpImage, x, h), *dstbyte);
|
|
|
|
dstbyte++;
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_SetImageBits_16
|
|
|
|
*
|
|
|
|
* SetDIBits for a 16-bit deep DIB.
|
|
|
|
*/
|
|
|
|
static void X11DRV_DIB_SetImageBits_16( int lines, const BYTE *srcbits,
|
2009-08-29 21:43:51 +02:00
|
|
|
DWORD srcwidth, DWORD dstwidth, int left,
|
|
|
|
X11DRV_PDEVICE *physDev, DWORD rSrc, DWORD gSrc, DWORD bSrc,
|
|
|
|
XImage *bmpImage, int linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2003-11-25 04:27:37 +01:00
|
|
|
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap;
|
2001-10-17 21:41:54 +02:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
1999-04-11 19:04:16 +02:00
|
|
|
{
|
1999-09-03 18:49:17 +02:00
|
|
|
lines = -lines;
|
1999-09-14 13:51:01 +02:00
|
|
|
srcbits = srcbits + ( linebytes * (lines-1));
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
|
|
|
|
switch (bmpImage->depth)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
case 15:
|
2001-12-21 20:18:30 +01:00
|
|
|
case 16:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*2;
|
|
|
|
dstbits=bmpImage->data+left*2+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (gSrc==bmpImage->green_mask) {
|
|
|
|
if (rSrc==bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 555 dib -> rgb 555 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> bgr 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_5x5_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else if (rSrc==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 555 dib -> bgr 555 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> rgb 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (rSrc==bmpImage->red_mask || bSrc==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 565 dib -> rgb 555 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> bgr 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_555_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 565 dib -> bgr 555 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> rgb 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (gSrc==bmpImage->green_mask) {
|
|
|
|
if (rSrc==bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 565 dib -> rgb 565 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> bgr 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_5x5_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 565 dib -> bgr 565 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> rgb 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (rSrc==bmpImage->red_mask || bSrc==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 555 dib -> rgb 565 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> bgr 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_565_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 555 dib -> bgr 565 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> rgb 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
1999-04-11 19:04:16 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
case 24:
|
|
|
|
if (bmpImage->bits_per_pixel==24) {
|
2001-10-17 21:41:54 +02:00
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*2;
|
2001-12-21 20:18:30 +01:00
|
|
|
dstbits=bmpImage->data+left*3+(lines-1)*bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if ((rSrc==0x1f && bmpImage->red_mask==0xff) ||
|
|
|
|
(bSrc==0x1f && bmpImage->blue_mask==0xff)) {
|
|
|
|
if (gSrc==0x03e0) {
|
|
|
|
/* ==== rgb 555 dib -> rgb 888 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> bgr 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
/* ==== rgb 565 dib -> rgb 888 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> bgr 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (gSrc==0x03e0) {
|
|
|
|
/* ==== rgb 555 dib -> bgr 888 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> rgb 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 565 dib -> bgr 888 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> rgb 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
|
|
|
}
|
1999-09-03 18:49:17 +02:00
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
/* Fall through */
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*2;
|
|
|
|
dstbits=bmpImage->data+left*4+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if ((rSrc==0x1f && bmpImage->red_mask==0xff) ||
|
|
|
|
(bSrc==0x1f && bmpImage->blue_mask==0xff)) {
|
|
|
|
if (gSrc==0x03e0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 555 dib -> rgb 0888 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> bgr 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
/* ==== rgb 565 dib -> rgb 0888 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> bgr 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (gSrc==0x03e0) {
|
|
|
|
/* ==== rgb 555 dib -> bgr 0888 bmp ==== */
|
|
|
|
/* ==== bgr 555 dib -> rgb 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 565 dib -> bgr 0888 bmp ==== */
|
|
|
|
/* ==== bgr 565 dib -> rgb 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
default:
|
|
|
|
notsupported:
|
2006-10-08 01:34:01 +02:00
|
|
|
WARN("from 16 bit DIB (%x,%x,%x) to unknown %d bit bitmap (%lx,%lx,%lx)\n",
|
2001-12-21 20:18:30 +01:00
|
|
|
rSrc, gSrc, bSrc, bmpImage->bits_per_pixel, bmpImage->red_mask,
|
|
|
|
bmpImage->green_mask, bmpImage->blue_mask );
|
|
|
|
/* fall through */
|
2001-10-17 21:41:54 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
/* ==== rgb or bgr 555 or 565 dib -> pal 1, 4 or 8 ==== */
|
|
|
|
const WORD* srcpixel;
|
|
|
|
int rShift1,gShift1,bShift1;
|
|
|
|
int rShift2,gShift2,bShift2;
|
|
|
|
BYTE gMask1,gMask2;
|
|
|
|
|
|
|
|
/* Set color scaling values */
|
|
|
|
rShift1=16+X11DRV_DIB_MaskToShift(rSrc)-3;
|
|
|
|
gShift1=16+X11DRV_DIB_MaskToShift(gSrc)-3;
|
|
|
|
bShift1=16+X11DRV_DIB_MaskToShift(bSrc)-3;
|
|
|
|
rShift2=rShift1+5;
|
|
|
|
gShift2=gShift1+5;
|
|
|
|
bShift2=bShift1+5;
|
|
|
|
if (gSrc==0x03e0) {
|
|
|
|
/* Green has 5 bits, like the others */
|
|
|
|
gMask1=0xf8;
|
|
|
|
gMask2=0x07;
|
|
|
|
} else {
|
|
|
|
/* Green has 6 bits, not 5. Compensate. */
|
|
|
|
gShift1++;
|
|
|
|
gShift2+=2;
|
|
|
|
gMask1=0xfc;
|
|
|
|
gMask2=0x03;
|
|
|
|
}
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits+=2*left;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* We could split it into four separate cases to optimize
|
2001-10-17 21:41:54 +02:00
|
|
|
* but it is probably not worth it.
|
|
|
|
*/
|
|
|
|
for (h=lines-1; h>=0; h--) {
|
|
|
|
srcpixel=(const WORD*)srcbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x=left; x<width+left; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
DWORD srcval;
|
|
|
|
BYTE red,green,blue;
|
|
|
|
srcval=*srcpixel++ << 16;
|
|
|
|
red= ((srcval >> rShift1) & 0xf8) |
|
2001-12-21 20:18:30 +01:00
|
|
|
((srcval >> rShift2) & 0x07);
|
2001-10-17 21:41:54 +02:00
|
|
|
green=((srcval >> gShift1) & gMask1) |
|
2001-12-21 20:18:30 +01:00
|
|
|
((srcval >> gShift2) & gMask2);
|
2001-10-17 21:41:54 +02:00
|
|
|
blue= ((srcval >> bShift1) & 0xf8) |
|
2001-12-21 20:18:30 +01:00
|
|
|
((srcval >> bShift2) & 0x07);
|
2001-10-17 21:41:54 +02:00
|
|
|
XPutPixel(bmpImage, x, h,
|
2001-12-21 20:18:30 +01:00
|
|
|
X11DRV_PALETTE_ToPhysical
|
2002-03-28 23:22:05 +01:00
|
|
|
(physDev, RGB(red,green,blue)));
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
srcbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
1999-09-03 18:49:17 +02:00
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetImageBits_16
|
|
|
|
*
|
|
|
|
* GetDIBits for an 16-bit deep DIB.
|
|
|
|
*/
|
2009-09-01 22:05:40 +02:00
|
|
|
static void X11DRV_DIB_GetImageBits_16( X11DRV_PDEVICE *physDev, int lines, BYTE *dstbits,
|
1999-09-14 13:51:01 +02:00
|
|
|
DWORD dstwidth, DWORD srcwidth,
|
2000-11-26 00:51:59 +01:00
|
|
|
PALETTEENTRY *srccolors,
|
|
|
|
DWORD rDst, DWORD gDst, DWORD bDst,
|
2009-08-29 21:43:51 +02:00
|
|
|
XImage *bmpImage, int linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2003-11-25 04:27:37 +01:00
|
|
|
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
|
|
|
{
|
|
|
|
lines = -lines;
|
1999-09-14 13:51:01 +02:00
|
|
|
dstbits = dstbits + ( linebytes * (lines-1));
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (gDst==bmpImage->green_mask) {
|
|
|
|
if (rDst==bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 555 bmp -> rgb 555 dib ==== */
|
|
|
|
/* ==== bgr 555 bmp -> bgr 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_5x5_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 555 bmp -> bgr 555 dib ==== */
|
|
|
|
/* ==== bgr 555 bmp -> rgb 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (rDst==bmpImage->red_mask || bDst==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 555 bmp -> rgb 565 dib ==== */
|
|
|
|
/* ==== bgr 555 bmp -> bgr 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_565_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 555 bmp -> bgr 565 dib ==== */
|
|
|
|
/* ==== bgr 555 bmp -> rgb 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (gDst==bmpImage->green_mask) {
|
|
|
|
if (rDst == bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 565 bmp -> rgb 565 dib ==== */
|
|
|
|
/* ==== bgr 565 bmp -> bgr 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_5x5_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 565 bmp -> bgr 565 dib ==== */
|
|
|
|
/* ==== bgr 565 bmp -> rgb 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (rDst==bmpImage->red_mask || bDst==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 565 bmp -> rgb 555 dib ==== */
|
|
|
|
/* ==== bgr 565 bmp -> bgr 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_555_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 565 bmp -> bgr 555 dib ==== */
|
|
|
|
/* ==== bgr 565 bmp -> rgb 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
|
|
|
if (bmpImage->bits_per_pixel == 24) {
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if ((rDst==0x1f && bmpImage->red_mask==0xff) ||
|
2001-10-17 21:41:54 +02:00
|
|
|
(bDst==0x1f && bmpImage->blue_mask==0xff)) {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (gDst==0x03e0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 bmp -> rgb 555 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> bgr 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_555_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
/* ==== rgb 888 bmp -> rgb 565 dib ==== */
|
|
|
|
/* ==== rgb 888 bmp -> rgb 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_565_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (gDst==0x03e0) {
|
|
|
|
/* ==== rgb 888 bmp -> bgr 555 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> rgb 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 888 bmp -> bgr 565 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> rgb 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
|
|
|
}
|
1999-09-14 13:51:01 +02:00
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
/* Fall through */
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if ((rDst==0x1f && bmpImage->red_mask==0xff) ||
|
|
|
|
(bDst==0x1f && bmpImage->blue_mask==0xff)) {
|
|
|
|
if (gDst==0x03e0) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 0888 bmp -> rgb 555 dib ==== */
|
|
|
|
/* ==== bgr 0888 bmp -> bgr 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_555_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
/* ==== rgb 0888 bmp -> rgb 565 dib ==== */
|
|
|
|
/* ==== bgr 0888 bmp -> bgr 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_565_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (gDst==0x03e0) {
|
|
|
|
/* ==== rgb 0888 bmp -> bgr 555 dib ==== */
|
|
|
|
/* ==== bgr 0888 bmp -> rgb 555 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 0888 bmp -> bgr 565 dib ==== */
|
|
|
|
/* ==== bgr 0888 bmp -> rgb 565 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 1 or 4 bmp -> rgb or bgr 555 or 565 dib ==== */
|
|
|
|
int rShift,gShift,bShift;
|
|
|
|
WORD* dstpixel;
|
|
|
|
|
|
|
|
/* Shift everything 16 bits left so that all shifts are >0,
|
|
|
|
* even for BGR DIBs. Then a single >> 16 will bring everything
|
|
|
|
* back into place.
|
|
|
|
*/
|
|
|
|
rShift=16+X11DRV_DIB_MaskToShift(rDst)-3;
|
|
|
|
gShift=16+X11DRV_DIB_MaskToShift(gDst)-3;
|
|
|
|
bShift=16+X11DRV_DIB_MaskToShift(bDst)-3;
|
|
|
|
if (gDst==0x07e0) {
|
|
|
|
/* 6 bits for the green */
|
|
|
|
gShift++;
|
|
|
|
}
|
|
|
|
rDst=rDst << 16;
|
|
|
|
gDst=gDst << 16;
|
|
|
|
bDst=bDst << 16;
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
dstpixel=(LPWORD)dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
|
|
|
DWORD dstval;
|
|
|
|
srcval=srccolors[XGetPixel(bmpImage, x, h)];
|
|
|
|
dstval=((srcval.peRed << rShift) & rDst) |
|
|
|
|
((srcval.peGreen << gShift) & gDst) |
|
|
|
|
((srcval.peBlue << bShift) & bDst);
|
|
|
|
*dstpixel++=dstval >> 16;
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 8:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 bmp -> rgb or bgr 555 or 565 dib ==== */
|
|
|
|
int rShift,gShift,bShift;
|
|
|
|
const BYTE* srcbits;
|
|
|
|
const BYTE* srcpixel;
|
|
|
|
WORD* dstpixel;
|
|
|
|
|
|
|
|
/* Shift everything 16 bits left so that all shifts are >0,
|
|
|
|
* even for BGR DIBs. Then a single >> 16 will bring everything
|
|
|
|
* back into place.
|
|
|
|
*/
|
|
|
|
rShift=16+X11DRV_DIB_MaskToShift(rDst)-3;
|
|
|
|
gShift=16+X11DRV_DIB_MaskToShift(gDst)-3;
|
|
|
|
bShift=16+X11DRV_DIB_MaskToShift(bDst)-3;
|
|
|
|
if (gDst==0x07e0) {
|
|
|
|
/* 6 bits for the green */
|
|
|
|
gShift++;
|
|
|
|
}
|
|
|
|
rDst=rDst << 16;
|
|
|
|
gDst=gDst << 16;
|
|
|
|
bDst=bDst << 16;
|
2005-08-15 12:47:23 +02:00
|
|
|
srcbits=(BYTE*)bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
for (h=0; h<lines; h++) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstpixel=(LPWORD)dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
|
|
|
DWORD dstval;
|
2007-10-23 15:32:38 +02:00
|
|
|
srcval=srccolors[*srcpixel++];
|
2001-10-17 21:41:54 +02:00
|
|
|
dstval=((srcval.peRed << rShift) & rDst) |
|
|
|
|
((srcval.peGreen << gShift) & gDst) |
|
|
|
|
((srcval.peBlue << bShift) & bDst);
|
|
|
|
*dstpixel++=dstval >> 16;
|
|
|
|
}
|
|
|
|
srcbits -= bmpImage->bytes_per_line;
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
notsupported:
|
|
|
|
{
|
|
|
|
/* ==== any bmp format -> rgb or bgr 555 or 565 dib ==== */
|
|
|
|
int rShift,gShift,bShift;
|
|
|
|
WORD* dstpixel;
|
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 16 bit DIB (%x,%x,%x)\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
bmpImage->depth, bmpImage->red_mask,
|
|
|
|
bmpImage->green_mask, bmpImage->blue_mask,
|
|
|
|
rDst, gDst, bDst);
|
|
|
|
|
|
|
|
/* Shift everything 16 bits left so that all shifts are >0,
|
|
|
|
* even for BGR DIBs. Then a single >> 16 will bring everything
|
|
|
|
* back into place.
|
|
|
|
*/
|
|
|
|
rShift=16+X11DRV_DIB_MaskToShift(rDst)-3;
|
|
|
|
gShift=16+X11DRV_DIB_MaskToShift(gDst)-3;
|
|
|
|
bShift=16+X11DRV_DIB_MaskToShift(bDst)-3;
|
|
|
|
if (gDst==0x07e0) {
|
|
|
|
/* 6 bits for the green */
|
|
|
|
gShift++;
|
|
|
|
}
|
|
|
|
rDst=rDst << 16;
|
|
|
|
gDst=gDst << 16;
|
|
|
|
bDst=bDst << 16;
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
dstpixel=(LPWORD)dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
COLORREF srcval;
|
|
|
|
DWORD dstval;
|
2009-09-01 22:05:40 +02:00
|
|
|
srcval=X11DRV_PALETTE_ToLogical(physDev, XGetPixel(bmpImage, x, h));
|
2001-10-17 21:41:54 +02:00
|
|
|
dstval=((GetRValue(srcval) << rShift) & rDst) |
|
|
|
|
((GetGValue(srcval) << gShift) & gDst) |
|
|
|
|
((GetBValue(srcval) << bShift) & bDst);
|
|
|
|
*dstpixel++=dstval >> 16;
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_SetImageBits_24
|
|
|
|
*
|
|
|
|
* SetDIBits for a 24-bit deep DIB.
|
|
|
|
*/
|
|
|
|
static void X11DRV_DIB_SetImageBits_24( int lines, const BYTE *srcbits,
|
|
|
|
DWORD srcwidth, DWORD dstwidth, int left,
|
2002-03-28 23:22:05 +01:00
|
|
|
X11DRV_PDEVICE *physDev,
|
2001-10-17 21:41:54 +02:00
|
|
|
DWORD rSrc, DWORD gSrc, DWORD bSrc,
|
|
|
|
XImage *bmpImage, DWORD linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2003-11-25 04:27:37 +01:00
|
|
|
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap;
|
2001-10-17 21:41:54 +02:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
|
|
|
{
|
|
|
|
lines = -lines;
|
1999-09-19 14:04:17 +02:00
|
|
|
srcbits = srcbits + linebytes * (lines - 1);
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth)
|
1999-04-11 19:04:16 +02:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
|
|
|
if (bmpImage->bits_per_pixel==24) {
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*3;
|
|
|
|
dstbits=bmpImage->data+left*3+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (rSrc==bmpImage->red_mask) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 dib -> rgb 888 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> bgr 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 888 dib -> bgr 888 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> rgb 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
/* fall through */
|
1999-04-11 19:04:16 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*3;
|
|
|
|
dstbits=bmpImage->data+left*4+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (rSrc==bmpImage->red_mask) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 dib -> rgb 0888 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> bgr 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 888 dib -> bgr 0888 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> rgb 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
1999-04-11 19:04:16 +02:00
|
|
|
}
|
1999-09-03 18:49:17 +02:00
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*3;
|
|
|
|
dstbits=bmpImage->data+left*2+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if ((rSrc==0xff0000 && bmpImage->red_mask==0x7f00) ||
|
|
|
|
(bSrc==0xff0000 && bmpImage->blue_mask==0x7f00)) {
|
|
|
|
/* ==== rgb 888 dib -> rgb 555 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> bgr 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_555_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else if ((rSrc==0xff && bmpImage->red_mask==0x7f00) ||
|
|
|
|
(bSrc==0xff && bmpImage->blue_mask==0x7f00)) {
|
|
|
|
/* ==== rgb 888 dib -> bgr 555 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> rgb 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if ((rSrc==0xff0000 && bmpImage->red_mask==0xf800) ||
|
|
|
|
(bSrc==0xff0000 && bmpImage->blue_mask==0xf800)) {
|
|
|
|
/* ==== rgb 888 dib -> rgb 565 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> bgr 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_565_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else if ((rSrc==0xff && bmpImage->red_mask==0xf800) ||
|
|
|
|
(bSrc==0xff && bmpImage->blue_mask==0xf800)) {
|
|
|
|
/* ==== rgb 888 dib -> bgr 565 bmp ==== */
|
|
|
|
/* ==== bgr 888 dib -> rgb 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
default:
|
|
|
|
notsupported:
|
2006-10-08 01:34:01 +02:00
|
|
|
WARN("from 24 bit DIB (%x,%x,%x) to unknown %d bit bitmap (%lx,%lx,%lx)\n",
|
2001-12-21 20:18:30 +01:00
|
|
|
rSrc, gSrc, bSrc, bmpImage->bits_per_pixel, bmpImage->red_mask,
|
|
|
|
bmpImage->green_mask, bmpImage->blue_mask );
|
|
|
|
/* fall through */
|
2001-10-17 21:41:54 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
{
|
2008-01-04 20:37:14 +01:00
|
|
|
/* ==== rgb 888 dib -> any bmp format ==== */
|
2001-10-17 21:41:54 +02:00
|
|
|
const BYTE* srcbyte;
|
|
|
|
|
|
|
|
/* Windows only supports one 24bpp DIB format: RGB888 */
|
|
|
|
srcbits+=left*3;
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
2008-02-02 18:27:19 +01:00
|
|
|
srcbyte = srcbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = left; x < width+left; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
XPutPixel(bmpImage, x, h,
|
|
|
|
X11DRV_PALETTE_ToPhysical
|
2002-03-28 23:22:05 +01:00
|
|
|
(physDev, RGB(srcbyte[2], srcbyte[1], srcbyte[0])));
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbyte+=3;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits += linebytes;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetImageBits_24
|
|
|
|
*
|
|
|
|
* GetDIBits for an 24-bit deep DIB.
|
|
|
|
*/
|
2009-09-01 22:05:40 +02:00
|
|
|
static void X11DRV_DIB_GetImageBits_24( X11DRV_PDEVICE *physDev, int lines, BYTE *dstbits,
|
1999-09-14 13:51:01 +02:00
|
|
|
DWORD dstwidth, DWORD srcwidth,
|
2000-12-06 21:15:43 +01:00
|
|
|
PALETTEENTRY *srccolors,
|
2001-10-17 21:41:54 +02:00
|
|
|
DWORD rDst, DWORD gDst, DWORD bDst,
|
2000-12-06 21:15:43 +01:00
|
|
|
XImage *bmpImage, DWORD linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2003-11-25 04:27:37 +01:00
|
|
|
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
|
|
|
{
|
|
|
|
lines = -lines;
|
1999-09-14 13:51:01 +02:00
|
|
|
dstbits = dstbits + ( linebytes * (lines-1) );
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
|
|
|
if (bmpImage->bits_per_pixel==24) {
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (rDst==bmpImage->red_mask) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 bmp -> rgb 888 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> bgr 888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 888 bmp -> bgr 888 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> rgb 888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
/* fall through */
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
} else if (rDst==bmpImage->red_mask) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 bmp -> rgb 0888 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> bgr 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== rgb 888 bmp -> bgr 0888 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> rgb 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
{
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if ((rDst==0xff0000 && bmpImage->red_mask==0x7f00) ||
|
|
|
|
(bDst==0xff0000 && bmpImage->blue_mask==0x7f00)) {
|
|
|
|
/* ==== rgb 555 bmp -> rgb 888 dib ==== */
|
|
|
|
/* ==== bgr 555 bmp -> bgr 888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else if ((rDst==0xff && bmpImage->red_mask==0x7f00) ||
|
|
|
|
(bDst==0xff && bmpImage->blue_mask==0x7f00)) {
|
|
|
|
/* ==== rgb 555 bmp -> bgr 888 dib ==== */
|
|
|
|
/* ==== bgr 555 bmp -> rgb 888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if ((rDst==0xff0000 && bmpImage->red_mask==0xf800) ||
|
|
|
|
(bDst==0xff0000 && bmpImage->blue_mask==0xf800)) {
|
|
|
|
/* ==== rgb 565 bmp -> rgb 888 dib ==== */
|
|
|
|
/* ==== bgr 565 bmp -> bgr 888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else if ((rDst==0xff && bmpImage->red_mask==0xf800) ||
|
|
|
|
(bDst==0xff && bmpImage->blue_mask==0xf800)) {
|
|
|
|
/* ==== rgb 565 bmp -> bgr 888 dib ==== */
|
|
|
|
/* ==== bgr 565 bmp -> rgb 888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 1 or 4 bmp -> rgb 888 dib ==== */
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
/* Windows only supports one 24bpp DIB format: rgb 888 */
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
|
|
|
srcval=srccolors[XGetPixel(bmpImage, x, h)];
|
|
|
|
dstbyte[0]=srcval.peBlue;
|
|
|
|
dstbyte[1]=srcval.peGreen;
|
|
|
|
dstbyte[2]=srcval.peRed;
|
|
|
|
dstbyte+=3;
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 8:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 bmp -> rgb 888 dib ==== */
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE* srcpixel;
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
|
|
|
/* Windows only supports one 24bpp DIB format: rgb 888 */
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++ ) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
2007-10-23 15:32:38 +02:00
|
|
|
srcval=srccolors[*srcpixel++];
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbyte[0]=srcval.peBlue;
|
|
|
|
dstbyte[1]=srcval.peGreen;
|
|
|
|
dstbyte[2]=srcval.peRed;
|
|
|
|
dstbyte+=3;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
default:
|
|
|
|
notsupported:
|
|
|
|
{
|
|
|
|
/* ==== any bmp format -> 888 dib ==== */
|
|
|
|
BYTE* dstbyte;
|
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 24 bit DIB (%x,%x,%x)\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
bmpImage->depth, bmpImage->red_mask,
|
2001-12-21 20:18:30 +01:00
|
|
|
bmpImage->green_mask, bmpImage->blue_mask,
|
|
|
|
rDst, gDst, bDst );
|
2001-10-17 21:41:54 +02:00
|
|
|
|
|
|
|
/* Windows only supports one 24bpp DIB format: rgb 888 */
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
dstbyte=dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
COLORREF srcval=X11DRV_PALETTE_ToLogical
|
2009-09-01 22:05:40 +02:00
|
|
|
(physDev, XGetPixel( bmpImage, x, h ));
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbyte[0]=GetBValue(srcval);
|
|
|
|
dstbyte[1]=GetGValue(srcval);
|
|
|
|
dstbyte[2]=GetRValue(srcval);
|
|
|
|
dstbyte+=3;
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_SetImageBits_32
|
|
|
|
*
|
|
|
|
* SetDIBits for a 32-bit deep DIB.
|
|
|
|
*/
|
2001-10-17 21:41:54 +02:00
|
|
|
static void X11DRV_DIB_SetImageBits_32(int lines, const BYTE *srcbits,
|
|
|
|
DWORD srcwidth, DWORD dstwidth, int left,
|
2002-03-28 23:22:05 +01:00
|
|
|
X11DRV_PDEVICE *physDev,
|
2001-10-17 21:41:54 +02:00
|
|
|
DWORD rSrc, DWORD gSrc, DWORD bSrc,
|
|
|
|
XImage *bmpImage,
|
|
|
|
DWORD linebytes)
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2003-11-25 04:27:37 +01:00
|
|
|
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap;
|
2001-10-17 21:41:54 +02:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
1999-04-11 19:04:16 +02:00
|
|
|
{
|
1999-09-03 18:49:17 +02:00
|
|
|
lines = -lines;
|
1999-09-14 13:51:01 +02:00
|
|
|
srcbits = srcbits + ( linebytes * (lines-1) );
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
1999-04-11 19:04:16 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
|
|
|
if (bmpImage->bits_per_pixel==24) {
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*4;
|
|
|
|
dstbits=bmpImage->data+left*3+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
|
|
|
if (rSrc==bmpImage->red_mask && gSrc==bmpImage->green_mask && bSrc==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 0888 dib -> rgb 888 bmp ==== */
|
|
|
|
/* ==== bgr 0888 dib -> bgr 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
/* the tests below assume sane bmpImage masks */
|
2001-10-17 21:41:54 +02:00
|
|
|
} else if (rSrc==bmpImage->blue_mask && gSrc==bmpImage->green_mask && bSrc==bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 0888 dib -> bgr 888 bmp ==== */
|
|
|
|
/* ==== bgr 0888 dib -> rgb 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0xff) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== any 0888 dib -> rgb 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_any0888_to_rgb888
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
rSrc,gSrc,bSrc,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== any 0888 dib -> bgr 888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_any0888_to_bgr888
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
rSrc,gSrc,bSrc,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
/* fall through */
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*4;
|
|
|
|
dstbits=bmpImage->data+left*4+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
|
|
|
if (gSrc==bmpImage->green_mask) {
|
|
|
|
if (rSrc==bmpImage->red_mask && bSrc==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 0888 dib -> rgb 0888 bmp ==== */
|
|
|
|
/* ==== bgr 0888 dib -> bgr 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
/* the tests below assume sane bmpImage masks */
|
2001-10-17 21:41:54 +02:00
|
|
|
} else if (rSrc==bmpImage->blue_mask && bSrc==bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 0888 dib -> bgr 0888 bmp ==== */
|
|
|
|
/* ==== bgr 0888 dib -> rgb 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
/* ==== any 0888 dib -> any 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_any
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
rSrc,gSrc,bSrc,
|
|
|
|
dstbits,-bmpImage->bytes_per_line,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask);
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
/* the tests below assume sane bmpImage masks */
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
|
|
|
/* ==== any 0888 dib -> any 0888 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_any
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
|
|
|
rSrc,gSrc,bSrc,
|
|
|
|
dstbits,-bmpImage->bytes_per_line,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask);
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 15:
|
2001-12-21 20:18:30 +01:00
|
|
|
case 16:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
char* dstbits;
|
|
|
|
|
|
|
|
srcbits=srcbits+left*4;
|
|
|
|
dstbits=bmpImage->data+left*2+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
|
|
|
if (rSrc==0xff0000 && gSrc==0x00ff00 && bSrc==0x0000ff) {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (bmpImage->red_mask==0x7f00) {
|
|
|
|
/* ==== rgb 0888 dib -> rgb 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_555_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else if (bmpImage->blue_mask==0x7f00) {
|
|
|
|
/* ==== rgb 0888 dib -> bgr 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (bmpImage->red_mask==0xf800) {
|
|
|
|
/* ==== rgb 0888 dib -> rgb 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_565_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else if (bmpImage->blue_mask==0xf800) {
|
|
|
|
/* ==== rgb 0888 dib -> bgr 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
1999-04-11 19:04:16 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else if (rSrc==0x0000ff && gSrc==0x00ff00 && bSrc==0xff0000) {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (bmpImage->blue_mask==0x7f00) {
|
|
|
|
/* ==== bgr 0888 dib -> bgr 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_555_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else if (bmpImage->red_mask==0x7f00) {
|
|
|
|
/* ==== bgr 0888 dib -> rgb 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_555_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (bmpImage->blue_mask==0xf800) {
|
|
|
|
/* ==== bgr 0888 dib -> bgr 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_565_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else if (bmpImage->red_mask==0xf800) {
|
|
|
|
/* ==== bgr 0888 dib -> rgb 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_to_565_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,linebytes,
|
|
|
|
dstbits,-bmpImage->bytes_per_line);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0 &&
|
|
|
|
(bmpImage->red_mask==0x7f00 ||
|
|
|
|
bmpImage->blue_mask==0x7f00)) {
|
|
|
|
/* ==== any 0888 dib -> rgb or bgr 555 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_any0888_to_5x5
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
2001-12-21 20:18:30 +01:00
|
|
|
rSrc,gSrc,bSrc,
|
|
|
|
dstbits,-bmpImage->bytes_per_line,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask);
|
|
|
|
} else if (bmpImage->green_mask==0x07e0 &&
|
|
|
|
(bmpImage->red_mask==0xf800 ||
|
|
|
|
bmpImage->blue_mask==0xf800)) {
|
|
|
|
/* ==== any 0888 dib -> rgb or bgr 565 bmp ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_any0888_to_5x5
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,linebytes,
|
2001-12-21 20:18:30 +01:00
|
|
|
rSrc,gSrc,bSrc,
|
|
|
|
dstbits,-bmpImage->bytes_per_line,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask);
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
1999-04-11 19:04:16 +02:00
|
|
|
}
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-12-21 20:18:30 +01:00
|
|
|
default:
|
|
|
|
notsupported:
|
2006-10-08 01:34:01 +02:00
|
|
|
WARN("from 32 bit DIB (%x,%x,%x) to unknown %d bit bitmap (%lx,%lx,%lx)\n",
|
2001-12-21 20:18:30 +01:00
|
|
|
rSrc, gSrc, bSrc, bmpImage->bits_per_pixel, bmpImage->red_mask,
|
|
|
|
bmpImage->green_mask, bmpImage->blue_mask );
|
|
|
|
/* fall through */
|
2001-10-17 21:41:54 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
/* ==== any 0888 dib -> pal 1, 4 or 8 bmp ==== */
|
|
|
|
const DWORD* srcpixel;
|
|
|
|
int rShift,gShift,bShift;
|
|
|
|
|
|
|
|
rShift=X11DRV_DIB_MaskToShift(rSrc);
|
|
|
|
gShift=X11DRV_DIB_MaskToShift(gSrc);
|
|
|
|
bShift=X11DRV_DIB_MaskToShift(bSrc);
|
|
|
|
srcbits+=left*4;
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
srcpixel=(const DWORD*)srcbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = left; x < width+left; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
DWORD srcvalue;
|
|
|
|
BYTE red,green,blue;
|
|
|
|
srcvalue=*srcpixel++;
|
|
|
|
red= (srcvalue >> rShift) & 0xff;
|
|
|
|
green=(srcvalue >> gShift) & 0xff;
|
|
|
|
blue= (srcvalue >> bShift) & 0xff;
|
|
|
|
XPutPixel(bmpImage, x, h, X11DRV_PALETTE_ToPhysical
|
2002-03-28 23:22:05 +01:00
|
|
|
(physDev, RGB(red,green,blue)));
|
1999-04-11 19:04:16 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits += linebytes;
|
1999-04-11 19:04:16 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetImageBits_32
|
|
|
|
*
|
|
|
|
* GetDIBits for an 32-bit deep DIB.
|
|
|
|
*/
|
2009-09-01 22:05:40 +02:00
|
|
|
static void X11DRV_DIB_GetImageBits_32( X11DRV_PDEVICE *physDev, int lines, BYTE *dstbits,
|
1999-09-14 13:51:01 +02:00
|
|
|
DWORD dstwidth, DWORD srcwidth,
|
2000-12-06 21:15:43 +01:00
|
|
|
PALETTEENTRY *srccolors,
|
2001-10-17 21:41:54 +02:00
|
|
|
DWORD rDst, DWORD gDst, DWORD bDst,
|
2009-08-29 21:43:51 +02:00
|
|
|
XImage *bmpImage, int linebytes )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
DWORD x;
|
2004-08-12 22:02:39 +02:00
|
|
|
int h, width = min(srcwidth, dstwidth);
|
2003-11-25 04:27:37 +01:00
|
|
|
const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap;
|
1998-11-06 12:03:00 +01:00
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
if (lines < 0 )
|
|
|
|
{
|
|
|
|
lines = -lines;
|
1999-09-14 13:51:01 +02:00
|
|
|
dstbits = dstbits + ( linebytes * (lines-1) );
|
1999-09-03 18:49:17 +02:00
|
|
|
linebytes = -linebytes;
|
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
switch (bmpImage->depth)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
|
|
|
if (bmpImage->bits_per_pixel==24) {
|
|
|
|
const void* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
|
|
|
if (rDst==bmpImage->red_mask && gDst==bmpImage->green_mask && bDst==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 888 bmp -> rgb 0888 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> bgr 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
/* the tests below assume sane bmpImage masks */
|
2001-10-17 21:41:54 +02:00
|
|
|
} else if (rDst==bmpImage->blue_mask && gDst==bmpImage->green_mask && bDst==bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 888 bmp -> bgr 0888 dib ==== */
|
|
|
|
/* ==== bgr 888 bmp -> rgb 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_888_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->blue_mask==0xff) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== rgb 888 bmp -> any 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_rgb888_to_any0888
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes,
|
|
|
|
rDst,gDst,bDst);
|
|
|
|
} else {
|
|
|
|
/* ==== bgr 888 bmp -> any 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_bgr888_to_any0888
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes,
|
|
|
|
rDst,gDst,bDst);
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
break;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
/* fall through */
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
|
|
|
if (gDst==bmpImage->green_mask) {
|
|
|
|
if (rDst==bmpImage->red_mask && bDst==bmpImage->blue_mask) {
|
|
|
|
/* ==== rgb 0888 bmp -> rgb 0888 dib ==== */
|
|
|
|
/* ==== bgr 0888 bmp -> bgr 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
/* the tests below assume sane bmpImage masks */
|
2001-10-17 21:41:54 +02:00
|
|
|
} else if (rDst==bmpImage->blue_mask && bDst==bmpImage->red_mask) {
|
|
|
|
/* ==== rgb 0888 bmp -> bgr 0888 dib ==== */
|
|
|
|
/* ==== bgr 0888 bmp -> rgb 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
/* ==== any 0888 bmp -> any 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_any
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
|
|
|
|
dstbits,linebytes,
|
|
|
|
rDst,gDst,bDst);
|
|
|
|
}
|
2001-12-21 20:18:30 +01:00
|
|
|
} else if (bmpImage->green_mask!=0x00ff00 ||
|
|
|
|
(bmpImage->red_mask|bmpImage->blue_mask)!=0xff00ff) {
|
|
|
|
goto notsupported;
|
|
|
|
/* the tests below assume sane bmpImage masks */
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
|
|
|
/* ==== any 0888 bmp -> any 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_0888_any
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
|
|
|
|
dstbits,linebytes,
|
|
|
|
rDst,gDst,bDst);
|
2000-05-24 23:04:42 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 15:
|
2001-12-21 20:18:30 +01:00
|
|
|
case 16:
|
2001-10-17 21:41:54 +02:00
|
|
|
{
|
|
|
|
const char* srcbits;
|
|
|
|
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
|
|
|
|
if (rDst==0xff0000 && gDst==0x00ff00 && bDst==0x0000ff) {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (bmpImage->red_mask==0x7f00) {
|
|
|
|
/* ==== rgb 555 bmp -> rgb 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else if (bmpImage->blue_mask==0x7f00) {
|
|
|
|
/* ==== bgr 555 bmp -> rgb 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (bmpImage->red_mask==0xf800) {
|
|
|
|
/* ==== rgb 565 bmp -> rgb 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else if (bmpImage->blue_mask==0xf800) {
|
|
|
|
/* ==== bgr 565 bmp -> rgb 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else if (rDst==0x0000ff && gDst==0x00ff00 && bDst==0xff0000) {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0) {
|
|
|
|
if (bmpImage->blue_mask==0x7f00) {
|
|
|
|
/* ==== bgr 555 bmp -> bgr 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else if (bmpImage->red_mask==0x7f00) {
|
|
|
|
/* ==== rgb 555 bmp -> bgr 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_555_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
} else if (bmpImage->green_mask==0x07e0) {
|
|
|
|
if (bmpImage->blue_mask==0xf800) {
|
|
|
|
/* ==== bgr 565 bmp -> bgr 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_0888_asis
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else if (bmpImage->red_mask==0xf800) {
|
|
|
|
/* ==== rgb 565 bmp -> bgr 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_565_to_0888_reverse
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-12-21 20:18:30 +01:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
|
|
|
dstbits,linebytes);
|
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
if (bmpImage->green_mask==0x03e0 &&
|
|
|
|
(bmpImage->red_mask==0x7f00 ||
|
|
|
|
bmpImage->blue_mask==0x7f00)) {
|
|
|
|
/* ==== rgb or bgr 555 bmp -> any 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_5x5_to_any0888
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
2001-12-21 20:18:30 +01:00
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
|
|
|
|
dstbits,linebytes,
|
|
|
|
rDst,gDst,bDst);
|
|
|
|
} else if (bmpImage->green_mask==0x07e0 &&
|
|
|
|
(bmpImage->red_mask==0xf800 ||
|
|
|
|
bmpImage->blue_mask==0xf800)) {
|
|
|
|
/* ==== rgb or bgr 565 bmp -> any 0888 dib ==== */
|
2003-11-25 04:27:37 +01:00
|
|
|
convs->Convert_5x5_to_any0888
|
2004-08-12 22:02:39 +02:00
|
|
|
(width,lines,
|
2001-10-17 21:41:54 +02:00
|
|
|
srcbits,-bmpImage->bytes_per_line,
|
2001-12-21 20:18:30 +01:00
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask,
|
|
|
|
dstbits,linebytes,
|
|
|
|
rDst,gDst,bDst);
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
2001-12-21 20:18:30 +01:00
|
|
|
goto notsupported;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 1:
|
|
|
|
case 4:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 1 or 4 bmp -> any 0888 dib ==== */
|
|
|
|
int rShift,gShift,bShift;
|
|
|
|
DWORD* dstpixel;
|
|
|
|
|
|
|
|
rShift=X11DRV_DIB_MaskToShift(rDst);
|
|
|
|
gShift=X11DRV_DIB_MaskToShift(gDst);
|
|
|
|
bShift=X11DRV_DIB_MaskToShift(bDst);
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
dstpixel=(DWORD*)dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
|
|
|
srcval = srccolors[XGetPixel(bmpImage, x, h)];
|
|
|
|
*dstpixel++=(srcval.peRed << rShift) |
|
|
|
|
(srcval.peGreen << gShift) |
|
|
|
|
(srcval.peBlue << bShift);
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
1999-09-14 13:51:01 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
1999-09-14 13:51:01 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 8:
|
2005-11-30 18:26:52 +01:00
|
|
|
if (X11DRV_DIB_CheckMask(bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask)
|
|
|
|
&& srccolors) {
|
2001-10-17 21:41:54 +02:00
|
|
|
/* ==== pal 8 bmp -> any 0888 dib ==== */
|
|
|
|
int rShift,gShift,bShift;
|
|
|
|
const void* srcbits;
|
|
|
|
const BYTE* srcpixel;
|
|
|
|
DWORD* dstpixel;
|
|
|
|
|
|
|
|
rShift=X11DRV_DIB_MaskToShift(rDst);
|
|
|
|
gShift=X11DRV_DIB_MaskToShift(gDst);
|
|
|
|
bShift=X11DRV_DIB_MaskToShift(bDst);
|
|
|
|
srcbits=bmpImage->data+(lines-1)*bmpImage->bytes_per_line;
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
srcpixel=srcbits;
|
|
|
|
dstpixel=(DWORD*)dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
PALETTEENTRY srcval;
|
2007-10-23 15:32:38 +02:00
|
|
|
srcval=srccolors[*srcpixel++];
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstpixel++=(srcval.peRed << rShift) |
|
|
|
|
(srcval.peGreen << gShift) |
|
|
|
|
(srcval.peBlue << bShift);
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2004-11-30 22:38:57 +01:00
|
|
|
srcbits = (const char*)srcbits - bmpImage->bytes_per_line;
|
2001-10-17 21:41:54 +02:00
|
|
|
dstbits += linebytes;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-10-17 21:41:54 +02:00
|
|
|
} else {
|
|
|
|
goto notsupported;
|
|
|
|
}
|
|
|
|
break;
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
default:
|
|
|
|
notsupported:
|
|
|
|
{
|
|
|
|
/* ==== any bmp format -> any 0888 dib ==== */
|
|
|
|
int rShift,gShift,bShift;
|
|
|
|
DWORD* dstpixel;
|
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
WARN("from unknown %d bit bitmap (%lx,%lx,%lx) to 32 bit DIB (%x,%x,%x)\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
bmpImage->depth, bmpImage->red_mask,
|
|
|
|
bmpImage->green_mask, bmpImage->blue_mask,
|
|
|
|
rDst,gDst,bDst);
|
|
|
|
|
|
|
|
rShift=X11DRV_DIB_MaskToShift(rDst);
|
|
|
|
gShift=X11DRV_DIB_MaskToShift(gDst);
|
|
|
|
bShift=X11DRV_DIB_MaskToShift(bDst);
|
|
|
|
for (h = lines - 1; h >= 0; h--) {
|
|
|
|
dstpixel=(DWORD*)dstbits;
|
2004-08-12 22:02:39 +02:00
|
|
|
for (x = 0; x < width; x++) {
|
2001-10-17 21:41:54 +02:00
|
|
|
COLORREF srcval;
|
2009-09-01 22:05:40 +02:00
|
|
|
srcval=X11DRV_PALETTE_ToLogical(physDev, XGetPixel(bmpImage, x, h));
|
2001-10-17 21:41:54 +02:00
|
|
|
*dstpixel++=(GetRValue(srcval) << rShift) |
|
|
|
|
(GetGValue(srcval) << gShift) |
|
|
|
|
(GetBValue(srcval) << bShift);
|
|
|
|
}
|
|
|
|
dstbits += linebytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_SetImageBits
|
|
|
|
*
|
|
|
|
* Transfer the bits to an X image.
|
|
|
|
* Helper function for SetDIBits() and SetDIBitsToDevice().
|
|
|
|
*/
|
2001-01-15 23:30:50 +01:00
|
|
|
static int X11DRV_DIB_SetImageBits( const X11DRV_DIB_IMAGEBITS_DESCR *descr )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
int lines = descr->lines >= 0 ? descr->lines : -descr->lines;
|
2009-08-06 08:12:22 +02:00
|
|
|
void *old_data = NULL;
|
1998-11-06 12:03:00 +01:00
|
|
|
XImage *bmpImage;
|
|
|
|
|
2001-01-15 23:30:50 +01:00
|
|
|
wine_tsx11_lock();
|
1998-11-06 12:03:00 +01:00
|
|
|
if (descr->image)
|
|
|
|
bmpImage = descr->image;
|
1999-02-09 15:11:59 +01:00
|
|
|
else {
|
2001-05-11 02:17:47 +02:00
|
|
|
bmpImage = XCreateImage( gdi_display, visual, descr->depth, ZPixmap, 0, NULL,
|
1999-02-09 15:11:59 +01:00
|
|
|
descr->infoWidth, lines, 32, 0 );
|
2008-08-29 13:34:11 +02:00
|
|
|
bmpImage->data = HeapAlloc( GetProcessHeap(), 0, lines * bmpImage->bytes_per_line );
|
2000-03-19 15:29:50 +01:00
|
|
|
if(bmpImage->data == NULL) {
|
2000-08-25 23:56:19 +02:00
|
|
|
ERR("Out of memory!\n");
|
2000-03-19 15:29:50 +01:00
|
|
|
XDestroyImage( bmpImage );
|
2001-01-15 23:30:50 +01:00
|
|
|
wine_tsx11_unlock();
|
2008-07-19 00:28:06 +02:00
|
|
|
return 0;
|
2000-03-19 15:29:50 +01:00
|
|
|
}
|
2010-06-02 15:52:20 +02:00
|
|
|
if (descr->shifts)
|
|
|
|
{
|
|
|
|
bmpImage->red_mask = descr->shifts->physicalRed.max << descr->shifts->physicalRed.shift;
|
|
|
|
bmpImage->green_mask = descr->shifts->physicalGreen.max << descr->shifts->physicalGreen.shift;
|
|
|
|
bmpImage->blue_mask = descr->shifts->physicalBlue.max << descr->shifts->physicalBlue.shift;
|
|
|
|
}
|
1999-02-09 15:11:59 +01:00
|
|
|
}
|
2007-09-27 18:02:26 +02:00
|
|
|
wine_tsx11_unlock();
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE("Dib: depth=%d r=%x g=%x b=%x\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
descr->infoBpp,descr->rMask,descr->gMask,descr->bMask);
|
|
|
|
TRACE("Bmp: depth=%d/%d r=%lx g=%lx b=%lx\n",
|
|
|
|
bmpImage->depth,bmpImage->bits_per_pixel,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask);
|
|
|
|
|
2009-08-06 08:12:22 +02:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
|
|
|
if (descr->shm_mode == X11DRV_SHM_PIXMAP
|
|
|
|
&& descr->xSrc == 0 && descr->ySrc == 0
|
|
|
|
&& descr->xDest == 0 && descr->yDest == 0)
|
|
|
|
{
|
|
|
|
TRACE("Using the shared pixmap data.\n");
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XSync( gdi_display, False );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
old_data = descr->image->data;
|
|
|
|
descr->image->data = descr->physBitmap->shminfo.shmaddr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-11-06 12:03:00 +01:00
|
|
|
/* Transfer the pixels */
|
2008-03-10 17:22:08 +01:00
|
|
|
__TRY
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
2008-03-10 17:22:08 +01:00
|
|
|
switch(descr->infoBpp)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
X11DRV_DIB_SetImageBits_1( descr->lines, descr->bits, descr->infoWidth,
|
|
|
|
descr->width, descr->xSrc, (int *)(descr->colorMap),
|
|
|
|
bmpImage, descr->dibpitch );
|
|
|
|
break;
|
|
|
|
case 4:
|
2011-09-06 14:48:37 +02:00
|
|
|
X11DRV_DIB_SetImageBits_4( descr->lines, descr->bits,
|
|
|
|
descr->infoWidth, descr->width,
|
|
|
|
descr->xSrc, (int*)(descr->colorMap),
|
|
|
|
bmpImage, descr->dibpitch );
|
2008-03-10 17:22:08 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
2011-09-06 14:48:37 +02:00
|
|
|
X11DRV_DIB_SetImageBits_8( descr->lines, descr->bits,
|
|
|
|
descr->infoWidth, descr->width,
|
|
|
|
descr->xSrc, (int *)(descr->colorMap),
|
|
|
|
bmpImage, descr->dibpitch );
|
2008-03-10 17:22:08 +01:00
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
X11DRV_DIB_SetImageBits_16( descr->lines, descr->bits,
|
|
|
|
descr->infoWidth, descr->width,
|
|
|
|
descr->xSrc, descr->physDev,
|
|
|
|
descr->rMask, descr->gMask, descr->bMask,
|
|
|
|
bmpImage, descr->dibpitch);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
X11DRV_DIB_SetImageBits_24( descr->lines, descr->bits,
|
|
|
|
descr->infoWidth, descr->width,
|
|
|
|
descr->xSrc, descr->physDev,
|
|
|
|
descr->rMask, descr->gMask, descr->bMask,
|
|
|
|
bmpImage, descr->dibpitch);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
X11DRV_DIB_SetImageBits_32( descr->lines, descr->bits,
|
|
|
|
descr->infoWidth, descr->width,
|
|
|
|
descr->xSrc, descr->physDev,
|
|
|
|
descr->rMask, descr->gMask, descr->bMask,
|
|
|
|
bmpImage, descr->dibpitch);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("(%d): Invalid depth\n", descr->infoBpp );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
WARN( "invalid bits pointer %p\n", descr->bits );
|
|
|
|
lines = 0;
|
1998-11-06 12:03:00 +01:00
|
|
|
}
|
2008-03-10 17:22:08 +01:00
|
|
|
__ENDTRY
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
TRACE("XPutImage(%ld,%p,%p,%d,%d,%d,%d,%d,%d)\n",
|
|
|
|
descr->drawable, descr->gc, bmpImage,
|
2000-12-22 02:07:57 +01:00
|
|
|
descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
|
|
|
|
descr->width, descr->height);
|
2007-09-27 18:02:26 +02:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
2008-03-10 17:22:08 +01:00
|
|
|
if (lines)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2008-03-10 17:22:08 +01:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
2009-08-06 08:12:22 +02:00
|
|
|
if (descr->shm_mode == X11DRV_SHM_PIXMAP
|
|
|
|
&& descr->xSrc == 0 && descr->ySrc == 0
|
|
|
|
&& descr->xDest == 0 && descr->yDest == 0)
|
|
|
|
{
|
|
|
|
XSync( gdi_display, False );
|
|
|
|
}
|
|
|
|
else if (descr->shm_mode == X11DRV_SHM_IMAGE && descr->image)
|
2008-03-10 17:22:08 +01:00
|
|
|
{
|
|
|
|
XShmPutImage( gdi_display, descr->drawable, descr->gc, bmpImage,
|
|
|
|
descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
|
|
|
|
descr->width, descr->height, FALSE );
|
|
|
|
XSync( gdi_display, 0 );
|
|
|
|
}
|
|
|
|
else
|
2001-06-25 21:51:04 +02:00
|
|
|
#endif
|
2009-08-06 08:12:22 +02:00
|
|
|
{
|
2008-03-10 17:22:08 +01:00
|
|
|
XPutImage( gdi_display, descr->drawable, descr->gc, bmpImage,
|
|
|
|
descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
|
|
|
|
descr->width, descr->height );
|
2009-08-06 08:12:22 +02:00
|
|
|
}
|
2008-03-10 17:22:08 +01:00
|
|
|
}
|
2009-08-06 08:12:22 +02:00
|
|
|
|
|
|
|
if (old_data) descr->image->data = old_data;
|
|
|
|
|
2008-08-29 13:34:11 +02:00
|
|
|
if (!descr->image) X11DRV_DIB_DestroyXImage( bmpImage );
|
2001-01-15 23:30:50 +01:00
|
|
|
wine_tsx11_unlock();
|
1998-11-06 12:03:00 +01:00
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_GetImageBits
|
|
|
|
*
|
|
|
|
* Transfer the bits from an X image.
|
|
|
|
*/
|
2001-01-15 23:30:50 +01:00
|
|
|
static int X11DRV_DIB_GetImageBits( const X11DRV_DIB_IMAGEBITS_DESCR *descr )
|
1998-11-06 12:03:00 +01:00
|
|
|
{
|
|
|
|
int lines = descr->lines >= 0 ? descr->lines : -descr->lines;
|
2009-08-06 08:12:22 +02:00
|
|
|
void *old_data = NULL;
|
1998-11-06 12:03:00 +01:00
|
|
|
XImage *bmpImage;
|
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
wine_tsx11_lock();
|
2001-01-15 23:30:50 +01:00
|
|
|
if (descr->image)
|
1998-11-06 12:03:00 +01:00
|
|
|
bmpImage = descr->image;
|
1999-02-09 15:11:59 +01:00
|
|
|
else {
|
2001-05-11 02:17:47 +02:00
|
|
|
bmpImage = XCreateImage( gdi_display, visual, descr->depth, ZPixmap, 0, NULL,
|
1999-02-09 15:11:59 +01:00
|
|
|
descr->infoWidth, lines, 32, 0 );
|
2008-08-29 13:34:11 +02:00
|
|
|
bmpImage->data = HeapAlloc( GetProcessHeap(), 0, lines * bmpImage->bytes_per_line );
|
2000-03-19 15:29:50 +01:00
|
|
|
if(bmpImage->data == NULL) {
|
2000-08-25 23:56:19 +02:00
|
|
|
ERR("Out of memory!\n");
|
2000-03-19 15:29:50 +01:00
|
|
|
XDestroyImage( bmpImage );
|
2001-01-15 23:30:50 +01:00
|
|
|
wine_tsx11_unlock();
|
2008-07-19 00:28:06 +02:00
|
|
|
return 0;
|
2001-01-15 23:30:50 +01:00
|
|
|
}
|
2010-06-02 15:52:20 +02:00
|
|
|
if (descr->shifts)
|
|
|
|
{
|
|
|
|
bmpImage->red_mask = descr->shifts->physicalRed.max << descr->shifts->physicalRed.shift;
|
|
|
|
bmpImage->green_mask = descr->shifts->physicalGreen.max << descr->shifts->physicalGreen.shift;
|
|
|
|
bmpImage->blue_mask = descr->shifts->physicalBlue.max << descr->shifts->physicalBlue.shift;
|
|
|
|
}
|
2001-01-15 23:30:50 +01:00
|
|
|
}
|
1998-11-06 12:03:00 +01:00
|
|
|
|
2002-12-16 23:11:35 +01:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
2007-06-26 15:39:30 +02:00
|
|
|
|
2007-10-11 18:31:26 +02:00
|
|
|
/* We must not call XShmGetImage() with a bitmap which is bigger than the available area.
|
2007-06-26 15:39:30 +02:00
|
|
|
If we do, XShmGetImage() will fail (X exception), as it checks for this internally. */
|
2009-08-06 08:12:22 +02:00
|
|
|
if (descr->shm_mode == X11DRV_SHM_PIXMAP && descr->image
|
|
|
|
&& descr->xSrc == 0 && descr->ySrc == 0
|
|
|
|
&& descr->xDest == 0 && descr->yDest == 0
|
|
|
|
&& bmpImage->width <= (descr->width - descr->xSrc)
|
|
|
|
&& bmpImage->height <= (descr->height - descr->ySrc))
|
|
|
|
{
|
|
|
|
XSync( gdi_display, False );
|
|
|
|
old_data = bmpImage->data;
|
|
|
|
bmpImage->data = descr->physBitmap->shminfo.shmaddr;
|
|
|
|
TRACE("Using shared pixmap data.\n");
|
|
|
|
}
|
|
|
|
else if (descr->shm_mode == X11DRV_SHM_IMAGE && descr->image
|
|
|
|
&& bmpImage->width <= (descr->width - descr->xSrc)
|
|
|
|
&& bmpImage->height <= (descr->height - descr->ySrc))
|
2002-01-04 19:23:17 +01:00
|
|
|
{
|
|
|
|
int saveRed, saveGreen, saveBlue;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-04 19:23:17 +01:00
|
|
|
TRACE("XShmGetImage(%p, %ld, %p, %d, %d, %ld)\n",
|
|
|
|
gdi_display, descr->drawable, bmpImage,
|
|
|
|
descr->xSrc, descr->ySrc, AllPlanes);
|
|
|
|
|
|
|
|
/* We must save and restore the bmpImage's masks in order
|
|
|
|
* to preserve them across the call to XShmGetImage, which
|
2008-01-04 20:37:14 +01:00
|
|
|
* decides to eliminate them since it doesn't happen to know
|
2002-06-01 01:06:46 +02:00
|
|
|
* what the format of the image is supposed to be, even though
|
2002-01-04 19:23:17 +01:00
|
|
|
* we do. */
|
|
|
|
saveRed = bmpImage->red_mask;
|
|
|
|
saveBlue= bmpImage->blue_mask;
|
|
|
|
saveGreen = bmpImage->green_mask;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-04 19:23:17 +01:00
|
|
|
XShmGetImage( gdi_display, descr->drawable, bmpImage,
|
|
|
|
descr->xSrc, descr->ySrc, AllPlanes);
|
|
|
|
|
|
|
|
bmpImage->red_mask = saveRed;
|
|
|
|
bmpImage->blue_mask = saveBlue;
|
|
|
|
bmpImage->green_mask = saveGreen;
|
|
|
|
}
|
|
|
|
else
|
2002-12-16 23:11:35 +01:00
|
|
|
#endif /* HAVE_LIBXXSHM */
|
2002-01-04 19:23:17 +01:00
|
|
|
{
|
|
|
|
TRACE("XGetSubImage(%p,%ld,%d,%d,%d,%d,%ld,%d,%p,%d,%d)\n",
|
|
|
|
gdi_display, descr->drawable, descr->xSrc, descr->ySrc, descr->width,
|
|
|
|
lines, AllPlanes, ZPixmap, bmpImage, descr->xDest, descr->yDest);
|
|
|
|
XGetSubImage( gdi_display, descr->drawable, descr->xSrc, descr->ySrc,
|
|
|
|
descr->width, lines, AllPlanes, ZPixmap,
|
|
|
|
bmpImage, descr->xDest, descr->yDest );
|
|
|
|
}
|
2007-09-27 18:02:26 +02:00
|
|
|
wine_tsx11_unlock();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE("Dib: depth=%2d r=%x g=%x b=%x\n",
|
2001-10-17 21:41:54 +02:00
|
|
|
descr->infoBpp,descr->rMask,descr->gMask,descr->bMask);
|
|
|
|
TRACE("Bmp: depth=%2d/%2d r=%lx g=%lx b=%lx\n",
|
|
|
|
bmpImage->depth,bmpImage->bits_per_pixel,
|
|
|
|
bmpImage->red_mask,bmpImage->green_mask,bmpImage->blue_mask);
|
1998-11-06 12:03:00 +01:00
|
|
|
/* Transfer the pixels */
|
|
|
|
switch(descr->infoBpp)
|
|
|
|
{
|
|
|
|
case 1:
|
2002-06-01 01:06:46 +02:00
|
|
|
X11DRV_DIB_GetImageBits_1( descr->lines,(LPVOID)descr->bits,
|
1999-09-14 13:51:01 +02:00
|
|
|
descr->infoWidth, descr->width,
|
2002-06-01 01:06:46 +02:00
|
|
|
descr->colorMap, descr->palentry,
|
2000-12-06 21:15:43 +01:00
|
|
|
bmpImage, descr->dibpitch );
|
1998-11-06 12:03:00 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2004-03-30 22:39:09 +02:00
|
|
|
X11DRV_DIB_GetImageBits_4( descr->lines,(LPVOID)descr->bits,
|
|
|
|
descr->infoWidth, descr->width,
|
|
|
|
descr->colorMap, descr->palentry,
|
|
|
|
bmpImage, descr->dibpitch );
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
case 8:
|
2004-03-30 22:39:09 +02:00
|
|
|
X11DRV_DIB_GetImageBits_8( descr->lines, (LPVOID)descr->bits,
|
|
|
|
descr->infoWidth, descr->width,
|
|
|
|
descr->colorMap, descr->palentry,
|
|
|
|
bmpImage, descr->dibpitch );
|
|
|
|
break;
|
1998-11-06 12:03:00 +01:00
|
|
|
case 16:
|
2009-09-01 22:05:40 +02:00
|
|
|
X11DRV_DIB_GetImageBits_16( descr->physDev, descr->lines, (LPVOID)descr->bits,
|
1999-09-14 13:51:01 +02:00
|
|
|
descr->infoWidth,descr->width,
|
2000-11-26 00:51:59 +01:00
|
|
|
descr->palentry,
|
|
|
|
descr->rMask, descr->gMask, descr->bMask,
|
2000-12-06 21:15:43 +01:00
|
|
|
bmpImage, descr->dibpitch );
|
1998-11-06 12:03:00 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
2009-09-01 22:05:40 +02:00
|
|
|
X11DRV_DIB_GetImageBits_24( descr->physDev, descr->lines, (LPVOID)descr->bits,
|
1999-09-14 13:51:01 +02:00
|
|
|
descr->infoWidth,descr->width,
|
2001-10-17 21:41:54 +02:00
|
|
|
descr->palentry,
|
|
|
|
descr->rMask, descr->gMask, descr->bMask,
|
|
|
|
bmpImage, descr->dibpitch);
|
1998-11-06 12:03:00 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 32:
|
2009-09-01 22:05:40 +02:00
|
|
|
X11DRV_DIB_GetImageBits_32( descr->physDev, descr->lines, (LPVOID)descr->bits,
|
1999-09-14 13:51:01 +02:00
|
|
|
descr->infoWidth, descr->width,
|
2001-10-17 21:41:54 +02:00
|
|
|
descr->palentry,
|
|
|
|
descr->rMask, descr->gMask, descr->bMask,
|
|
|
|
bmpImage, descr->dibpitch);
|
1998-11-06 12:03:00 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("(%d): Invalid depth\n", descr->infoBpp );
|
1998-11-06 12:03:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-06 08:12:22 +02:00
|
|
|
if (old_data) bmpImage->data = old_data;
|
2008-08-29 13:34:11 +02:00
|
|
|
if (!descr->image) X11DRV_DIB_DestroyXImage( bmpImage );
|
1998-11-06 12:03:00 +01:00
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
/***********************************************************************
|
2005-04-11 20:54:30 +02:00
|
|
|
* X11DRV_DIB_DoCopyDIBSection
|
1999-04-01 10:16:08 +02:00
|
|
|
*/
|
2005-04-11 20:54:30 +02:00
|
|
|
static void X11DRV_DIB_DoCopyDIBSection(X_PHYSBITMAP *physBitmap, BOOL toDIB,
|
2000-12-22 02:07:57 +01:00
|
|
|
void *colorMap, int nColorMap,
|
2005-12-13 17:05:06 +01:00
|
|
|
Drawable dest, GC gc,
|
2000-12-22 02:07:57 +01:00
|
|
|
DWORD xSrc, DWORD ySrc,
|
|
|
|
DWORD xDest, DWORD yDest,
|
|
|
|
DWORD width, DWORD height)
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
2005-04-13 13:23:24 +02:00
|
|
|
DIBSECTION dibSection;
|
1999-09-03 18:49:17 +02:00
|
|
|
X11DRV_DIB_IMAGEBITS_DESCR descr;
|
2004-09-16 21:10:14 +02:00
|
|
|
int identity[2] = {0,1};
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-13 13:23:24 +02:00
|
|
|
if (!GetObjectW( physBitmap->hbitmap, sizeof(dibSection), &dibSection )) return;
|
1999-04-01 10:16:08 +02:00
|
|
|
|
2009-08-06 08:12:22 +02:00
|
|
|
descr.physDev = NULL;
|
|
|
|
descr.palentry = NULL;
|
|
|
|
descr.infoWidth = dibSection.dsBmih.biWidth;
|
|
|
|
descr.infoBpp = dibSection.dsBmih.biBitCount;
|
2010-03-01 12:39:54 +01:00
|
|
|
descr.lines = physBitmap->topdown ? -dibSection.dsBmih.biHeight : dibSection.dsBmih.biHeight;
|
2009-08-06 08:12:22 +02:00
|
|
|
descr.image = physBitmap->image;
|
|
|
|
descr.colorMap = colorMap;
|
|
|
|
descr.nColorMap = nColorMap;
|
|
|
|
descr.bits = dibSection.dsBm.bmBits;
|
2011-09-26 15:29:28 +02:00
|
|
|
descr.depth = physBitmap->depth;
|
|
|
|
descr.shifts = physBitmap->trueColor ? &physBitmap->color_shifts : NULL;
|
2005-04-13 13:23:24 +02:00
|
|
|
descr.compression = dibSection.dsBmih.biCompression;
|
2009-08-06 08:12:22 +02:00
|
|
|
descr.physBitmap = physBitmap;
|
2001-10-17 21:41:54 +02:00
|
|
|
|
2004-09-16 21:10:14 +02:00
|
|
|
if(descr.infoBpp == 1)
|
|
|
|
descr.colorMap = (void*)identity;
|
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
switch (descr.infoBpp)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
descr.rMask = descr.gMask = descr.bMask = 0;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
case 16:
|
2005-04-13 13:23:24 +02:00
|
|
|
descr.rMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[0] : 0x7c00;
|
|
|
|
descr.gMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[1] : 0x03e0;
|
|
|
|
descr.bMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[2] : 0x001f;
|
1999-09-03 18:49:17 +02:00
|
|
|
break;
|
|
|
|
|
2001-10-17 21:41:54 +02:00
|
|
|
case 24:
|
1999-09-03 18:49:17 +02:00
|
|
|
case 32:
|
2005-04-13 13:23:24 +02:00
|
|
|
descr.rMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[0] : 0xff0000;
|
|
|
|
descr.gMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[1] : 0x00ff00;
|
|
|
|
descr.bMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[2] : 0x0000ff;
|
1999-09-03 18:49:17 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
/* Hack for now */
|
2000-12-22 02:07:57 +01:00
|
|
|
descr.drawable = dest;
|
2005-12-13 17:05:06 +01:00
|
|
|
descr.gc = gc;
|
2000-12-22 02:07:57 +01:00
|
|
|
descr.xSrc = xSrc;
|
|
|
|
descr.ySrc = ySrc;
|
|
|
|
descr.xDest = xDest;
|
|
|
|
descr.yDest = yDest;
|
|
|
|
descr.width = width;
|
|
|
|
descr.height = height;
|
2004-03-30 22:39:09 +02:00
|
|
|
descr.sizeImage = 0;
|
|
|
|
|
2009-08-06 08:12:22 +02:00
|
|
|
descr.shm_mode = physBitmap->shm_mode;
|
2000-11-26 04:59:20 +01:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
2009-08-06 08:12:22 +02:00
|
|
|
if (physBitmap->shm_mode == X11DRV_SHM_PIXMAP && physBitmap->pixmap != dest)
|
|
|
|
{
|
2009-08-07 11:53:17 +02:00
|
|
|
descr.shm_mode = X11DRV_SHM_NONE;
|
2009-08-06 08:12:22 +02:00
|
|
|
}
|
2000-11-26 04:59:20 +01:00
|
|
|
#endif
|
2005-04-13 13:23:24 +02:00
|
|
|
descr.dibpitch = dibSection.dsBm.bmWidthBytes;
|
1999-04-01 10:16:08 +02:00
|
|
|
|
|
|
|
if (toDIB)
|
|
|
|
{
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("Copying from Pixmap to DIB bits\n");
|
2001-01-15 23:30:50 +01:00
|
|
|
X11DRV_DIB_GetImageBits( &descr );
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("Copying from DIB bits to Pixmap\n");
|
2001-01-15 23:30:50 +01:00
|
|
|
X11DRV_DIB_SetImageBits( &descr );
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-22 02:07:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_DoUpdateDIBSection
|
|
|
|
*/
|
2005-04-12 12:17:55 +02:00
|
|
|
static void X11DRV_DIB_DoUpdateDIBSection(X_PHYSBITMAP *physBitmap, BOOL toDIB)
|
2000-12-22 02:07:57 +01:00
|
|
|
{
|
2005-04-12 12:17:55 +02:00
|
|
|
BITMAP bitmap;
|
|
|
|
|
|
|
|
GetObjectW( physBitmap->hbitmap, sizeof(bitmap), &bitmap );
|
|
|
|
X11DRV_DIB_DoCopyDIBSection(physBitmap, toDIB,
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->colorMap, physBitmap->nColorMap,
|
2011-09-26 15:29:28 +02:00
|
|
|
physBitmap->pixmap, get_bitmap_gc(physBitmap->depth),
|
2005-12-13 17:05:06 +01:00
|
|
|
0, 0, 0, 0, bitmap.bmWidth, bitmap.bmHeight);
|
2000-12-22 02:07:57 +01:00
|
|
|
}
|
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_FaultHandler
|
|
|
|
*/
|
2005-04-20 18:24:13 +02:00
|
|
|
static LONG CALLBACK X11DRV_DIB_FaultHandler( PEXCEPTION_POINTERS ep )
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
2005-04-20 18:24:13 +02:00
|
|
|
X_PHYSBITMAP *physBitmap = NULL;
|
|
|
|
BOOL found = FALSE;
|
2005-04-20 20:45:28 +02:00
|
|
|
BYTE *addr;
|
2005-04-20 18:24:13 +02:00
|
|
|
struct list *ptr;
|
2008-01-24 10:21:17 +01:00
|
|
|
const size_t pagemask = getpagesize() - 1;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
2005-04-20 18:24:13 +02:00
|
|
|
if (ep->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
|
2005-04-20 20:45:28 +02:00
|
|
|
addr = (BYTE *)ep->ExceptionRecord->ExceptionInformation[1];
|
2005-04-20 18:24:13 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&dibs_cs);
|
|
|
|
LIST_FOR_EACH( ptr, &dibs_list )
|
|
|
|
{
|
|
|
|
physBitmap = LIST_ENTRY( ptr, X_PHYSBITMAP, entry );
|
2008-01-24 10:21:17 +01:00
|
|
|
if ((physBitmap->base <= addr) &&
|
|
|
|
(addr < physBitmap->base + ((physBitmap->size + pagemask) & ~pagemask)))
|
2005-04-20 18:24:13 +02:00
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&dibs_cs);
|
|
|
|
|
|
|
|
if (!found) return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
|
2008-01-24 10:21:17 +01:00
|
|
|
if (addr >= physBitmap->base + physBitmap->size)
|
|
|
|
WARN( "%p: access to %p beyond the end of the DIB\n", physBitmap->hbitmap, addr );
|
|
|
|
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_Lock( physBitmap, DIB_Status_None );
|
2006-09-20 11:27:53 +02:00
|
|
|
if (ep->ExceptionRecord->ExceptionInformation[0] == EXCEPTION_WRITE_FAULT) {
|
2005-04-20 18:24:13 +02:00
|
|
|
/* the app tried to write the DIB bits */
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_Coerce( physBitmap, DIB_Status_AppMod);
|
2005-04-20 18:24:13 +02:00
|
|
|
} else {
|
|
|
|
/* the app tried to read the DIB bits */
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_Coerce( physBitmap, DIB_Status_InSync);
|
2005-04-20 18:24:13 +02:00
|
|
|
}
|
|
|
|
X11DRV_DIB_Unlock( physBitmap, TRUE );
|
|
|
|
|
|
|
|
return EXCEPTION_CONTINUE_EXECUTION;
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-12-06 21:15:43 +01:00
|
|
|
* X11DRV_DIB_Coerce
|
1999-04-01 10:16:08 +02:00
|
|
|
*/
|
2007-10-12 17:44:13 +02:00
|
|
|
static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req)
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
2005-04-13 13:23:24 +02:00
|
|
|
INT ret = DIB_Status_None;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
2005-04-13 13:23:24 +02:00
|
|
|
if (!physBitmap->image) return ret; /* not a DIB section */
|
|
|
|
EnterCriticalSection(&physBitmap->lock);
|
|
|
|
ret = physBitmap->status;
|
2000-12-06 21:15:43 +01:00
|
|
|
switch (req) {
|
|
|
|
case DIB_Status_GdiMod:
|
|
|
|
/* GDI access - request to draw on pixmap */
|
2005-04-13 13:23:24 +02:00
|
|
|
switch (physBitmap->status)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
1999-04-01 10:16:08 +02:00
|
|
|
default:
|
2000-12-06 21:15:43 +01:00
|
|
|
case DIB_Status_None:
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->p_status = DIB_Status_GdiMod;
|
2005-04-12 12:17:55 +02:00
|
|
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, FALSE );
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
|
|
|
case DIB_Status_GdiMod:
|
|
|
|
TRACE("GdiMod requested in status GdiMod\n" );
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->p_status = DIB_Status_GdiMod;
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
|
|
|
case DIB_Status_InSync:
|
|
|
|
TRACE("GdiMod requested in status InSync\n" );
|
2005-04-11 20:54:30 +02:00
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->status = DIB_Status_GdiMod;
|
|
|
|
physBitmap->p_status = DIB_Status_InSync;
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
|
|
|
case DIB_Status_AppMod:
|
|
|
|
TRACE("GdiMod requested in status AppMod\n" );
|
2007-10-12 17:44:13 +02:00
|
|
|
/* make it readonly to avoid app changing data while we copy */
|
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
|
|
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, FALSE );
|
2005-04-11 20:54:30 +02:00
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->p_status = DIB_Status_AppMod;
|
|
|
|
physBitmap->status = DIB_Status_GdiMod;
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIB_Status_InSync:
|
|
|
|
/* App access - request access to read DIB surface */
|
|
|
|
/* (typically called from signal handler) */
|
2005-04-13 13:23:24 +02:00
|
|
|
switch (physBitmap->status)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
1999-04-01 10:16:08 +02:00
|
|
|
default:
|
2000-12-06 21:15:43 +01:00
|
|
|
case DIB_Status_None:
|
|
|
|
/* shouldn't happen from signal handler */
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
|
|
|
case DIB_Status_GdiMod:
|
|
|
|
TRACE("InSync requested in status GdiMod\n" );
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
|
|
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
2005-04-11 20:54:30 +02:00
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->status = DIB_Status_InSync;
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
|
|
|
case DIB_Status_InSync:
|
|
|
|
TRACE("InSync requested in status InSync\n" );
|
|
|
|
/* shouldn't happen from signal handler */
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
|
|
|
case DIB_Status_AppMod:
|
|
|
|
TRACE("InSync requested in status AppMod\n" );
|
|
|
|
/* no reason to do anything here, and this
|
|
|
|
* shouldn't happen from signal handler */
|
1999-04-01 10:16:08 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIB_Status_AppMod:
|
|
|
|
/* App access - request access to write DIB surface */
|
|
|
|
/* (typically called from signal handler) */
|
2005-04-13 13:23:24 +02:00
|
|
|
switch (physBitmap->status)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case DIB_Status_None:
|
|
|
|
/* shouldn't happen from signal handler */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIB_Status_GdiMod:
|
|
|
|
TRACE("AppMod requested in status GdiMod\n" );
|
2005-04-11 20:54:30 +02:00
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->status = DIB_Status_AppMod;
|
2001-04-16 21:05:37 +02:00
|
|
|
break;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
|
|
|
case DIB_Status_InSync:
|
|
|
|
TRACE("AppMod requested in status InSync\n" );
|
2005-04-11 20:54:30 +02:00
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->status = DIB_Status_AppMod;
|
2000-12-06 21:15:43 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DIB_Status_AppMod:
|
|
|
|
TRACE("AppMod requested in status AppMod\n" );
|
|
|
|
/* shouldn't happen from signal handler */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* it is up to the caller to do the copy/conversion, probably
|
|
|
|
* using the return value to decide where to copy from */
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
2005-04-13 13:23:24 +02:00
|
|
|
LeaveCriticalSection(&physBitmap->lock);
|
|
|
|
return ret;
|
2000-12-06 21:15:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_Lock
|
|
|
|
*/
|
2011-07-15 14:05:25 +02:00
|
|
|
INT X11DRV_DIB_Lock(X_PHYSBITMAP *physBitmap, INT req)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
2005-04-13 13:23:24 +02:00
|
|
|
INT ret = DIB_Status_None;
|
2000-12-06 21:15:43 +01:00
|
|
|
|
2005-04-13 13:23:24 +02:00
|
|
|
if (!physBitmap->image) return ret; /* not a DIB section */
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE("Locking %p from thread %04x\n", physBitmap->hbitmap, GetCurrentThreadId());
|
2005-04-13 13:23:24 +02:00
|
|
|
EnterCriticalSection(&physBitmap->lock);
|
|
|
|
ret = physBitmap->status;
|
2000-12-06 21:15:43 +01:00
|
|
|
if (req != DIB_Status_None)
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_Coerce(physBitmap, req);
|
2005-04-13 13:23:24 +02:00
|
|
|
return ret;
|
2000-07-29 01:59:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-12-06 21:15:43 +01:00
|
|
|
* X11DRV_DIB_Unlock
|
2000-07-29 01:59:06 +02:00
|
|
|
*/
|
2011-07-15 14:05:25 +02:00
|
|
|
void X11DRV_DIB_Unlock(X_PHYSBITMAP *physBitmap, BOOL commit)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
2005-04-13 13:23:24 +02:00
|
|
|
if (!physBitmap->image) return; /* not a DIB section */
|
|
|
|
switch (physBitmap->status)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case DIB_Status_None:
|
|
|
|
/* in case anyone is wondering, this is the "signal handler doesn't
|
|
|
|
* work" case, where we always have to be ready for app access */
|
|
|
|
if (commit) {
|
2005-04-13 13:23:24 +02:00
|
|
|
switch (physBitmap->p_status)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
|
|
|
case DIB_Status_GdiMod:
|
|
|
|
TRACE("Unlocking and syncing from GdiMod\n" );
|
2005-04-12 12:17:55 +02:00
|
|
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
2000-12-06 21:15:43 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE("Unlocking without needing to sync\n" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else TRACE("Unlocking with no changes\n");
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->p_status = DIB_Status_None;
|
2000-12-06 21:15:43 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DIB_Status_GdiMod:
|
|
|
|
TRACE("Unlocking in status GdiMod\n" );
|
|
|
|
/* DIB was protected in Coerce */
|
|
|
|
if (!commit) {
|
|
|
|
/* no commit, revert to InSync if applicable */
|
2005-04-13 13:23:24 +02:00
|
|
|
if ((physBitmap->p_status == DIB_Status_InSync) ||
|
|
|
|
(physBitmap->p_status == DIB_Status_AppMod)) {
|
2005-04-11 20:54:30 +02:00
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
2005-04-13 13:23:24 +02:00
|
|
|
physBitmap->status = DIB_Status_InSync;
|
2000-12-06 21:15:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIB_Status_InSync:
|
|
|
|
TRACE("Unlocking in status InSync\n" );
|
|
|
|
/* DIB was already protected in Coerce */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIB_Status_AppMod:
|
|
|
|
TRACE("Unlocking in status AppMod\n" );
|
|
|
|
/* DIB was already protected in Coerce */
|
|
|
|
/* this case is ordinary only called from the signal handler,
|
|
|
|
* so we don't bother to check for !commit */
|
|
|
|
break;
|
|
|
|
}
|
2005-04-13 13:23:24 +02:00
|
|
|
LeaveCriticalSection(&physBitmap->lock);
|
2005-04-12 12:17:55 +02:00
|
|
|
TRACE("Unlocked %p\n", physBitmap->hbitmap);
|
2000-12-06 21:15:43 +01:00
|
|
|
}
|
|
|
|
|
2001-04-16 21:05:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_CoerceDIBSection
|
|
|
|
*/
|
2007-10-12 17:44:13 +02:00
|
|
|
INT X11DRV_CoerceDIBSection(X11DRV_PDEVICE *physDev, INT req)
|
2001-04-16 21:05:37 +02:00
|
|
|
{
|
2005-04-12 13:59:48 +02:00
|
|
|
if (!physDev || !physDev->bitmap) return DIB_Status_None;
|
2007-10-12 17:44:13 +02:00
|
|
|
return X11DRV_DIB_Coerce(physDev->bitmap, req);
|
2001-04-16 21:05:37 +02:00
|
|
|
}
|
|
|
|
|
2000-12-06 21:15:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_LockDIBSection
|
|
|
|
*/
|
2007-10-12 17:44:13 +02:00
|
|
|
INT X11DRV_LockDIBSection(X11DRV_PDEVICE *physDev, INT req)
|
2000-12-06 21:15:43 +01:00
|
|
|
{
|
2005-04-12 13:59:48 +02:00
|
|
|
if (!physDev || !physDev->bitmap) return DIB_Status_None;
|
2007-10-12 17:44:13 +02:00
|
|
|
return X11DRV_DIB_Lock(physDev->bitmap, req);
|
2000-12-06 21:15:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_UnlockDIBSection
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
void X11DRV_UnlockDIBSection(X11DRV_PDEVICE *physDev, BOOL commit)
|
2000-07-29 01:59:06 +02:00
|
|
|
{
|
2005-04-12 13:59:48 +02:00
|
|
|
if (!physDev || !physDev->bitmap) return;
|
|
|
|
X11DRV_DIB_Unlock(physDev->bitmap, commit);
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 21:51:04 +02:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
1999-09-03 18:49:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XShmErrorHandler
|
|
|
|
*
|
|
|
|
*/
|
2002-04-24 23:32:11 +02:00
|
|
|
static int XShmErrorHandler( Display *dpy, XErrorEvent *event, void *arg )
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2002-04-24 23:32:11 +02:00
|
|
|
return 1; /* FIXME: should check event contents */
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XShmCreateImage
|
|
|
|
*
|
|
|
|
*/
|
2001-05-11 02:17:47 +02:00
|
|
|
static XImage *X11DRV_XShmCreateImage( int width, int height, int bpp,
|
|
|
|
XShmSegmentInfo* shminfo)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
XImage *image;
|
|
|
|
|
|
|
|
image = XShmCreateImage(gdi_display, visual, bpp, ZPixmap, NULL, shminfo, width, height);
|
|
|
|
if (image)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
shminfo->shmid = shmget(IPC_PRIVATE, image->bytes_per_line * height,
|
1999-09-03 18:49:17 +02:00
|
|
|
IPC_CREAT|0700);
|
|
|
|
if( shminfo->shmid != -1 )
|
|
|
|
{
|
2009-08-06 08:12:22 +02:00
|
|
|
shminfo->shmaddr = shmat( shminfo->shmid, 0, 0 );
|
1999-10-13 17:42:04 +02:00
|
|
|
if( shminfo->shmaddr != (char*)-1 )
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2002-04-24 23:32:11 +02:00
|
|
|
BOOL ok;
|
|
|
|
|
1999-09-03 18:49:17 +02:00
|
|
|
shminfo->readOnly = FALSE;
|
2002-04-24 23:32:11 +02:00
|
|
|
X11DRV_expect_error( gdi_display, XShmErrorHandler, NULL );
|
|
|
|
ok = (XShmAttach( gdi_display, shminfo ) != 0);
|
2003-11-09 01:34:43 +01:00
|
|
|
XSync( gdi_display, False );
|
2002-04-24 23:32:11 +02:00
|
|
|
if (X11DRV_check_error()) ok = FALSE;
|
|
|
|
if (ok)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2002-04-24 23:32:11 +02:00
|
|
|
shmctl(shminfo->shmid, IPC_RMID, 0);
|
|
|
|
return image; /* Success! */
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2003-08-18 22:11:29 +02:00
|
|
|
/* An error occurred */
|
1999-09-03 18:49:17 +02:00
|
|
|
shmdt(shminfo->shmaddr);
|
|
|
|
}
|
|
|
|
shmctl(shminfo->shmid, IPC_RMID, 0);
|
2005-04-22 21:06:41 +02:00
|
|
|
shminfo->shmid = -1;
|
2001-05-11 02:17:47 +02:00
|
|
|
}
|
|
|
|
XFlush(gdi_display);
|
|
|
|
XDestroyImage(image);
|
|
|
|
image = NULL;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2001-05-11 02:17:47 +02:00
|
|
|
return image;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
|
2011-02-01 20:47:22 +01:00
|
|
|
static Bool X11DRV_DIB_QueryXShm( Bool *pixmaps )
|
|
|
|
{
|
|
|
|
static Bool have_xshm, have_xshm_pixmaps;
|
|
|
|
static BOOL initialized;
|
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
{
|
|
|
|
int major, minor;
|
|
|
|
|
|
|
|
have_xshm = XShmQueryVersion( gdi_display, &major, &minor, &have_xshm_pixmaps );
|
|
|
|
initialized = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pixmaps = have_xshm_pixmaps;
|
|
|
|
return have_xshm;
|
|
|
|
}
|
2011-10-27 20:25:26 +02:00
|
|
|
#endif /* HAVE_LIBXXSHM */
|
1999-04-01 10:16:08 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2005-04-13 16:45:27 +02:00
|
|
|
* X11DRV_CreateDIBSection (X11DRV.@)
|
1999-04-01 10:16:08 +02:00
|
|
|
*/
|
2011-09-02 15:53:10 +02:00
|
|
|
HBITMAP X11DRV_CreateDIBSection( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *bmi, UINT usage )
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
2011-07-08 15:55:11 +02:00
|
|
|
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
|
2005-04-13 16:45:27 +02:00
|
|
|
X_PHYSBITMAP *physBitmap;
|
|
|
|
DIBSECTION dib;
|
2009-08-06 08:12:22 +02:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
|
|
|
Bool pixmaps;
|
|
|
|
#endif
|
1999-09-03 18:49:17 +02:00
|
|
|
|
2005-04-13 16:45:27 +02:00
|
|
|
if (!(physBitmap = X11DRV_init_phys_bitmap( hbitmap ))) return 0;
|
2011-08-04 18:21:37 +02:00
|
|
|
physBitmap->topdown = bmi->bmiHeader.biHeight < 0;
|
2005-04-13 16:45:27 +02:00
|
|
|
physBitmap->status = DIB_Status_None;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-13 16:45:27 +02:00
|
|
|
GetObjectW( hbitmap, sizeof(dib), &dib );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-13 16:45:27 +02:00
|
|
|
/* create color map */
|
|
|
|
if (dib.dsBm.bmBitsPixel <= 8)
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
2006-03-02 13:13:28 +01:00
|
|
|
physBitmap->colorMap = X11DRV_DIB_BuildColorMap( physDev,
|
2005-04-13 16:45:27 +02:00
|
|
|
usage, dib.dsBm.bmBitsPixel, bmi,
|
|
|
|
&physBitmap->nColorMap );
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-04-06 19:07:25 +02:00
|
|
|
if (!X11DRV_XRender_SetPhysBitmapDepth( physBitmap, dib.dsBm.bmBitsPixel, &dib ))
|
2009-09-01 21:48:29 +02:00
|
|
|
{
|
2009-09-26 14:52:46 +02:00
|
|
|
if (dib.dsBm.bmBitsPixel == 1)
|
|
|
|
{
|
2011-09-26 15:29:28 +02:00
|
|
|
physBitmap->depth = 1;
|
2009-09-26 14:52:46 +02:00
|
|
|
physBitmap->trueColor = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-26 15:29:28 +02:00
|
|
|
physBitmap->depth = screen_depth;
|
|
|
|
physBitmap->color_shifts = X11DRV_PALETTE_default_shifts;
|
2009-09-26 14:52:46 +02:00
|
|
|
physBitmap->trueColor = (visual->class == TrueColor || visual->class == DirectColor);
|
|
|
|
}
|
2009-09-01 21:48:29 +02:00
|
|
|
}
|
2009-09-26 14:52:46 +02:00
|
|
|
|
|
|
|
/* create pixmap and X image */
|
|
|
|
wine_tsx11_lock();
|
2000-11-26 04:59:20 +01:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
2005-04-13 16:45:27 +02:00
|
|
|
physBitmap->shminfo.shmid = -1;
|
2009-08-06 08:12:22 +02:00
|
|
|
|
2011-02-01 20:47:22 +01:00
|
|
|
if (X11DRV_DIB_QueryXShm( &pixmaps )
|
2009-08-06 08:12:22 +02:00
|
|
|
&& (physBitmap->image = X11DRV_XShmCreateImage( dib.dsBm.bmWidth, dib.dsBm.bmHeight,
|
2011-09-26 15:29:28 +02:00
|
|
|
physBitmap->depth, &physBitmap->shminfo )))
|
2009-08-06 08:12:22 +02:00
|
|
|
{
|
|
|
|
if (pixmaps)
|
|
|
|
{
|
|
|
|
physBitmap->shm_mode = X11DRV_SHM_PIXMAP;
|
|
|
|
physBitmap->image->data = HeapAlloc( GetProcessHeap(), 0,
|
|
|
|
dib.dsBm.bmHeight * physBitmap->image->bytes_per_line );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
physBitmap->shm_mode = X11DRV_SHM_IMAGE;
|
|
|
|
physBitmap->image->data = physBitmap->shminfo.shmaddr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-11-26 04:59:20 +01:00
|
|
|
#endif
|
2009-08-06 08:12:22 +02:00
|
|
|
{
|
|
|
|
physBitmap->shm_mode = X11DRV_SHM_NONE;
|
2005-04-13 16:45:27 +02:00
|
|
|
physBitmap->image = X11DRV_DIB_CreateXImage( dib.dsBm.bmWidth, dib.dsBm.bmHeight,
|
2011-09-26 15:29:28 +02:00
|
|
|
physBitmap->depth );
|
2009-08-06 08:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXXSHM
|
|
|
|
if (physBitmap->shm_mode == X11DRV_SHM_PIXMAP)
|
|
|
|
{
|
|
|
|
TRACE("Creating shared pixmap for bmp %p.\n", physBitmap->hbitmap);
|
|
|
|
physBitmap->pixmap = XShmCreatePixmap( gdi_display, root_window,
|
|
|
|
physBitmap->shminfo.shmaddr, &physBitmap->shminfo,
|
|
|
|
dib.dsBm.bmWidth, dib.dsBm.bmHeight,
|
2011-09-26 15:29:28 +02:00
|
|
|
physBitmap->depth );
|
2009-08-06 08:12:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
physBitmap->pixmap = XCreatePixmap( gdi_display, root_window, dib.dsBm.bmWidth,
|
2011-09-26 15:29:28 +02:00
|
|
|
dib.dsBm.bmHeight, physBitmap->depth );
|
2009-08-06 08:12:22 +02:00
|
|
|
}
|
|
|
|
|
2005-04-13 16:45:27 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
if (!physBitmap->pixmap || !physBitmap->image) return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-26 14:52:46 +02:00
|
|
|
if (physBitmap->trueColor)
|
|
|
|
{
|
2011-09-26 15:29:28 +02:00
|
|
|
ColorShifts *shifts = &physBitmap->color_shifts;
|
2009-09-26 14:52:46 +02:00
|
|
|
|
|
|
|
/* When XRender is around and used, we also support dibsections in other formats like 16-bit. In these
|
|
|
|
* cases we need to override the mask of XImages. The reason is that during XImage creation the masks are
|
|
|
|
* derived from a 24-bit visual (no 16-bit ones are around when X runs at 24-bit). SetImageBits and other
|
|
|
|
* functions rely on the color masks for proper color conversion, so we need to override the masks here. */
|
|
|
|
physBitmap->image->red_mask = shifts->physicalRed.max << shifts->physicalRed.shift;
|
|
|
|
physBitmap->image->green_mask = shifts->physicalGreen.max << shifts->physicalGreen.shift;
|
|
|
|
physBitmap->image->blue_mask = shifts->physicalBlue.max << shifts->physicalBlue.shift;
|
|
|
|
}
|
|
|
|
|
2005-04-13 16:45:27 +02:00
|
|
|
/* install fault handler */
|
|
|
|
InitializeCriticalSection( &physBitmap->lock );
|
2007-03-10 22:11:01 +01:00
|
|
|
physBitmap->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": X_PHYSBITMAP.lock");
|
2005-04-20 18:24:13 +02:00
|
|
|
|
|
|
|
physBitmap->base = dib.dsBm.bmBits;
|
|
|
|
physBitmap->size = dib.dsBmih.biSizeImage;
|
|
|
|
physBitmap->status = DIB_Status_AppMod;
|
|
|
|
|
|
|
|
if (!dibs_handler)
|
|
|
|
dibs_handler = AddVectoredExceptionHandler( TRUE, X11DRV_DIB_FaultHandler );
|
|
|
|
EnterCriticalSection( &dibs_cs );
|
|
|
|
list_add_head( &dibs_list, &physBitmap->entry );
|
|
|
|
LeaveCriticalSection( &dibs_cs );
|
|
|
|
|
|
|
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
1999-04-01 10:16:08 +02:00
|
|
|
|
2005-04-13 16:45:27 +02:00
|
|
|
return hbitmap;
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_DeleteDIBSection
|
|
|
|
*/
|
2005-04-13 13:23:24 +02:00
|
|
|
void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap, DIBSECTION *dib)
|
1999-04-01 10:16:08 +02:00
|
|
|
{
|
2005-04-20 18:24:13 +02:00
|
|
|
BOOL last;
|
|
|
|
|
|
|
|
EnterCriticalSection( &dibs_cs );
|
|
|
|
list_remove( &physBitmap->entry );
|
|
|
|
last = list_empty( &dibs_list );
|
|
|
|
LeaveCriticalSection( &dibs_cs );
|
|
|
|
|
|
|
|
if (last)
|
|
|
|
{
|
|
|
|
RemoveVectoredExceptionHandler( dibs_handler );
|
|
|
|
dibs_handler = NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-13 13:23:24 +02:00
|
|
|
if (dib->dshSection)
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_Coerce(physBitmap, DIB_Status_InSync);
|
2005-03-01 11:43:19 +01:00
|
|
|
|
2005-04-13 13:23:24 +02:00
|
|
|
if (physBitmap->image)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2002-09-24 05:17:31 +02:00
|
|
|
wine_tsx11_lock();
|
2000-11-26 04:59:20 +01:00
|
|
|
#ifdef HAVE_LIBXXSHM
|
2005-04-13 13:23:24 +02:00
|
|
|
if (physBitmap->shminfo.shmid != -1)
|
1999-09-03 18:49:17 +02:00
|
|
|
{
|
2005-04-13 13:23:24 +02:00
|
|
|
XShmDetach( gdi_display, &(physBitmap->shminfo) );
|
2009-08-06 08:12:22 +02:00
|
|
|
if (physBitmap->shm_mode == X11DRV_SHM_PIXMAP) X11DRV_DIB_DestroyXImage( physBitmap->image );
|
|
|
|
else XDestroyImage( physBitmap->image );
|
2005-04-13 13:23:24 +02:00
|
|
|
shmdt( physBitmap->shminfo.shmaddr );
|
|
|
|
physBitmap->shminfo.shmid = -1;
|
2009-08-06 08:12:22 +02:00
|
|
|
physBitmap->shm_mode = X11DRV_SHM_NONE;
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
|
|
|
else
|
2000-11-26 04:59:20 +01:00
|
|
|
#endif
|
2008-08-29 13:34:11 +02:00
|
|
|
X11DRV_DIB_DestroyXImage( physBitmap->image );
|
2002-09-24 05:17:31 +02:00
|
|
|
wine_tsx11_unlock();
|
1999-09-03 18:49:17 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-13 13:23:24 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, physBitmap->colorMap);
|
2007-03-10 22:11:01 +01:00
|
|
|
physBitmap->lock.DebugInfo->Spare[0] = 0;
|
2005-04-13 13:23:24 +02:00
|
|
|
DeleteCriticalSection(&physBitmap->lock);
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
|
2000-11-25 22:42:00 +01:00
|
|
|
/***********************************************************************
|
2002-04-03 04:37:09 +02:00
|
|
|
* SetDIBColorTable (X11DRV.@)
|
2000-11-25 22:42:00 +01:00
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
UINT X11DRV_SetDIBColorTable( PHYSDEV dev, UINT start, UINT count, const RGBQUAD *colors )
|
2000-11-25 22:42:00 +01:00
|
|
|
{
|
2011-07-08 15:55:11 +02:00
|
|
|
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
|
2005-04-13 13:23:24 +02:00
|
|
|
DIBSECTION dib;
|
2002-03-28 23:22:05 +01:00
|
|
|
UINT ret = 0;
|
2005-04-12 13:59:48 +02:00
|
|
|
X_PHYSBITMAP *physBitmap = physDev->bitmap;
|
2002-03-28 23:22:05 +01:00
|
|
|
|
2005-03-31 21:13:03 +02:00
|
|
|
if (!physBitmap) return 0;
|
2005-04-13 13:23:24 +02:00
|
|
|
GetObjectW( physBitmap->hbitmap, sizeof(dib), &dib );
|
2002-03-28 23:22:05 +01:00
|
|
|
|
2005-04-13 13:23:24 +02:00
|
|
|
if (physBitmap->colorMap && start < physBitmap->nColorMap) {
|
2002-03-28 23:22:05 +01:00
|
|
|
UINT end = count + start;
|
2005-04-13 13:23:24 +02:00
|
|
|
if (end > physBitmap->nColorMap) end = physBitmap->nColorMap;
|
2002-03-28 23:22:05 +01:00
|
|
|
/*
|
|
|
|
* Changing color table might change the mapping between
|
|
|
|
* DIB colors and X11 colors and thus alter the visible state
|
|
|
|
* of the bitmap object.
|
|
|
|
*/
|
2006-03-02 13:13:28 +01:00
|
|
|
/*
|
|
|
|
* FIXME we need to recalculate the pen, brush, text and bkgnd pixels here,
|
|
|
|
* at least for a 1 bpp dibsection
|
|
|
|
*/
|
2007-10-12 17:44:13 +02:00
|
|
|
X11DRV_DIB_Lock( physBitmap, DIB_Status_AppMod );
|
2005-04-13 13:23:24 +02:00
|
|
|
X11DRV_DIB_GenColorMap( physDev, physBitmap->colorMap, DIB_RGB_COLORS,
|
2011-08-04 13:22:53 +02:00
|
|
|
dib.dsBm.bmBitsPixel, colors, start, end );
|
2005-04-12 12:17:55 +02:00
|
|
|
X11DRV_DIB_Unlock( physBitmap, TRUE );
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = end - start;
|
|
|
|
}
|
|
|
|
return ret;
|
2000-11-25 22:42:00 +01:00
|
|
|
}
|
|
|
|
|
2004-01-14 00:31:46 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DIB_CreateDIBFromBitmap
|
|
|
|
*
|
|
|
|
* Allocates a packed DIB and copies the bitmap data into it.
|
|
|
|
*/
|
|
|
|
HGLOBAL X11DRV_DIB_CreateDIBFromBitmap(HDC hdc, HBITMAP hBmp)
|
|
|
|
{
|
|
|
|
BITMAP bmp;
|
|
|
|
HGLOBAL hPackedDIB;
|
|
|
|
LPBYTE pPackedDIB;
|
|
|
|
LPBITMAPINFOHEADER pbmiHeader;
|
2004-08-12 01:45:34 +02:00
|
|
|
unsigned int cDataSize, cPackedSize, OffsetBits;
|
|
|
|
int nLinesCopied;
|
2004-01-14 00:31:46 +01:00
|
|
|
|
|
|
|
if (!GetObjectW( hBmp, sizeof(bmp), &bmp )) return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A packed DIB contains a BITMAPINFO structure followed immediately by
|
|
|
|
* an optional color palette and the pixel data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Calculate the size of the packed DIB */
|
|
|
|
cDataSize = X11DRV_DIB_GetDIBWidthBytes( bmp.bmWidth, bmp.bmBitsPixel ) * abs( bmp.bmHeight );
|
|
|
|
cPackedSize = sizeof(BITMAPINFOHEADER)
|
|
|
|
+ ( (bmp.bmBitsPixel <= 8) ? (sizeof(RGBQUAD) * (1 << bmp.bmBitsPixel)) : 0 )
|
|
|
|
+ cDataSize;
|
|
|
|
/* Get the offset to the bits */
|
|
|
|
OffsetBits = cPackedSize - cDataSize;
|
|
|
|
|
|
|
|
/* Allocate the packed DIB */
|
|
|
|
TRACE("\tAllocating packed DIB of size %d\n", cPackedSize);
|
|
|
|
hPackedDIB = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE /*| GMEM_ZEROINIT*/,
|
|
|
|
cPackedSize );
|
|
|
|
if ( !hPackedDIB )
|
|
|
|
{
|
|
|
|
WARN("Could not allocate packed DIB!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A packed DIB starts with a BITMAPINFOHEADER */
|
|
|
|
pPackedDIB = GlobalLock(hPackedDIB);
|
|
|
|
pbmiHeader = (LPBITMAPINFOHEADER)pPackedDIB;
|
|
|
|
|
|
|
|
/* Init the BITMAPINFOHEADER */
|
|
|
|
pbmiHeader->biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
pbmiHeader->biWidth = bmp.bmWidth;
|
|
|
|
pbmiHeader->biHeight = bmp.bmHeight;
|
|
|
|
pbmiHeader->biPlanes = 1;
|
|
|
|
pbmiHeader->biBitCount = bmp.bmBitsPixel;
|
|
|
|
pbmiHeader->biCompression = BI_RGB;
|
|
|
|
pbmiHeader->biSizeImage = 0;
|
|
|
|
pbmiHeader->biXPelsPerMeter = pbmiHeader->biYPelsPerMeter = 0;
|
|
|
|
pbmiHeader->biClrUsed = 0;
|
|
|
|
pbmiHeader->biClrImportant = 0;
|
|
|
|
|
|
|
|
/* Retrieve the DIB bits from the bitmap and fill in the
|
|
|
|
* DIB color table if present */
|
|
|
|
|
|
|
|
nLinesCopied = GetDIBits(hdc, /* Handle to device context */
|
|
|
|
hBmp, /* Handle to bitmap */
|
|
|
|
0, /* First scan line to set in dest bitmap */
|
|
|
|
bmp.bmHeight, /* Number of scan lines to copy */
|
|
|
|
pPackedDIB + OffsetBits, /* [out] Address of array for bitmap bits */
|
|
|
|
(LPBITMAPINFO) pbmiHeader, /* [out] Address of BITMAPINFO structure */
|
|
|
|
0); /* RGB or palette index */
|
|
|
|
GlobalUnlock(hPackedDIB);
|
|
|
|
|
|
|
|
/* Cleanup if GetDIBits failed */
|
|
|
|
if (nLinesCopied != bmp.bmHeight)
|
|
|
|
{
|
|
|
|
TRACE("\tGetDIBits returned %d. Actual lines=%d\n", nLinesCopied, bmp.bmHeight);
|
|
|
|
GlobalFree(hPackedDIB);
|
|
|
|
hPackedDIB = 0;
|
|
|
|
}
|
|
|
|
return hPackedDIB;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* X11DRV_DIB_CreateDIBFromPixmap
|
|
|
|
*
|
|
|
|
* Allocates a packed DIB and copies the Pixmap data into it.
|
2005-03-28 12:06:06 +02:00
|
|
|
* The Pixmap passed in is deleted after the conversion.
|
1999-09-20 17:42:47 +02:00
|
|
|
*/
|
2005-03-28 12:06:06 +02:00
|
|
|
HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc)
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2005-03-28 12:06:06 +02:00
|
|
|
HDC hdcMem;
|
2005-04-11 20:54:30 +02:00
|
|
|
X_PHYSBITMAP *physBitmap;
|
2008-05-01 17:43:33 +02:00
|
|
|
Pixmap orig_pixmap;
|
|
|
|
HBITMAP hBmp = 0;
|
1999-10-13 17:42:04 +02:00
|
|
|
HGLOBAL hPackedDIB = 0;
|
2005-03-28 12:06:06 +02:00
|
|
|
Window root;
|
|
|
|
int x,y; /* Unused */
|
|
|
|
unsigned border_width; /* Unused */
|
|
|
|
unsigned int depth, width, height;
|
1999-09-20 17:42:47 +02:00
|
|
|
|
2005-03-28 12:06:06 +02:00
|
|
|
/* Get the Pixmap dimensions and bit depth */
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!XGetGeometry(gdi_display, pixmap, &root, &x, &y, &width, &height,
|
|
|
|
&border_width, &depth)) depth = 0;
|
|
|
|
wine_tsx11_unlock();
|
2011-07-06 12:38:31 +02:00
|
|
|
if (!pixmap_formats[depth]) return 0;
|
2005-03-28 12:06:06 +02:00
|
|
|
|
|
|
|
TRACE("\tPixmap properties: width=%d, height=%d, depth=%d\n",
|
|
|
|
width, height, depth);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create an HBITMAP with the same dimensions and BPP as the pixmap,
|
|
|
|
* and make it a container for the pixmap passed.
|
|
|
|
*/
|
2011-07-06 12:38:31 +02:00
|
|
|
if (!(hBmp = CreateBitmap( width, height, 1, pixmap_formats[depth]->bits_per_pixel, NULL ))) return 0;
|
2005-03-28 12:06:06 +02:00
|
|
|
|
|
|
|
/* force bitmap to be owned by a screen DC */
|
|
|
|
hdcMem = CreateCompatibleDC( hdc );
|
2008-05-01 17:43:33 +02:00
|
|
|
SelectObject( hdcMem, SelectObject( hdcMem, hBmp ));
|
|
|
|
DeleteDC( hdcMem );
|
2005-03-28 12:06:06 +02:00
|
|
|
|
2005-04-11 20:54:30 +02:00
|
|
|
physBitmap = X11DRV_get_phys_bitmap( hBmp );
|
|
|
|
|
2008-05-01 17:43:33 +02:00
|
|
|
/* swap the new pixmap in */
|
|
|
|
orig_pixmap = physBitmap->pixmap;
|
2005-04-11 20:54:30 +02:00
|
|
|
physBitmap->pixmap = pixmap;
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a packed DIB from the Pixmap wrapper bitmap created above.
|
|
|
|
* A packed DIB contains a BITMAPINFO structure followed immediately by
|
|
|
|
* an optional color palette and the pixel data.
|
|
|
|
*/
|
2004-01-14 00:31:46 +01:00
|
|
|
hPackedDIB = X11DRV_DIB_CreateDIBFromBitmap(hdc, hBmp);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2008-05-01 17:43:33 +02:00
|
|
|
/* we can now get rid of the HBITMAP and its original pixmap */
|
|
|
|
physBitmap->pixmap = orig_pixmap;
|
2002-06-01 01:06:46 +02:00
|
|
|
DeleteObject(hBmp);
|
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE("\tReturning packed DIB %p\n", hPackedDIB);
|
1999-09-20 17:42:47 +02:00
|
|
|
return hPackedDIB;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* X11DRV_DIB_CreatePixmapFromDIB
|
|
|
|
*
|
|
|
|
* Creates a Pixmap from a packed DIB
|
|
|
|
*/
|
|
|
|
Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc )
|
|
|
|
{
|
2011-09-07 22:55:12 +02:00
|
|
|
Pixmap pixmap = 0;
|
2005-04-11 20:54:30 +02:00
|
|
|
X_PHYSBITMAP *physBitmap;
|
2005-03-28 12:06:06 +02:00
|
|
|
HBITMAP hBmp;
|
|
|
|
LPBITMAPINFO pbmi;
|
2011-09-07 22:55:12 +02:00
|
|
|
HDC memdc;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/* Create a DDB from the DIB */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-03-28 12:06:06 +02:00
|
|
|
pbmi = GlobalLock(hPackedDIB);
|
|
|
|
hBmp = CreateDIBitmap(hdc, &pbmi->bmiHeader, CBM_INIT,
|
2008-05-02 13:43:14 +02:00
|
|
|
(LPBYTE)pbmi + bitmap_info_size( pbmi, DIB_RGB_COLORS ),
|
2005-03-28 12:06:06 +02:00
|
|
|
pbmi, DIB_RGB_COLORS);
|
1999-09-20 17:42:47 +02:00
|
|
|
GlobalUnlock(hPackedDIB);
|
|
|
|
|
2011-09-07 22:55:12 +02:00
|
|
|
/* make sure it's owned by x11drv */
|
|
|
|
memdc = CreateCompatibleDC( hdc );
|
|
|
|
SelectObject( memdc, hBmp );
|
|
|
|
DeleteDC( memdc );
|
|
|
|
|
2000-03-28 15:37:50 +02:00
|
|
|
/* clear the physBitmap so that we can steal its pixmap */
|
2011-09-07 22:55:12 +02:00
|
|
|
if ((physBitmap = X11DRV_get_phys_bitmap( hBmp )))
|
|
|
|
{
|
|
|
|
pixmap = physBitmap->pixmap;
|
|
|
|
physBitmap->pixmap = 0;
|
|
|
|
}
|
1999-09-20 17:42:47 +02:00
|
|
|
|
|
|
|
/* Delete the DDB we created earlier now that we have stolen its pixmap */
|
|
|
|
DeleteObject(hBmp);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2008-05-01 17:43:33 +02:00
|
|
|
TRACE("Returning Pixmap %lx\n", pixmap);
|
1999-09-20 17:42:47 +02:00
|
|
|
return pixmap;
|
|
|
|
}
|