weiß jemand, warum unter Linux GTK2 und QT (andere Widgetsets habe ich bisher nicht getestet) nur einmal die Zuweisung des Bitmaps funktioniert? Unter Windows funktioniert es, wie es soll:
Code: Alles auswählen
procedure TForm1.Button1Click(Sender: TObject);
var
LRandomColor: Integer;
begin
if Assigned(FBitmap) then FBitmap.Free;
LRandomColor := Random($FFFFFF);
FBitmap := TBitmap.Create;
FBitmap.SetSize(2, 2);
FBitmap.Canvas.Pixels[0, 0] := clBlack;
FBitmap.Canvas.Pixels[0, 1] := LRandomColor;
FBitmap.Canvas.Pixels[1, 0] := LRandomColor;
FBitmap.Canvas.Pixels[0, 0] := clBlack;
Invalidate;
end;
...
procedure TForm1.FormPaint(Sender: TObject);
begin
if not Assigned(FBitmap) then Exit;
Canvas.Brush.Style := bsImage;
Canvas.Brush.Bitmap := FBitmap;
Canvas.FillRect(0, 0, ClientWidth, ClientHeight);
end;