source: GraphicTest/Methods/MethodBitmapRawImageData.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 MethodBitmapRawImageData;
2
3interface
4
5uses
6 Classes, SysUtils, DrawMethod, FastBitmap, Graphics, GraphType;
7
8type
9 { TMethodBitmapRawImageData }
10
11 TMethodBitmapRawImageData = class(TDrawMethodImage)
12 constructor Create; override;
13 procedure DrawFrame(FastBitmap: TFastBitmap); override;
14 end;
15
16
17implementation
18
19{ TMethodBitmapRawImageData }
20
21constructor TMethodBitmapRawImageData.Create;
22begin
23 inherited;
24 Caption := 'TBitmap.RawImage.Data';
25 Description.Add('Custom TFastBitmap data are converted to visible image bitmap raw data. ' +
26 'Then TImage is responsible for show loaded data.');
27end;
28
29procedure TMethodBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap);
30var
31 Y, X: Integer;
32 PixelPtr: PCardinal;
33 RowPtr: PCardinal;
34 P: TPixelFormat;
35 RawImage: TRawImage;
36 BytePerPixel: Integer;
37 BytePerRow: Integer;
38begin
39 P := Image.Picture.Bitmap.PixelFormat;
40 with FastBitmap do
41 try
42 Image.Picture.Bitmap.BeginUpdate(False);
43 RawImage := Image.Picture.Bitmap.RawImage;
44 RowPtr := PCardinal(RawImage.Data);
45 BytePerPixel := RawImage.Description.BitsPerPixel div 8;
46 BytePerRow := RawImage.Description.BytesPerLine;
47 for Y := 0 to Size.Y - 1 do begin
48 PixelPtr := RowPtr;
49 for X := 0 to Size.X - 1 do begin
50 PixelPtr^ := Pixels[X, Y];
51 Inc(PByte(PixelPtr), BytePerPixel);
52 end;
53 Inc(PByte(RowPtr), BytePerRow);
54 end;
55 finally
56 Image.Picture.Bitmap.EndUpdate(False);
57 end;
58end;
59
60end.
61
Note: See TracBrowser for help on using the repository browser.