From: "Earl F. Glynn" Subject: Re: Color reduction in Canvas.CopyRect? Date: Wednesday, December 06, 2000 1:13 PM "David Lively" wrote in message news:3a2e759d_1@dnews... > When I combine two 24-bit bitmaps (both initialized as DIB's with a > pixelFormat value of pf24Bit) with Canvas.CopyRect, the pasted image data > appears to be reduced from 24-bit to 8-bit. This doesn't happen when I use > Canvas.StretchDraw. Ideas or workarounds? D5 under Win2k. Happens with a > variety of different video cards/chipsets (and, therefore, drivers.). CopyRect is nearly a direct call to the StretchBlt API call. Both Draw and StretchDraw call Graphic.Draw. For a TBitmap, TBitmap.Draw results in a call to StretchBlt (or TransparentStretchBlt). So CopyRect and StretchDraw both use StretchBlt. But there are several things that can happen before StretchBlt is called using StretchDraw. One is a call to SetStretchBltMode(ACanvas.Handle, STRETCH_DELETESCANS); The Windows API documentation says STRETCH_DELETESCANS is "typically used to preserve color in color bitmaps." I have not studied exactly why this may be necessary. In at least one application, I added the following line before a CopyRect to get "better" color: SetStretchBltMode(Bitmap.Canvas.Handle, STRETCH_DELETESCANS); -- efg Earl F. Glynn E-mail: efg2@efg2.com Overland Park, KS USA efg's Computer Lab: http://www.efg2.com/Lab Mirror: http://homepages.borland.com/efg2lab/Default.htm