TTIWPaintBox / CopyRect

Greetings

I have the following phenomena: When using the paintbox.canvas.copyrect-function the color-depth seems to be reduced automatically to 8-bit. stretchdraw and draw do not show this behaviour and show 24-bit images with no problem.

Please advice
Michael

CopyRect performs a copy from one canvas to the other canvas. Have both canvases the same color depth to start with?

Yes they have.

  MyJPEG   := TJPEGImage.Create;
  MyPic    := TPicture.Create;

  MyPic.Bitmap.PixelFormat := pf24bit;
  MyJPEG.PixelFormat          := jf24bit;

  MyJPEG.LoadFromFile('D:\Delphi\u-may Server\Temp'+FileName);

  MyPic.Bitmap.Width := MyJPEG.Width;
  MyPic.Bitmap.Height:= MyJPEG.Height;

  MyPic.BitMap.Assign(MyJPEG);

....

  BildBox.Canvas.CopyRect(recDest,MyPic.Bitmap.Canvas,RecSource);
  BildBox.Repaint;
  BildBox.Refresh;

Strange: Dithering only occurs when the destination rectangle is smaller than the source rectangle. Meaning: When the source picture is computed down to a smaller resolution.

SOLVED: This does the trick:

  SetStretchBltMode(BildBox.Canvas.Handle, STRETCH_DELETESCANS);