2 * GDI device-independent bitmaps
4 * Copyright 1993,1994 Alexandre Julliard
17 static int bitmapDepthTable[] = { 8, 1, 32, 16, 24, 15, 4, 0 };
18 static int ximageDepthTable[] = { 0, 0, 0, 0, 0, 0, 0 };
21 /* This structure holds the arguments for DIB_SetImageBits() */
41 } DIB_SETIMAGEBITS_DESCR;
44 /***********************************************************************
52 for( i = 0; bitmapDepthTable[i]; i++ )
54 testimage = TSXCreateImage(display, DefaultVisualOfScreen(screen),
55 bitmapDepthTable[i], ZPixmap, 0, NULL, 1, 1, 32, 20 );
56 if( testimage ) ximageDepthTable[i] = testimage->bits_per_pixel;
58 TSXDestroyImage(testimage);
63 /***********************************************************************
64 * DIB_GetXImageWidthBytes
66 * Return the width of an X image in bytes
68 int DIB_GetXImageWidthBytes( int width, int depth )
72 if (!ximageDepthTable[0]) {
75 for( i = 0; bitmapDepthTable[i] ; i++ )
76 if( bitmapDepthTable[i] == depth )
77 return (4 * ((width * ximageDepthTable[i] + 31)/32));
79 WARN(bitmap, "(%d): Unsupported depth\n", depth );
83 /***********************************************************************
84 * DIB_GetDIBWidthBytes
86 * Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned.
87 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/struc/src/str01.htm
89 int DIB_GetDIBWidthBytes( int width, int depth )
95 case 1: words = (width + 31) / 32; break;
96 case 4: words = (width + 7) / 8; break;
97 case 8: words = (width + 3) / 4; break;
99 case 16: words = (width + 1) / 2; break;
100 case 24: words = (width * 3 + 3)/4; break;
103 WARN(bitmap, "(%d): Unsupported depth\n", depth );
112 /***********************************************************************
115 * Return the size of the bitmap info structure including color table.
117 int DIB_BitmapInfoSize( BITMAPINFO * info, WORD coloruse )
121 if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
123 BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)info;
124 colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
125 return sizeof(BITMAPCOREHEADER) + colors *
126 ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
128 else /* assume BITMAPINFOHEADER */
130 colors = info->bmiHeader.biClrUsed;
131 if (!colors && (info->bmiHeader.biBitCount <= 8))
132 colors = 1 << info->bmiHeader.biBitCount;
133 return sizeof(BITMAPINFOHEADER) + colors *
134 ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
139 /***********************************************************************
142 * Get the info from a bitmap header.
143 * Return 1 for INFOHEADER, 0 for COREHEADER, -1 for error.
145 static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
146 int *height, WORD *bpp, WORD *compr )
148 if (header->biSize == sizeof(BITMAPINFOHEADER))
150 *width = header->biWidth;
151 *height = header->biHeight;
152 *bpp = header->biBitCount;
153 *compr = header->biCompression;
156 if (header->biSize == sizeof(BITMAPCOREHEADER))
158 BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header;
159 *width = core->bcWidth;
160 *height = core->bcHeight;
161 *bpp = core->bcBitCount;
165 WARN(bitmap, "(%ld): wrong size for header\n", header->biSize );
170 /***********************************************************************
173 * Build the color map from the bitmap palette. Should not be called
174 * for a >8-bit deep bitmap.
176 static RGBQUAD *DIB_BuildColorMap( const BITMAPINFO *info,
177 HPALETTE16 hPalette, int *nColors )
182 RGBQUAD *colorMapping;
184 if ((isInfo = (info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))))
186 colors = info->bmiHeader.biClrUsed;
187 if (!colors) colors = 1 << info->bmiHeader.biBitCount;
188 colorPtr = (WORD *)info->bmiColors;
190 else /* assume BITMAPCOREINFO */
192 colors = 1 << ((BITMAPCOREHEADER *)&info->bmiHeader)->bcBitCount;
193 colorPtr = (WORD *)((BITMAPCOREINFO *)info)->bmciColors;
198 ERR(bitmap, "DIB_BuildColorMap called with >256 colors!\n");
202 if (!(colorMapping = (RGBQUAD *)HeapAlloc(GetProcessHeap(), 0,
203 colors * sizeof(RGBQUAD) )))
206 if (hPalette == 0) /* DIB_RGB_COLORS */
210 RGBQUAD * rgb = (RGBQUAD *)colorPtr;
212 for (i = 0; i < colors; i++, rgb++)
213 colorMapping[i] = *rgb;
217 RGBTRIPLE * rgb = (RGBTRIPLE *)colorPtr;
219 for (i = 0; i < colors; i++, rgb++)
220 colorMapping[i].rgbRed = rgb->rgbtRed,
221 colorMapping[i].rgbGreen = rgb->rgbtGreen,
222 colorMapping[i].rgbBlue = rgb->rgbtBlue;
225 else /* DIB_PAL_COLORS */
227 PALETTEOBJ *palPtr = (PALETTEOBJ *)GDI_GetObjPtr(hPalette, PALETTE_MAGIC);
230 HeapFree(GetProcessHeap(), 0, colorMapping);
234 for (i = 0; i < colors; i++, colorPtr++)
235 if (*colorPtr >= palPtr->logpalette.palNumEntries)
237 colorMapping[i].rgbRed = 0;
238 colorMapping[i].rgbGreen = 0;
239 colorMapping[i].rgbBlue = 0;
243 PALETTEENTRY *pe = palPtr->logpalette.palPalEntry + *colorPtr;
244 colorMapping[i].rgbRed = pe->peRed;
245 colorMapping[i].rgbGreen = pe->peGreen;
246 colorMapping[i].rgbBlue = pe->peBlue;
249 GDI_HEAP_UNLOCK(hPalette);
256 /***********************************************************************
257 * DIB_PhysicalColorMap
259 * Translate color map to physical colors
261 static int *DIB_PhysicalColorMap( DC *dc, int depth,
262 RGBQUAD *colorMap, int nColorMap)
264 int *colorMapping, i;
266 if (!nColorMap) return NULL;
267 if (!(colorMapping = (int *)HeapAlloc(GetProcessHeap(), 0,
268 nColorMap * sizeof(int) ))) return NULL;
270 if (depth == 1) /* Monochrome */
271 for (i = 0; i < nColorMap; i++, colorMap++)
272 colorMapping[i] = (colorMap->rgbRed + colorMap->rgbGreen +
273 colorMap->rgbBlue > 255*3/2);
275 for (i = 0; i < nColorMap; i++, colorMap++)
276 colorMapping[i] = COLOR_ToPhysical( dc, RGB(colorMap->rgbRed,
282 /***********************************************************************
283 * DIB_SetImageBits_1_Line
285 * Handles a single line of 1 bit data.
287 static void DIB_SetImageBits_1_Line(DWORD dstwidth, int left, int *colors,
288 XImage *bmpImage, int h, const BYTE *bits)
293 dstwidth += left; bits += left >> 3;
295 /* FIXME: should avoid putting x<left pixels (minor speed issue) */
296 for (i = dstwidth/8, x = left&~7; (i > 0); i--)
299 XPutPixel( bmpImage, x++, h, colors[pix >> 7] );
300 XPutPixel( bmpImage, x++, h, colors[(pix >> 6) & 1] );
301 XPutPixel( bmpImage, x++, h, colors[(pix >> 5) & 1] );
302 XPutPixel( bmpImage, x++, h, colors[(pix >> 4) & 1] );
303 XPutPixel( bmpImage, x++, h, colors[(pix >> 3) & 1] );
304 XPutPixel( bmpImage, x++, h, colors[(pix >> 2) & 1] );
305 XPutPixel( bmpImage, x++, h, colors[(pix >> 1) & 1] );
306 XPutPixel( bmpImage, x++, h, colors[pix & 1] );
311 case 7: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
312 case 6: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
313 case 5: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
314 case 4: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
315 case 3: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
316 case 2: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
317 case 1: XPutPixel( bmpImage, x++, h, colors[pix >> 7] );
321 /***********************************************************************
324 * SetDIBits for a 1-bit deep DIB.
326 static void DIB_SetImageBits_1( int lines, const BYTE *srcbits,
327 DWORD srcwidth, DWORD dstwidth, int left,
328 int *colors, XImage *bmpImage )
333 DWORD linebytes = ((srcwidth + 31) & ~31) / 8;
336 for (h = lines-1; h >=0; h--) {
337 DIB_SetImageBits_1_Line(dstwidth, left, colors, bmpImage, h, srcbits);
338 srcbits += linebytes;
342 for (h = 0; h < lines; h++) {
343 DIB_SetImageBits_1_Line(dstwidth, left, colors, bmpImage, h, srcbits);
344 srcbits += linebytes;
350 /***********************************************************************
353 * SetDIBits for a 4-bit deep DIB.
355 static void DIB_SetImageBits_4( int lines, const BYTE *srcbits,
356 DWORD srcwidth, DWORD dstwidth, int left,
357 int *colors, XImage *bmpImage )
361 const BYTE *bits = srcbits + (left >> 1);
364 DWORD linebytes = ((srcwidth+7)&~7)/2;
368 /* FIXME: should avoid putting x<left pixels (minor speed issue) */
370 for (h = lines-1; h >= 0; h--) {
371 for (i = dstwidth/2, x = left&~1; i > 0; i--) {
373 XPutPixel( bmpImage, x++, h, colors[pix >> 4] );
374 XPutPixel( bmpImage, x++, h, colors[pix & 0x0f] );
376 if (dstwidth & 1) XPutPixel( bmpImage, x, h, colors[*bits >> 4] );
377 srcbits += linebytes;
378 bits = srcbits + (left >> 1);
382 for (h = 0; h < lines; h++) {
383 for (i = dstwidth/2, x = left&~1; i > 0; i--) {
385 XPutPixel( bmpImage, x++, h, colors[pix >> 4] );
386 XPutPixel( bmpImage, x++, h, colors[pix & 0x0f] );
388 if (dstwidth & 1) XPutPixel( bmpImage, x, h, colors[*bits >> 4] );
389 srcbits += linebytes;
390 bits = srcbits + (left >> 1);
395 #define check_xy(x,y) \
402 /***********************************************************************
403 * DIB_SetImageBits_RLE4
405 * SetDIBits for a 4-bit deep compressed DIB.
407 static void DIB_SetImageBits_RLE4( int lines, const BYTE *bits, DWORD width,
408 DWORD dstwidth, int left, int *colors, XImage *bmpImage )
410 int x = 0, c, length;
411 const BYTE *begin = bits;
413 dstwidth += left; /* FIXME: avoid putting x<left pixels */
416 while ((int)lines >= 0)
419 if (length) { /* encoded */
422 XPutPixel(bmpImage, x++, lines, colors[c >> 4]);
426 XPutPixel(bmpImage, x++, lines, colors[c & 0xf]);
438 case 1: /* eopicture */
446 default: /* absolute */
449 XPutPixel(bmpImage, x++, lines, colors[c >> 4]);
453 XPutPixel(bmpImage, x++, lines, colors[c & 0xf]);
457 if ((bits - begin) & 1)
464 /***********************************************************************
467 * SetDIBits for an 8-bit deep DIB.
469 static void DIB_SetImageBits_8( int lines, const BYTE *srcbits,
470 DWORD srcwidth, DWORD dstwidth, int left,
471 int *colors, XImage *bmpImage )
475 const BYTE *bits = srcbits + left;
477 /* align to 32 bit */
478 DWORD linebytes = (srcwidth + 3) & ~3;
483 for (h = lines - 1; h >= 0; h--) {
484 for (x = left; x < dstwidth; x++, bits++) {
485 XPutPixel( bmpImage, x, h, colors[*bits] );
487 bits = (srcbits += linebytes) + left;
491 for (h = 0; h < lines; h++) {
492 for (x = left; x < dstwidth; x++, bits++) {
493 XPutPixel( bmpImage, x, h, colors[*bits] );
495 bits = (srcbits += linebytes) + left;
500 /***********************************************************************
501 * DIB_SetImageBits_RLE8
503 * SetDIBits for an 8-bit deep compressed DIB.
505 * This function rewritten 941113 by James Youngman. WINE blew out when I
506 * first ran it because my desktop wallpaper is a (large) RLE8 bitmap.
508 * This was because the algorithm assumed that all RLE8 bitmaps end with the
509 * 'End of bitmap' escape code. This code is very much laxer in what it
510 * allows to end the expansion. Possibly too lax. See the note by
511 * case RleDelta. BTW, MS's documentation implies that a correct RLE8
512 * bitmap should end with RleEnd, but on the other hand, software exists
513 * that produces ones that don't and Windows 3.1 doesn't complain a bit
516 * (No) apologies for my English spelling. [Emacs users: c-indent-level=4].
517 * James A. Youngman <mbcstjy@afs.man.ac.uk>
521 enum Rle8_EscapeCodes
524 * Apologies for polluting your file's namespace...
526 RleEol = 0, /* End of line */
527 RleEnd = 1, /* End of bitmap */
528 RleDelta = 2 /* Delta */
531 static void DIB_SetImageBits_RLE8( int lines, const BYTE *bits, DWORD width,
532 DWORD dstwidth, int left, int *colors, XImage *bmpImage )
534 int x; /* X-positon on each line. Increases. */
535 int line; /* Line #. Starts at lines-1, decreases */
536 const BYTE *pIn = bits; /* Pointer to current position in bits */
537 BYTE length; /* The length pf a run */
538 BYTE color_index; /* index into colors[] as read from bits */
539 BYTE escape_code; /* See enum Rle8_EscapeCodes.*/
540 WORD color; /* value of colour[color_index] */
542 if (lines == 0) /* Let's hope this doesn't happen. */
545 dstwidth += left; /* FIXME: avoid putting x<left pixels */
548 * Note that the bitmap data is stored by Windows starting at the
549 * bottom line of the bitmap and going upwards. Within each line,
550 * the data is stored left-to-right. That's the reason why line
551 * goes from lines-1 to 0. [JAY]
561 * If the length byte is not zero (which is the escape value),
562 * We have a run of length pixels all the same colour. The colour
563 * index is stored next.
565 * If the length byte is zero, we need to read the next byte to
566 * know what to do. [JAY]
571 * [Run-Length] Encoded mode
573 color_index = (*pIn++); /* Get the colour index. */
574 color = colors[color_index];
577 XPutPixel(bmpImage, x++, line, color);
582 * Escape codes (may be an absolute sequence though)
584 escape_code = (*pIn++);
587 case RleEol: /* =0, end of line */
594 case RleEnd: /* =1, end of bitmap */
597 * Not all RLE8 bitmaps end with this
598 * code. For example, Paint Shop Pro
599 * produces some that don't. That's (I think)
600 * what caused the previous implementation to
603 line=-1; /* Cause exit from do loop. */
607 case RleDelta: /* =2, a delta */
610 * Note that deltaing to line 0
611 * will cause an exit from the loop,
612 * which may not be what is intended.
613 * The fact that there is a delta in the bits
614 * almost certainly implies that there is data
615 * to follow. You may feel that we should
616 * jump to the top of the loop to avoid exiting
619 * TODO: Decide what to do here in that case. [JAY]
625 TRACE(bitmap, "Delta to last line of bitmap "
626 "(wrongly?) causes loop exit\n");
631 default: /* >2, switch to absolute mode */
636 length = escape_code;
639 color_index = (*pIn++);
640 XPutPixel(bmpImage, x++, line,
641 colors[color_index]);
645 * If you think for a moment you'll realise that the
646 * only time we could ever possibly read an odd
647 * number of bytes is when there is a 0x00 (escape),
648 * a value >0x02 (absolute mode) and then an odd-
649 * length run. Therefore this is the only place we
650 * need to worry about it. Everywhere else the
651 * bytes are always read in pairs. [JAY]
654 pIn++; /* Throw away the pad byte. */
657 } /* switch (escape_code) : Escape sequence */
658 } /* process either an encoded sequence or an escape sequence */
660 /* We expect to come here more than once per line. */
661 } while (line >= 0); /* Do this until the bitmap is filled */
664 * Everybody comes here at the end.
665 * Check how we exited the loop and print a message if it's a bit odd.
668 if ( (*(pIn-2) != 0/*escape*/) || (*(pIn-1)!= RleEnd) )
670 TRACE(bitmap, "End-of-bitmap "
671 "without (strictly) proper escape code. Last two "
672 "bytes were: %02X %02X.\n",
679 /***********************************************************************
680 * DIB_SetImageBits_16
682 * SetDIBits for a 16-bit deep DIB.
684 static void DIB_SetImageBits_16( int lines, const BYTE *srcbits,
685 DWORD srcwidth, DWORD dstwidth, int left,
686 DC *dc, XImage *bmpImage )
694 /* align to 32 bit */
695 DWORD linebytes = (srcwidth * 2 + 3) & ~3;
699 ptr = (LPWORD) srcbits + left;
701 for (h = lines - 1; h >= 0; h--) {
702 for (x = left; x < dstwidth; x++, ptr++) {
704 r = (BYTE) ((val & 0x7c00) >> 7);
705 g = (BYTE) ((val & 0x03e0) >> 2);
706 b = (BYTE) ((val & 0x001f) << 3);
707 XPutPixel( bmpImage, x, h,
708 COLOR_ToPhysical(dc, RGB(r,g,b)) );
710 ptr = (LPWORD) (srcbits += linebytes) + left;
714 for (h = 0; h < lines; h++) {
715 for (x = left; x < dstwidth; x++, ptr++) {
717 r = (BYTE) ((val & 0x7c00) >> 7);
718 g = (BYTE) ((val & 0x03e0) >> 2);
719 b = (BYTE) ((val & 0x001f) << 3);
720 XPutPixel( bmpImage, x, h,
721 COLOR_ToPhysical(dc, RGB(r,g,b)) );
723 ptr = (LPWORD) (srcbits += linebytes) + left;
729 /***********************************************************************
730 * DIB_SetImageBits_24
732 * SetDIBits for a 24-bit deep DIB.
734 static void DIB_SetImageBits_24( int lines, const BYTE *srcbits,
735 DWORD srcwidth, DWORD dstwidth, int left,
736 DC *dc, XImage *bmpImage )
739 const BYTE *bits = srcbits + left * 3;
742 /* align to 32 bit */
743 DWORD linebytes = (srcwidth * 3 + 3) & ~3;
747 /* "bits" order is reversed for some reason */
750 for (h = lines - 1; h >= 0; h--) {
751 for (x = left; x < dstwidth; x++, bits += 3) {
752 XPutPixel( bmpImage, x, h,
753 COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
755 bits = (srcbits += linebytes) + left * 3;
759 for (h = 0; h < lines; h++) {
760 for (x = left; x < dstwidth; x++, bits += 3) {
761 XPutPixel( bmpImage, x, h,
762 COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
764 bits = (srcbits += linebytes) + left * 3;
770 /***********************************************************************
771 * DIB_SetImageBits_32
773 * SetDIBits for a 32-bit deep DIB.
775 static void DIB_SetImageBits_32( int lines, const BYTE *srcbits,
776 DWORD srcwidth, DWORD dstwidth, int left,
777 DC *dc, XImage *bmpImage )
780 const BYTE *bits = srcbits + left * 4;
783 DWORD linebytes = (srcwidth * 4);
788 for (h = lines - 1; h >= 0; h--) {
789 for (x = left; x < dstwidth; x++, bits += 4) {
790 XPutPixel( bmpImage, x, h,
791 COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
793 bits = (srcbits += linebytes) + left * 4;
797 for (h = 0; h < lines; h++) {
798 for (x = left; x < dstwidth; x++, bits += 4) {
799 XPutPixel( bmpImage, x, h,
800 COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
802 bits = (srcbits += linebytes) + left * 4;
808 /***********************************************************************
811 * Transfer the bits to an X image.
812 * Helper function for SetDIBits() and SetDIBitsToDevice().
813 * The Xlib critical section must be entered before calling this function.
815 static int DIB_SetImageBits( const DIB_SETIMAGEBITS_DESCR *descr )
821 /* Translate the color mapping table */
823 if (descr->infoBpp > 8) colorMapping = NULL;
824 else if (!(colorMapping = DIB_PhysicalColorMap( descr->dc, descr->depth,
825 descr->colorMap, descr->nColorMap )))
828 if( descr->dc->w.flags & DC_DIRTY ) CLIPPING_UpdateGCRegion(descr->dc);
830 /* Transfer the pixels */
831 lines = descr->lines;
832 if (lines < 0) lines = -lines;
833 XCREATEIMAGE(bmpImage, descr->infoWidth, lines, descr->depth );
835 switch(descr->infoBpp)
838 DIB_SetImageBits_1( descr->lines, descr->bits, descr->infoWidth,
839 descr->width, descr->xSrc, colorMapping, bmpImage );
842 if (descr->compression) DIB_SetImageBits_RLE4( descr->lines, descr->bits,
843 descr->infoWidth, descr->width, descr->xSrc,
844 colorMapping, bmpImage );
845 else DIB_SetImageBits_4( descr->lines, descr->bits, descr->infoWidth,
846 descr->width, descr->xSrc, colorMapping, bmpImage );
849 if (descr->compression) DIB_SetImageBits_RLE8( descr->lines, descr->bits,
850 descr->infoWidth, descr->width, descr->xSrc,
851 colorMapping, bmpImage );
852 else DIB_SetImageBits_8( descr->lines, descr->bits, descr->infoWidth,
853 descr->width, descr->xSrc, colorMapping, bmpImage );
857 DIB_SetImageBits_16( descr->lines, descr->bits, descr->infoWidth,
858 descr->width, descr->xSrc, descr->dc, bmpImage);
861 DIB_SetImageBits_24( descr->lines, descr->bits, descr->infoWidth,
862 descr->width, descr->xSrc, descr->dc, bmpImage );
865 DIB_SetImageBits_32( descr->lines, descr->bits, descr->infoWidth,
866 descr->width, descr->xSrc, descr->dc, bmpImage);
869 WARN(bitmap, "(%d): Invalid depth\n", descr->infoBpp );
872 if (colorMapping) HeapFree( GetProcessHeap(), 0, colorMapping );
873 XPutImage( display, descr->drawable, descr->gc, bmpImage,
874 descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
875 descr->width, descr->height );
876 XDestroyImage( bmpImage );
881 /***********************************************************************
882 * StretchDIBits16 (GDI.439)
884 INT16 WINAPI StretchDIBits16(HDC16 hdc, INT16 xDst, INT16 yDst, INT16 widthDst,
885 INT16 heightDst, INT16 xSrc, INT16 ySrc, INT16 widthSrc,
886 INT16 heightSrc, const VOID *bits,
887 const BITMAPINFO *info, UINT16 wUsage, DWORD dwRop )
889 return (INT16)StretchDIBits32( hdc, xDst, yDst, widthDst, heightDst,
890 xSrc, ySrc, widthSrc, heightSrc, bits,
891 info, wUsage, dwRop );
895 /***********************************************************************
896 * StretchDIBits32 (GDI32.351)
898 INT32 WINAPI StretchDIBits32(HDC32 hdc, INT32 xDst, INT32 yDst, INT32 widthDst,
899 INT32 heightDst, INT32 xSrc, INT32 ySrc, INT32 widthSrc,
900 INT32 heightSrc, const void *bits,
901 const BITMAPINFO *info, UINT32 wUsage, DWORD dwRop )
903 HBITMAP32 hBitmap, hOldBitmap;
906 hBitmap = CreateDIBitmap32( hdc, &info->bmiHeader, CBM_INIT,
907 bits, info, wUsage );
908 hdcMem = CreateCompatibleDC32( hdc );
909 hOldBitmap = SelectObject32( hdcMem, hBitmap );
910 StretchBlt32( hdc, xDst, yDst, widthDst, heightDst,
911 hdcMem, xSrc, ySrc, widthSrc, heightSrc, dwRop );
912 SelectObject32( hdcMem, hOldBitmap );
913 DeleteDC32( hdcMem );
914 DeleteObject32( hBitmap );
919 /***********************************************************************
920 * SetDIBits16 (GDI.440)
922 INT16 WINAPI SetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
923 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
926 return SetDIBits32( hdc, hbitmap, startscan, lines, bits, info, coloruse );
930 /******************************************************************************
931 * SetDIBits32 [GDI32.312] Sets pixels in a bitmap using colors from DIB
934 * hdc [I] Handle to device context
935 * hbitmap [I] Handle to bitmap
936 * startscan [I] Starting scan line
937 * lines [I] Number of scan lines
938 * bits [I] Array of bitmap bits
939 * info [I] Address of structure with data
940 * coloruse [I] Type of color indexes to use
943 * Success: Number of scan lines copied
946 INT32 WINAPI SetDIBits32( HDC32 hdc, HBITMAP32 hbitmap, UINT32 startscan,
947 UINT32 lines, LPCVOID bits, const BITMAPINFO *info,
950 DIB_SETIMAGEBITS_DESCR descr;
952 int height, tmpheight;
955 /* Check parameters */
957 descr.dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
960 descr.dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
961 if (!descr.dc) return 0;
963 if (!(bmp = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
965 GDI_HEAP_UNLOCK( hdc );
968 if (DIB_GetBitmapInfo( &info->bmiHeader, &descr.infoWidth, &height,
969 &descr.infoBpp, &descr.compression ) == -1)
971 GDI_HEAP_UNLOCK( hbitmap );
972 GDI_HEAP_UNLOCK( hdc );
976 if (height < 0) height = -height;
977 if (!lines || (startscan >= height))
979 GDI_HEAP_UNLOCK( hbitmap );
980 GDI_HEAP_UNLOCK( hdc );
983 if (startscan + lines > height) lines = height - startscan;
985 if (descr.infoBpp <= 8)
987 descr.colorMap = DIB_BuildColorMap( info, coloruse == DIB_PAL_COLORS?
988 descr.dc->w.hPalette : 0,
993 GDI_HEAP_UNLOCK( hbitmap );
994 GDI_HEAP_UNLOCK( hdc );
1002 descr.lines = tmpheight >= 0 ? lines : -lines;
1003 descr.depth = bmp->bitmap.bmBitsPixel;
1004 descr.drawable = bmp->pixmap;
1005 descr.gc = BITMAP_GC(bmp);
1009 descr.yDest = height - startscan - lines;
1010 descr.width = bmp->bitmap.bmWidth;
1011 descr.height = lines;
1013 EnterCriticalSection( &X11DRV_CritSection );
1014 result = CALL_LARGE_STACK( DIB_SetImageBits, &descr );
1015 LeaveCriticalSection( &X11DRV_CritSection );
1017 HeapFree(GetProcessHeap(), 0, descr.colorMap);
1019 GDI_HEAP_UNLOCK( hdc );
1020 GDI_HEAP_UNLOCK( hbitmap );
1025 /***********************************************************************
1026 * SetDIBitsToDevice16 (GDI.443)
1028 INT16 WINAPI SetDIBitsToDevice16(HDC16 hdc, INT16 xDest, INT16 yDest, INT16 cx,
1029 INT16 cy, INT16 xSrc, INT16 ySrc, UINT16 startscan,
1030 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
1033 return SetDIBitsToDevice32( hdc, xDest, yDest, cx, cy, xSrc, ySrc,
1034 startscan, lines, bits, info, coloruse );
1038 /***********************************************************************
1039 * SetDIBitsToDevice32 (GDI32.313)
1041 INT32 WINAPI SetDIBitsToDevice32(HDC32 hdc, INT32 xDest, INT32 yDest, DWORD cx,
1042 DWORD cy, INT32 xSrc, INT32 ySrc, UINT32 startscan,
1043 UINT32 lines, LPCVOID bits, const BITMAPINFO *info,
1046 DIB_SETIMAGEBITS_DESCR descr;
1048 DWORD width, oldcy = cy;
1050 int height, tmpheight;
1052 /* Check parameters */
1054 dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1057 dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
1060 if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height,
1061 &descr.infoBpp, &descr.compression ) == -1)
1064 if (height < 0) height = -height;
1065 if (!lines || (startscan >= height)) return 0;
1066 if (startscan + lines > height) lines = height - startscan;
1067 if (ySrc < startscan) ySrc = startscan;
1068 else if (ySrc >= startscan + lines) return 0;
1069 if (xSrc >= width) return 0;
1070 if (ySrc + cy >= startscan + lines) cy = startscan + lines - ySrc;
1071 if (xSrc + cx >= width) cx = width - xSrc;
1072 if (!cx || !cy) return 0;
1074 DC_SetupGCForText( dc ); /* To have the correct colors */
1075 TSXSetFunction( display, dc->u.x.gc, DC_XROPfunction[dc->w.ROPmode-1] );
1078 if (descr.infoBpp <= 8)
1080 descr.colorMap = DIB_BuildColorMap( info, coloruse == DIB_PAL_COLORS?
1081 descr.dc->w.hPalette : 0,
1084 if (!descr.colorMap)
1088 descr.lines = tmpheight >= 0 ? lines : -lines;
1089 descr.infoWidth = width;
1090 descr.depth = dc->w.bitsPerPixel;
1091 descr.drawable = dc->u.x.drawable;
1092 descr.gc = dc->u.x.gc;
1094 descr.ySrc = tmpheight >= 0 ? lines-(ySrc-startscan)-cy+(oldcy-cy) : ySrc - startscan;
1095 descr.xDest = dc->w.DCOrgX + XLPTODP( dc, xDest );
1096 descr.yDest = dc->w.DCOrgY + YLPTODP( dc, yDest ) + (tmpheight >= 0 ? oldcy-cy : 0);
1100 EnterCriticalSection( &X11DRV_CritSection );
1101 result = CALL_LARGE_STACK( DIB_SetImageBits, &descr );
1102 LeaveCriticalSection( &X11DRV_CritSection );
1104 HeapFree(GetProcessHeap(), 0, descr.colorMap);
1108 /***********************************************************************
1109 * SetDIBColorTable32 (GDI32.311)
1111 UINT32 WINAPI SetDIBColorTable32( HDC32 hdc, UINT32 startpos, UINT32 entries,
1115 PALETTEENTRY * palEntry;
1116 PALETTEOBJ * palette;
1119 dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1122 dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
1126 if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
1131 /* Transfer color info */
1133 if (dc->w.bitsPerPixel <= 8) {
1134 palEntry = palette->logpalette.palPalEntry + startpos;
1135 if (startpos + entries > (1 << dc->w.bitsPerPixel)) {
1136 entries = (1 << dc->w.bitsPerPixel) - startpos;
1138 for (end = colors + entries; colors < end; palEntry++, colors++)
1140 palEntry->peRed = colors->rgbRed;
1141 palEntry->peGreen = colors->rgbGreen;
1142 palEntry->peBlue = colors->rgbBlue;
1147 GDI_HEAP_UNLOCK( dc->w.hPalette );
1151 /***********************************************************************
1152 * GetDIBColorTable32 (GDI32.169)
1154 UINT32 WINAPI GetDIBColorTable32( HDC32 hdc, UINT32 startpos, UINT32 entries,
1158 PALETTEENTRY * palEntry;
1159 PALETTEOBJ * palette;
1162 dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1165 dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
1169 if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
1174 /* Transfer color info */
1176 if (dc->w.bitsPerPixel <= 8) {
1177 palEntry = palette->logpalette.palPalEntry + startpos;
1178 if (startpos + entries > (1 << dc->w.bitsPerPixel)) {
1179 entries = (1 << dc->w.bitsPerPixel) - startpos;
1181 for (end = colors + entries; colors < end; palEntry++, colors++)
1183 colors->rgbRed = palEntry->peRed;
1184 colors->rgbGreen = palEntry->peGreen;
1185 colors->rgbBlue = palEntry->peBlue;
1186 colors->rgbReserved = 0;
1191 GDI_HEAP_UNLOCK( dc->w.hPalette );
1195 /***********************************************************************
1196 * GetDIBits16 (GDI.441)
1198 INT16 WINAPI GetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
1199 UINT16 lines, LPSTR bits, BITMAPINFO * info,
1202 return GetDIBits32( hdc, hbitmap, startscan, lines, bits, info, coloruse );
1206 /******************************************************************************
1207 * GetDIBits32 [GDI32.170] Retrieves bits of bitmap and copies to buffer
1210 * Success: Number of scan lines copied from bitmap
1213 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/func/src/f30_14.htm
1215 INT32 WINAPI GetDIBits32(
1216 HDC32 hdc, /* [in] Handle to device context */
1217 HBITMAP32 hbitmap, /* [in] Handle to bitmap */
1218 UINT32 startscan, /* [in] First scan line to set in dest bitmap */
1219 UINT32 lines, /* [in] Number of scan lines to copy */
1220 LPSTR bits, /* [out] Address of array for bitmap bits */
1221 BITMAPINFO * info, /* [out] Address of structure with bitmap data */
1222 UINT32 coloruse) /* [in] RGB or palette index */
1226 PALETTEENTRY * palEntry;
1227 PALETTEOBJ * palette;
1231 if (!lines) return 0;
1232 dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1235 dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
1238 if (!(bmp = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
1240 if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
1242 GDI_HEAP_UNLOCK( hbitmap );
1246 /* Transfer color info */
1248 if (info->bmiHeader.biBitCount<=8) {
1249 palEntry = palette->logpalette.palPalEntry;
1250 for (i = 0; i < info->bmiHeader.biClrUsed; i++, palEntry++)
1252 if (coloruse == DIB_RGB_COLORS)
1254 info->bmiColors[i].rgbRed = palEntry->peRed;
1255 info->bmiColors[i].rgbGreen = palEntry->peGreen;
1256 info->bmiColors[i].rgbBlue = palEntry->peBlue;
1257 info->bmiColors[i].rgbReserved = 0;
1259 else ((WORD *)info->bmiColors)[i] = (WORD)i;
1266 int pad, yend, xend = bmp->bitmap.bmWidth;
1268 TRACE(bitmap, "%u scanlines of (%i,%i) -> (%i,%i) starting from %u\n",
1269 lines, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1270 (int)info->bmiHeader.biWidth, (int)info->bmiHeader.biHeight, startscan );
1272 /* adjust number of scanlines to copy */
1274 if( lines > info->bmiHeader.biHeight ) lines = info->bmiHeader.biHeight;
1275 yend = startscan + lines;
1276 if( startscan >= bmp->bitmap.bmHeight )
1278 GDI_HEAP_UNLOCK( hbitmap );
1279 GDI_HEAP_UNLOCK( dc->w.hPalette );
1282 if( yend > bmp->bitmap.bmHeight ) yend = bmp->bitmap.bmHeight;
1284 /* adjust scanline width */
1286 pad = info->bmiHeader.biWidth - bmp->bitmap.bmWidth;
1289 /* bitmap is wider than DIB, copy only a part */
1292 xend = info->bmiHeader.biWidth;
1295 EnterCriticalSection( &X11DRV_CritSection );
1296 bmpImage = (XImage *)CALL_LARGE_STACK( BITMAP_GetXImage, bmp );
1298 switch( info->bmiHeader.biBitCount )
1301 /* pad up to 32 bit */
1302 pad += (4 - (info->bmiHeader.biWidth & 3)) & 3;
1303 for( y = yend - 1; (int)y >= (int)startscan; y-- )
1305 for( x = 0; x < xend; x++ )
1306 *bbits++ = XGetPixel( bmpImage, x, y );
1311 pad += ((32 - (info->bmiHeader.biWidth & 31)) / 8) & 3;
1312 for( y = yend - 1; (int)y >= (int)startscan; y-- )
1315 for( x = 0; x < xend; x++ ) {
1317 *bbits |= XGetPixel( bmpImage, x, y)<<(7-(x&7));
1327 pad += ((8 - (info->bmiHeader.biWidth & 7)) / 2) & 3;
1328 for( y = yend - 1; (int)y >= (int)startscan; y-- )
1331 for( x = 0; x < xend; x++ ) {
1333 *bbits |= XGetPixel( bmpImage, x, y)<<(4*(1-(x&1)));
1344 pad += (4 - ((info->bmiHeader.biWidth*2) & 3)) & 3;
1345 for( y = yend - 1; (int)y >= (int)startscan; y-- )
1348 for( x = 0; x < xend; x++ ) {
1349 unsigned long pixel=XGetPixel( bmpImage, x, y);
1350 *bbits++ = pixel & 0xff;
1351 *bbits++ = (pixel >> 8) & 0xff;
1357 pad += (4 - ((info->bmiHeader.biWidth*3) & 3)) & 3;
1358 for( y = yend - 1; (int)y >= (int)startscan; y-- )
1361 for( x = 0; x < xend; x++ ) {
1362 unsigned long pixel=XGetPixel( bmpImage, x, y);
1363 *bbits++ = (pixel >>16) & 0xff;
1364 *bbits++ = (pixel >> 8) & 0xff;
1365 *bbits++ = pixel & 0xff;
1371 for( y = yend - 1; (int)y >= (int)startscan; y-- )
1374 for( x = 0; x < xend; x++ ) {
1375 unsigned long pixel=XGetPixel( bmpImage, x, y);
1376 *bbits++ = (pixel >>16) & 0xff;
1377 *bbits++ = (pixel >> 8) & 0xff;
1378 *bbits++ = pixel & 0xff;
1383 WARN(bitmap,"Unsupported depth %d\n",
1384 info->bmiHeader.biBitCount);
1388 XDestroyImage( bmpImage );
1389 LeaveCriticalSection( &X11DRV_CritSection );
1391 info->bmiHeader.biCompression = 0;
1393 else if( info->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) )
1395 /* fill in struct members */
1397 info->bmiHeader.biWidth = bmp->bitmap.bmWidth;
1398 info->bmiHeader.biHeight = bmp->bitmap.bmHeight;
1399 info->bmiHeader.biPlanes = 1;
1400 info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel;
1401 info->bmiHeader.biSizeImage = bmp->bitmap.bmHeight *
1402 DIB_GetDIBWidthBytes( bmp->bitmap.bmWidth,
1403 bmp->bitmap.bmBitsPixel );
1404 info->bmiHeader.biCompression = 0;
1407 GDI_HEAP_UNLOCK( hbitmap );
1408 GDI_HEAP_UNLOCK( dc->w.hPalette );
1413 /***********************************************************************
1414 * CreateDIBitmap16 (GDI.442)
1416 HBITMAP16 WINAPI CreateDIBitmap16( HDC16 hdc, const BITMAPINFOHEADER * header,
1417 DWORD init, LPCVOID bits, const BITMAPINFO * data,
1420 return CreateDIBitmap32( hdc, header, init, bits, data, coloruse );
1424 /***********************************************************************
1425 * CreateDIBitmap32 (GDI32.37)
1427 HBITMAP32 WINAPI CreateDIBitmap32( HDC32 hdc, const BITMAPINFOHEADER *header,
1428 DWORD init, LPCVOID bits, const BITMAPINFO *data,
1438 if (DIB_GetBitmapInfo( header, &width, &height, &bpp, &compr ) == -1) return 0;
1439 if (height < 0) height = -height;
1441 /* Check if we should create a monochrome or color bitmap. */
1442 /* We create a monochrome bitmap only if it has exactly 2 */
1443 /* colors, which are either black or white, nothing else. */
1444 /* In all other cases, we create a color bitmap. */
1446 if (bpp != 1) fColor = TRUE;
1447 else if ((coloruse != DIB_RGB_COLORS) ||
1448 (init != CBM_INIT) || !data) fColor = FALSE;
1451 if (data->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
1453 RGBQUAD *rgb = data->bmiColors;
1454 DWORD col = RGB( rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue );
1455 if ((col == RGB(0,0,0)) || (col == RGB(0xff,0xff,0xff)))
1458 col = RGB( rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue );
1459 fColor = ((col != RGB(0,0,0)) && (col != RGB(0xff,0xff,0xff)));
1463 else if (data->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
1465 RGBTRIPLE *rgb = ((BITMAPCOREINFO *)data)->bmciColors;
1466 DWORD col = RGB( rgb->rgbtRed, rgb->rgbtGreen, rgb->rgbtBlue );
1467 if ((col == RGB(0,0,0)) || (col == RGB(0xff,0xff,0xff)))
1470 col = RGB( rgb->rgbtRed, rgb->rgbtGreen, rgb->rgbtBlue );
1471 fColor = ((col != RGB(0,0,0)) && (col != RGB(0xff,0xff,0xff)));
1477 WARN(bitmap, "(%ld): wrong size for data\n",
1478 data->bmiHeader.biSize );
1483 /* Now create the bitmap */
1485 handle = fColor ? CreateBitmap32( width, height, 1, screenDepth, NULL ) :
1486 CreateBitmap32( width, height, 1, 1, NULL );
1487 if (!handle) return 0;
1489 if (init == CBM_INIT)
1490 SetDIBits32( hdc, handle, 0, height, bits, data, coloruse );
1494 /***********************************************************************
1495 * CreateDIBSection16 (GDI.489)
1497 HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
1498 LPVOID **bits, HANDLE16 section,
1501 return CreateDIBSection32(hdc, bmi, usage, bits, section, offset);
1504 /***********************************************************************
1505 * CreateDIBSection32 (GDI32.36)
1507 HBITMAP32 WINAPI CreateDIBSection32 (HDC32 hdc, BITMAPINFO *bmi, UINT32 usage,
1508 LPVOID **bits,HANDLE32 section,
1512 BITMAPOBJ *bmp = NULL;
1513 DIBSECTION *dib = NULL;
1514 RGBQUAD *colorMap = NULL;
1517 /* Fill BITMAP32 structure with DIB data */
1518 BITMAPINFOHEADER *bi = &bmi->bmiHeader;
1521 TRACE(bitmap, "format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
1522 bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
1523 bi->biSizeImage, bi->biClrUsed, usage == DIB_PAL_COLORS? "PAL" : "RGB");
1525 if (bi->biCompression)
1527 FIXME(bitmap, "Compression not implemented!\n");
1532 bm.bmWidth = bi->biWidth;
1533 bm.bmHeight = bi->biHeight;
1534 bm.bmWidthBytes = DIB_GetDIBWidthBytes(bm.bmWidth, bi->biBitCount);
1535 bm.bmPlanes = bi->biPlanes;
1536 bm.bmBitsPixel = bi->biBitCount;
1539 /* Get storage location for DIB bits */
1541 FIXME(bitmap, "section != NULL not implemented!\n");
1544 INT32 totalSize = bi->biSizeImage? bi->biSizeImage
1545 : bm.bmWidthBytes * bm.bmHeight;
1547 bm.bmBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, totalSize);
1550 /* Allocate Memory for DIB and fill structure */
1552 dib = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DIBSECTION));
1557 /* FIXME: dib->dsBitfields ??? */
1558 dib->dshSection = section;
1559 dib->dsOffset = offset;
1562 /* Create Color Map */
1563 if (dib && bm.bmBitsPixel <= 8)
1565 HPALETTE16 hPalette = 0;
1566 if (usage == DIB_PAL_COLORS)
1568 DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
1570 dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
1573 hPalette = dc->w.hPalette;
1574 GDI_HEAP_UNLOCK(hdc);
1577 colorMap = DIB_BuildColorMap(bmi, hPalette, &nColorMap);
1580 /* Create Device Dependent Bitmap and add DIB/ColorMap info */
1583 res = CreateDIBitmap32(hdc, bi, 0, NULL, bmi, usage);
1584 bmp = (BITMAPOBJ *) GDI_GetObjPtr(res, BITMAP_MAGIC);
1587 bmp->dibSection = dib;
1588 bmp->colorMap = colorMap;
1589 bmp->nColorMap = nColorMap;
1590 GDI_HEAP_UNLOCK(res);
1594 /* Clean up in case of errors */
1595 if (!res || !bmp || !dib || !bm.bmBits || (bm.bmBitsPixel <= 8 && !colorMap))
1597 if (bm.bmBits && section)
1598 HeapFree(GetProcessHeap(), 0, bm.bmBits), bm.bmBits = NULL;
1600 if (colorMap) HeapFree(GetProcessHeap(), 0, colorMap), colorMap = NULL;
1601 if (dib) HeapFree(GetProcessHeap(), 0, dib), dib = NULL;
1602 if (res) DeleteObject32(res), res = 0;
1605 /* Return BITMAP handle and storage location */
1606 if (bm.bmBits && bits) *bits = bm.bmBits;
1610 /***********************************************************************
1611 * DIB_UpdateDIBSection
1613 void DIB_UpdateDIBSection( DC *dc, BOOL32 toDIB )
1618 /* Ensure this is a Compatible DC that has a DIB section selected */
1621 if (!(dc->w.flags & DC_MEMORY)) return;
1623 bmp = (BITMAPOBJ *)GDI_GetObjPtr( dc->w.hBitmap, BITMAP_MAGIC );
1626 dib = bmp->dibSection;
1629 GDI_HEAP_UNLOCK(dc->w.hBitmap);
1634 /* Copy Pixmap to bits */
1637 /* Expect colour corruption if you uncomment this. -MF */
1639 // bi.bmiHeader = dib->dsBmih;
1640 // bi.bmiHeader.biClrUsed = 0; /* don't copy palette */
1641 // TRACE(bitmap, "Copying from Pixmap to DIB bits\n");
1642 // GetDIBits32( dc->hSelf, dc->w.hBitmap, 0, dib->dsBmih.biHeight,
1643 // dib->dsBm.bmBits, &bi, 0 );
1646 /* Copy bits to Pixmap */
1649 DIB_SETIMAGEBITS_DESCR descr;
1651 TRACE(bitmap, "Copying from DIB bits to Pixmap\n");
1652 if (DIB_GetBitmapInfo( &dib->dsBmih, &descr.infoWidth, &descr.lines,
1653 &descr.infoBpp, &descr.compression ) == -1)
1655 GDI_HEAP_UNLOCK(dc->w.hBitmap);
1660 descr.colorMap = bmp->colorMap;
1661 descr.nColorMap = bmp->nColorMap;
1662 descr.bits = dib->dsBm.bmBits;
1663 descr.depth = bmp->bitmap.bmBitsPixel;
1664 descr.drawable = bmp->pixmap;
1665 descr.gc = BITMAP_GC(bmp);
1670 descr.width = bmp->bitmap.bmWidth;
1671 descr.height = bmp->bitmap.bmHeight;
1673 EnterCriticalSection( &X11DRV_CritSection );
1674 CALL_LARGE_STACK( DIB_SetImageBits, &descr );
1675 LeaveCriticalSection( &X11DRV_CritSection );
1678 GDI_HEAP_UNLOCK(dc->w.hBitmap);