2004. június 22., kedd

How to apply the Windows Shutdown screen effect to a bitmap


Problem/Question/Abstract:

I would like to apply this "screening" effect to a bitmap. I have tried PatBlt, DrawState, and BitBlt, but I don't know what combination of params I need.

Answer:

Create an 8 x 8 bitmap, where the pixels alternate black and white (as in a checkerboard).

Load that bitmap into the Brush.Bitmap property of whatever Canvas it is that you're trying to modify.

Set the canvas's CopyMode to $00A000C9. (This ANDs the destination with the pattern).

Use CopyRect to draw the canvas onto itself. Example:

var
  Bmp: TBitmap;
begin
  Bmp := TBitmap.Create;
  Bmp.LoadFromFile('brush.bmp');
  with Image1.Picture.Bitmap do
  begin
    Canvas.Brush.Bitmap := Bmp;
    Canvas.CopyMode := $00A000C9;
    Canvas.CopyRect(Rect(0, 0, Width, Height), Canvas, Rect(0, 0, 0, 0));
  end;
  Bmp.Free;
end;

Nincsenek megjegyzések:

Megjegyzés küldése