source: trunk/Methods/UMethodBitmapScanline.pas

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