1 | unit UMethodBitmapRawImageData;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, UDrawMethod, UFastBitmap, Graphics, GraphType;
|
---|
9 |
|
---|
10 | type
|
---|
11 | { TMethodBitmapRawImageData }
|
---|
12 |
|
---|
13 | TMethodBitmapRawImageData = class(TDrawMethodImage)
|
---|
14 | constructor Create; override;
|
---|
15 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
---|
16 | end;
|
---|
17 |
|
---|
18 |
|
---|
19 | implementation
|
---|
20 |
|
---|
21 | { TMethodBitmapRawImageData }
|
---|
22 |
|
---|
23 | constructor TMethodBitmapRawImageData.Create;
|
---|
24 | begin
|
---|
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.');
|
---|
29 | end;
|
---|
30 |
|
---|
31 | procedure TMethodBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap);
|
---|
32 | var
|
---|
33 | Y, X: Integer;
|
---|
34 | PixelPtr: PCardinal;
|
---|
35 | RowPtr: PCardinal;
|
---|
36 | P: TPixelFormat;
|
---|
37 | RawImage: TRawImage;
|
---|
38 | BytePerPixel: Integer;
|
---|
39 | BytePerRow: Integer;
|
---|
40 | begin
|
---|
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;
|
---|
60 | end;
|
---|
61 |
|
---|
62 |
|
---|
63 | end.
|
---|
64 |
|
---|