Implemented Get/SetDIBColorTable.
This commit is contained in:
parent
235f1295f1
commit
a32ddc0f8d
|
@ -204,6 +204,24 @@ void TTYDRV_BITMAP_DeleteDIBSection(BITMAPOBJ *bmp)
|
||||||
FIXME("(%p): stub\n", bmp);
|
FIXME("(%p): stub\n", bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* TTYDRV_BITMAP_SetDIBColorTable
|
||||||
|
*/
|
||||||
|
UINT TTYDRV_BITMAP_SetDIBColorTable(BITMAPOBJ *bmp, DC *dc, UINT start, UINT count, const RGBQUAD *colors)
|
||||||
|
{
|
||||||
|
FIXME("(%p): stub\n", bmp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* TTYDRV_BITMAP_GetDIBColorTable
|
||||||
|
*/
|
||||||
|
UINT TTYDRV_BITMAP_GetDIBColorTable(BITMAPOBJ *bmp, DC *dc, UINT start, UINT count, RGBQUAD *colors)
|
||||||
|
{
|
||||||
|
FIXME("(%p): stub\n", bmp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* TTYDRV_BITMAP_GetDIBits
|
* TTYDRV_BITMAP_GetDIBits
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -122,7 +122,9 @@ BITMAP_DRIVER TTYDRV_BITMAP_Driver =
|
||||||
{
|
{
|
||||||
TTYDRV_BITMAP_SetDIBits,
|
TTYDRV_BITMAP_SetDIBits,
|
||||||
TTYDRV_BITMAP_GetDIBits,
|
TTYDRV_BITMAP_GetDIBits,
|
||||||
TTYDRV_BITMAP_DeleteDIBSection
|
TTYDRV_BITMAP_DeleteDIBSection,
|
||||||
|
TTYDRV_BITMAP_SetDIBColorTable,
|
||||||
|
TTYDRV_BITMAP_GetDIBColorTable
|
||||||
};
|
};
|
||||||
|
|
||||||
PALETTE_DRIVER TTYDRV_PALETTE_Driver =
|
PALETTE_DRIVER TTYDRV_PALETTE_Driver =
|
||||||
|
|
|
@ -51,6 +51,8 @@ extern HBITMAP16 TTYDRV_BITMAP_CreateDIBSection16(struct tagDC *dc, BITMAPINFO *
|
||||||
extern INT TTYDRV_BITMAP_SetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan, UINT lines, LPCVOID bits, const BITMAPINFO *info, UINT coloruse, HBITMAP hbitmap);
|
extern INT TTYDRV_BITMAP_SetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan, UINT lines, LPCVOID bits, const BITMAPINFO *info, UINT coloruse, HBITMAP hbitmap);
|
||||||
extern INT TTYDRV_BITMAP_GetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan, UINT lines, LPVOID bits, BITMAPINFO *info, UINT coloruse, HBITMAP hbitmap);
|
extern INT TTYDRV_BITMAP_GetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan, UINT lines, LPVOID bits, BITMAPINFO *info, UINT coloruse, HBITMAP hbitmap);
|
||||||
extern void TTYDRV_BITMAP_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
|
extern void TTYDRV_BITMAP_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
|
||||||
|
extern UINT TTYDRV_BITMAP_SetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,const RGBQUAD *);
|
||||||
|
extern UINT TTYDRV_BITMAP_GetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,RGBQUAD *);
|
||||||
|
|
||||||
#ifndef WINE_CURSES
|
#ifndef WINE_CURSES
|
||||||
typedef struct { int dummy; } WINDOW;
|
typedef struct { int dummy; } WINDOW;
|
||||||
|
|
|
@ -77,6 +77,60 @@ int X11DRV_DIB_GetXImageWidthBytes( int width, int depth )
|
||||||
return (4 * width);
|
return (4 * width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* X11DRV_DIB_GenColorMap
|
||||||
|
*
|
||||||
|
* Fills the color map of a bitmap palette. Should not be called
|
||||||
|
* for a >8-bit deep bitmap.
|
||||||
|
*/
|
||||||
|
int *X11DRV_DIB_GenColorMap( DC *dc, int *colorMapping,
|
||||||
|
WORD coloruse, WORD depth, BOOL quads,
|
||||||
|
const void *colorPtr, int start, int end )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (coloruse == DIB_RGB_COLORS)
|
||||||
|
{
|
||||||
|
if (quads)
|
||||||
|
{
|
||||||
|
RGBQUAD * rgb = (RGBQUAD *)colorPtr;
|
||||||
|
|
||||||
|
if (depth == 1) /* Monochrome */
|
||||||
|
for (i = start; i < end; i++, rgb++)
|
||||||
|
colorMapping[i] = (rgb->rgbRed + rgb->rgbGreen +
|
||||||
|
rgb->rgbBlue > 255*3/2);
|
||||||
|
else
|
||||||
|
for (i = start; i < end; i++, rgb++)
|
||||||
|
colorMapping[i] = X11DRV_PALETTE_ToPhysical( dc, RGB(rgb->rgbRed,
|
||||||
|
rgb->rgbGreen,
|
||||||
|
rgb->rgbBlue));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RGBTRIPLE * rgb = (RGBTRIPLE *)colorPtr;
|
||||||
|
|
||||||
|
if (depth == 1) /* Monochrome */
|
||||||
|
for (i = start; i < end; i++, rgb++)
|
||||||
|
colorMapping[i] = (rgb->rgbtRed + rgb->rgbtGreen +
|
||||||
|
rgb->rgbtBlue > 255*3/2);
|
||||||
|
else
|
||||||
|
for (i = start; i < end; i++, rgb++)
|
||||||
|
colorMapping[i] = X11DRV_PALETTE_ToPhysical( dc, RGB(rgb->rgbtRed,
|
||||||
|
rgb->rgbtGreen,
|
||||||
|
rgb->rgbtBlue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else /* DIB_PAL_COLORS */
|
||||||
|
{
|
||||||
|
WORD * index = (WORD *)colorPtr;
|
||||||
|
|
||||||
|
for (i = start; i < end; i++, index++)
|
||||||
|
colorMapping[i] = X11DRV_PALETTE_ToPhysical( dc, PALETTEINDEX(*index) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return colorMapping;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* X11DRV_DIB_BuildColorMap
|
* X11DRV_DIB_BuildColorMap
|
||||||
*
|
*
|
||||||
|
@ -86,7 +140,7 @@ int X11DRV_DIB_GetXImageWidthBytes( int width, int depth )
|
||||||
int *X11DRV_DIB_BuildColorMap( DC *dc, WORD coloruse, WORD depth,
|
int *X11DRV_DIB_BuildColorMap( DC *dc, WORD coloruse, WORD depth,
|
||||||
const BITMAPINFO *info, int *nColors )
|
const BITMAPINFO *info, int *nColors )
|
||||||
{
|
{
|
||||||
int i, colors;
|
int colors;
|
||||||
BOOL isInfo;
|
BOOL isInfo;
|
||||||
WORD *colorPtr;
|
WORD *colorPtr;
|
||||||
int *colorMapping;
|
int *colorMapping;
|
||||||
|
@ -113,45 +167,9 @@ int *X11DRV_DIB_BuildColorMap( DC *dc, WORD coloruse, WORD depth,
|
||||||
colors * sizeof(int) )))
|
colors * sizeof(int) )))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (coloruse == DIB_RGB_COLORS)
|
|
||||||
{
|
|
||||||
if (isInfo)
|
|
||||||
{
|
|
||||||
RGBQUAD * rgb = (RGBQUAD *)colorPtr;
|
|
||||||
|
|
||||||
if (depth == 1) /* Monochrome */
|
|
||||||
for (i = 0; i < colors; i++, rgb++)
|
|
||||||
colorMapping[i] = (rgb->rgbRed + rgb->rgbGreen +
|
|
||||||
rgb->rgbBlue > 255*3/2);
|
|
||||||
else
|
|
||||||
for (i = 0; i < colors; i++, rgb++)
|
|
||||||
colorMapping[i] = X11DRV_PALETTE_ToPhysical( dc, RGB(rgb->rgbRed,
|
|
||||||
rgb->rgbGreen,
|
|
||||||
rgb->rgbBlue));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RGBTRIPLE * rgb = (RGBTRIPLE *)colorPtr;
|
|
||||||
|
|
||||||
if (depth == 1) /* Monochrome */
|
|
||||||
for (i = 0; i < colors; i++, rgb++)
|
|
||||||
colorMapping[i] = (rgb->rgbtRed + rgb->rgbtGreen +
|
|
||||||
rgb->rgbtBlue > 255*3/2);
|
|
||||||
else
|
|
||||||
for (i = 0; i < colors; i++, rgb++)
|
|
||||||
colorMapping[i] = X11DRV_PALETTE_ToPhysical( dc, RGB(rgb->rgbtRed,
|
|
||||||
rgb->rgbtGreen,
|
|
||||||
rgb->rgbtBlue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* DIB_PAL_COLORS */
|
|
||||||
{
|
|
||||||
for (i = 0; i < colors; i++, colorPtr++)
|
|
||||||
colorMapping[i] = X11DRV_PALETTE_ToPhysical( dc, PALETTEINDEX(*colorPtr) );
|
|
||||||
}
|
|
||||||
|
|
||||||
*nColors = colors;
|
*nColors = colors;
|
||||||
return colorMapping;
|
return X11DRV_DIB_GenColorMap( dc, colorMapping, coloruse, depth,
|
||||||
|
isInfo, colorPtr, 0, colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3603,6 +3621,42 @@ void X11DRV_DIB_DeleteDIBSection(BITMAPOBJ *bmp)
|
||||||
if (dib->selector) SELECTOR_FreeBlock( dib->selector );
|
if (dib->selector) SELECTOR_FreeBlock( dib->selector );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* X11DRV_DIB_SetDIBColorTable
|
||||||
|
*/
|
||||||
|
UINT X11DRV_DIB_SetDIBColorTable(BITMAPOBJ *bmp, DC *dc, UINT start, UINT count, const RGBQUAD *colors)
|
||||||
|
{
|
||||||
|
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
|
||||||
|
|
||||||
|
if (dib && dib->colorMap) {
|
||||||
|
X11DRV_DIB_GenColorMap( dc, dib->colorMap, DIB_RGB_COLORS, dib->dibSection.dsBm.bmBitsPixel,
|
||||||
|
TRUE, colors, start, count - start );
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* X11DRV_DIB_GetDIBColorTable
|
||||||
|
*/
|
||||||
|
UINT X11DRV_DIB_GetDIBColorTable(BITMAPOBJ *bmp, DC *dc, UINT start, UINT count, RGBQUAD *colors)
|
||||||
|
{
|
||||||
|
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
|
||||||
|
|
||||||
|
if (dib && dib->colorMap) {
|
||||||
|
int i, end = count - start;
|
||||||
|
for (i = start; i < end; i++,colors++) {
|
||||||
|
COLORREF col = X11DRV_PALETTE_ToLogical( dib->colorMap[i] );
|
||||||
|
colors->rgbBlue = GetBValue(col);
|
||||||
|
colors->rgbGreen = GetGValue(col);
|
||||||
|
colors->rgbRed = GetRValue(col);
|
||||||
|
colors->rgbReserved = 0;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* X11DRV_DIB_CreateDIBFromPixmap
|
* X11DRV_DIB_CreateDIBFromPixmap
|
||||||
|
|
|
@ -131,7 +131,9 @@ BITMAP_DRIVER X11DRV_BITMAP_Driver =
|
||||||
{
|
{
|
||||||
X11DRV_DIB_SetDIBits,
|
X11DRV_DIB_SetDIBits,
|
||||||
X11DRV_DIB_GetDIBits,
|
X11DRV_DIB_GetDIBits,
|
||||||
X11DRV_DIB_DeleteDIBSection
|
X11DRV_DIB_DeleteDIBSection,
|
||||||
|
X11DRV_DIB_SetDIBColorTable,
|
||||||
|
X11DRV_DIB_GetDIBColorTable
|
||||||
};
|
};
|
||||||
|
|
||||||
PALETTE_DRIVER X11DRV_PALETTE_Driver =
|
PALETTE_DRIVER X11DRV_PALETTE_Driver =
|
||||||
|
|
|
@ -35,6 +35,8 @@ typedef struct tagBITMAP_DRIVER
|
||||||
INT (*pSetDIBits)(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,LPCVOID,const BITMAPINFO *,UINT,HBITMAP);
|
INT (*pSetDIBits)(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,LPCVOID,const BITMAPINFO *,UINT,HBITMAP);
|
||||||
INT (*pGetDIBits)(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,LPVOID,BITMAPINFO *,UINT,HBITMAP);
|
INT (*pGetDIBits)(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,LPVOID,BITMAPINFO *,UINT,HBITMAP);
|
||||||
VOID (*pDeleteDIBSection)(struct tagBITMAPOBJ *);
|
VOID (*pDeleteDIBSection)(struct tagBITMAPOBJ *);
|
||||||
|
UINT (*pSetDIBColorTable)(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,const RGBQUAD *);
|
||||||
|
UINT (*pGetDIBColorTable)(struct tagBITMAPOBJ *,struct tagDC *,UINT,UINT,RGBQUAD *);
|
||||||
} BITMAP_DRIVER;
|
} BITMAP_DRIVER;
|
||||||
|
|
||||||
extern BITMAP_DRIVER *BITMAP_Driver;
|
extern BITMAP_DRIVER *BITMAP_Driver;
|
||||||
|
|
|
@ -280,6 +280,8 @@ extern INT X11DRV_DIB_GetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT
|
||||||
UINT lines, LPVOID bits, BITMAPINFO *info,
|
UINT lines, LPVOID bits, BITMAPINFO *info,
|
||||||
UINT coloruse, HBITMAP hbitmap);
|
UINT coloruse, HBITMAP hbitmap);
|
||||||
extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
|
extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
|
||||||
|
extern UINT X11DRV_DIB_SetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,const RGBQUAD *);
|
||||||
|
extern UINT X11DRV_DIB_GetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,RGBQUAD *);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* X11 GDI driver
|
* X11 GDI driver
|
||||||
|
|
|
@ -306,40 +306,22 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries,
|
||||||
RGBQUAD *colors )
|
RGBQUAD *colors )
|
||||||
{
|
{
|
||||||
DC * dc;
|
DC * dc;
|
||||||
PALETTEENTRY * palEntry;
|
BITMAPOBJ * bmp;
|
||||||
PALETTEOBJ * palette;
|
UINT result;
|
||||||
RGBQUAD *end;
|
|
||||||
|
|
||||||
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
|
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
|
||||||
|
|
||||||
if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->hPalette, PALETTE_MAGIC )))
|
if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( dc->hBitmap, BITMAP_MAGIC )))
|
||||||
{
|
{
|
||||||
GDI_ReleaseObj( hdc );
|
GDI_ReleaseObj( hdc );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transfer color info */
|
result = BITMAP_Driver->pSetDIBColorTable(bmp, dc, startpos, entries, colors);
|
||||||
|
|
||||||
if (dc->bitsPerPixel <= 8) {
|
|
||||||
palEntry = palette->logpalette.palPalEntry + startpos;
|
|
||||||
if (startpos + entries > (1 << dc->bitsPerPixel))
|
|
||||||
entries = (1 << dc->bitsPerPixel) - startpos;
|
|
||||||
|
|
||||||
if (startpos + entries > palette->logpalette.palNumEntries)
|
GDI_ReleaseObj( dc->hBitmap );
|
||||||
entries = palette->logpalette.palNumEntries - startpos;
|
|
||||||
|
|
||||||
for (end = colors + entries; colors < end; palEntry++, colors++)
|
|
||||||
{
|
|
||||||
palEntry->peRed = colors->rgbRed;
|
|
||||||
palEntry->peGreen = colors->rgbGreen;
|
|
||||||
palEntry->peBlue = colors->rgbBlue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
entries = 0;
|
|
||||||
}
|
|
||||||
GDI_ReleaseObj( dc->hPalette );
|
|
||||||
GDI_ReleaseObj( hdc );
|
GDI_ReleaseObj( hdc );
|
||||||
return entries;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -358,38 +340,22 @@ UINT WINAPI GetDIBColorTable( HDC hdc, UINT startpos, UINT entries,
|
||||||
RGBQUAD *colors )
|
RGBQUAD *colors )
|
||||||
{
|
{
|
||||||
DC * dc;
|
DC * dc;
|
||||||
PALETTEENTRY * palEntry;
|
BITMAPOBJ * bmp;
|
||||||
PALETTEOBJ * palette;
|
UINT result;
|
||||||
RGBQUAD *end;
|
|
||||||
|
|
||||||
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
|
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
|
||||||
|
|
||||||
if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->hPalette, PALETTE_MAGIC )))
|
if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( dc->hBitmap, BITMAP_MAGIC )))
|
||||||
{
|
{
|
||||||
GDI_ReleaseObj( hdc );
|
GDI_ReleaseObj( hdc );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transfer color info */
|
result = BITMAP_Driver->pGetDIBColorTable(bmp, dc, startpos, entries, colors);
|
||||||
|
|
||||||
if (dc->bitsPerPixel <= 8) {
|
GDI_ReleaseObj( dc->hBitmap );
|
||||||
palEntry = palette->logpalette.palPalEntry + startpos;
|
|
||||||
if (startpos + entries > (1 << dc->bitsPerPixel)) {
|
|
||||||
entries = (1 << dc->bitsPerPixel) - startpos;
|
|
||||||
}
|
|
||||||
for (end = colors + entries; colors < end; palEntry++, colors++)
|
|
||||||
{
|
|
||||||
colors->rgbRed = palEntry->peRed;
|
|
||||||
colors->rgbGreen = palEntry->peGreen;
|
|
||||||
colors->rgbBlue = palEntry->peBlue;
|
|
||||||
colors->rgbReserved = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
entries = 0;
|
|
||||||
}
|
|
||||||
GDI_ReleaseObj( dc->hPalette );
|
|
||||||
GDI_ReleaseObj( hdc );
|
GDI_ReleaseObj( hdc );
|
||||||
return entries;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME the following two structs should be combined with __sysPalTemplate in
|
/* FIXME the following two structs should be combined with __sysPalTemplate in
|
||||||
|
|
Loading…
Reference in New Issue