source: GraphicTest/Methods/UMethodBitmapRawImageData.pas

Last change on this file was 543, checked in by chronos, 4 years ago
  • Modified: Removed drawing methods files and classes to use Method prefix.
  • Added: TBitmap.Scanline and Move draw methods.
File size: 1.6 KB
Line 
1unit UMethodBitmapRawImageData;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, UDrawMethod, UFastBitmap, Graphics, GraphType;
9
10type
11 { TMethodBitmapRawImageData }
12
13 TMethodBitmapRawImageData = class(TDrawMethodImage)
14 constructor Create; override;
15 procedure DrawFrame(FastBitmap: TFastBitmap); override;
16 end;
17
18
19implementation
20
21{ TMethodBitmapRawImageData }
22
23constructor TMethodBitmapRawImageData.Create;
24begin
25 inherited;
26 Caption := 'TBitmap.RawImage.Data';
27 Description.Add('Custom TFastBitmap data are converted to visible image bitmap raw data. ' +
28 'Then TImage is responsible for show loaded data.');
29end;
30
31procedure TMethodBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap);
32var
33 Y, X: Integer;
34 PixelPtr: PCardinal;
35 RowPtr: PCardinal;
36 P: TPixelFormat;
37 RawImage: TRawImage;
38 BytePerPixel: Integer;
39 BytePerRow: Integer;
40begin
41 P := Image.Picture.Bitmap.PixelFormat;
42 with FastBitmap do
43 try
44 Image.Picture.Bitmap.BeginUpdate(False);
45 RawImage := Image.Picture.Bitmap.RawImage;
46 RowPtr := PCardinal(RawImage.Data);
47 BytePerPixel := RawImage.Description.BitsPerPixel div 8;
48 BytePerRow := RawImage.Description.BytesPerLine;
49 for Y := 0 to Size.Y - 1 do begin
50 PixelPtr := RowPtr;
51 for X := 0 to Size.X - 1 do begin
52 PixelPtr^ := Pixels[X, Y];
53 Inc(PByte(PixelPtr), BytePerPixel);
54 end;
55 Inc(PByte(RowPtr), BytePerRow);
56 end;
57 finally
58 Image.Picture.Bitmap.EndUpdate(False);
59 end;
60end;
61
62
63end.
64
Note: See TracBrowser for help on using the repository browser.