source: GraphicTest/Methods/MethodBitmapScanline.pas

Last change on this file was 573, checked in by chronos, 5 months ago
  • Modified: Build with Lazarus 3.4.
  • Modified: Removed U prefix from unit names.
File size: 1.5 KB
Line 
1unit MethodBitmapScanline;
2
3interface
4
5uses
6 LCLIntf, LCLType, Classes, SysUtils, DrawMethod, FastBitmap, Controls, Graphics;
7
8type
9 { TMethodBitmapScanline }
10
11 TMethodBitmapScanline = class(TDrawMethodCanvas)
12 Bitmap: TBitmap;
13 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override;
14 constructor Create; override;
15 destructor Destroy; override;
16 procedure DrawFrame(FastBitmap: TFastBitmap); override;
17 end;
18
19
20implementation
21
22{ TMethodBitmapScanline }
23
24procedure TMethodBitmapScanline.Init(Parent: TWinControl; Size: TPoint;
25 PixelFormat: TPixelFormat);
26begin
27 inherited;
28 Bitmap.SetSize(Size.X, Size.Y);
29end;
30
31constructor TMethodBitmapScanline.Create;
32begin
33 inherited;
34 Caption := 'TBitmap Scanline PaintBox';
35 Bitmap := TBitmap.Create;
36 PaintObject := poCanvas;
37 Description.Add('This method uses TBitmap.ScanLine. ' +
38 'PaintBox is used to display image data.');
39end;
40
41destructor TMethodBitmapScanline.Destroy;
42begin
43 FreeAndNil(Bitmap);
44 inherited;
45end;
46
47procedure TMethodBitmapScanline.DrawFrame(FastBitmap: TFastBitmap);
48var
49 X, Y: Integer;
50 P: PCardinal;
51begin
52 Bitmap.BeginUpdate;
53 with FastBitmap do
54 for Y := 0 to Size.Y - 1 do begin
55 P := Bitmap.ScanLine[Y];
56 for X := 0 to Size.X - 1 do begin
57 P^ := NoSwapBRComponent(Pixels[X, Y]);
58 Inc(P);
59 end;
60 end;
61 Bitmap.EndUpdate;
62 BitBlt(Canvas.Handle, 0, 0, FastBitmap.Size.X, FastBitmap.Size.Y, Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
63end;
64
65end.
66
Note: See TracBrowser for help on using the repository browser.