1 | unit BGRAMacBitmap;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, BGRALCLBitmap, BGRAGraphics, BGRABitmapTypes;
|
---|
9 |
|
---|
10 | type
|
---|
11 |
|
---|
12 | { TBGRAMacBitmap }
|
---|
13 |
|
---|
14 | TBGRAMacBitmap = class(TBGRALCLBitmap)
|
---|
15 | procedure DataDrawOpaque(ACanvas: TCanvas; Rect: TRect; AData: Pointer;
|
---|
16 | ALineOrder: TRawImageLineOrder; AWidth, AHeight: integer); override;
|
---|
17 | end;
|
---|
18 |
|
---|
19 | implementation
|
---|
20 |
|
---|
21 | uses LCLType, GraphType, LCLIntf, FPimage;
|
---|
22 |
|
---|
23 | procedure DataDrawOpaqueImplementation(ACanvas: TCanvas; Rect: TRect;
|
---|
24 | AData: Pointer; ALineOrder: TRawImageLineOrder; AWidth, AHeight: integer);
|
---|
25 | type
|
---|
26 | PARGB = ^TARGB;
|
---|
27 | TARGB = packed record
|
---|
28 | alpha,red,green,blue: byte;
|
---|
29 | end;
|
---|
30 |
|
---|
31 | var
|
---|
32 | Temp: TBitmap;
|
---|
33 | RawImage: TRawImage;
|
---|
34 | BitmapHandle, MaskHandle: HBitmap;
|
---|
35 | CreateResult: boolean;
|
---|
36 | psrc: PBGRAPixel;
|
---|
37 | pdest: PARGB;
|
---|
38 | n: Integer;
|
---|
39 | begin
|
---|
40 | if (AHeight = 0) or (AWidth = 0) then
|
---|
41 | exit;
|
---|
42 |
|
---|
43 | RawImage.Init;
|
---|
44 | RawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(AWidth,AHeight);
|
---|
45 | RawImage.Description.Depth := 24;
|
---|
46 | RawImage.Description.AlphaPrec := 0;
|
---|
47 | RawImage.Description.LineOrder := ALineOrder;
|
---|
48 | RawImage.Description.LineEnd := rileDWordBoundary;
|
---|
49 | RawImage.CreateData(False);
|
---|
50 | psrc := PBGRAPixel(AData);
|
---|
51 | pdest := PARGB(RawImage.Data);
|
---|
52 | for n := AWidth*AHeight-1 downto 0 do
|
---|
53 | begin
|
---|
54 | pdest^.alpha := 255;
|
---|
55 | pdest^.red := psrc^.red;
|
---|
56 | pdest^.green := psrc^.green;
|
---|
57 | pdest^.blue := psrc^.blue;
|
---|
58 | inc(pdest);
|
---|
59 | inc(psrc);
|
---|
60 | end;
|
---|
61 | CreateResult := RawImage_CreateBitmaps(RawImage, BitmapHandle, MaskHandle, False);
|
---|
62 | RawImage.FreeData;
|
---|
63 |
|
---|
64 | if not CreateResult then
|
---|
65 | raise FPImageException.Create('Failed to create bitmap handle');
|
---|
66 |
|
---|
67 | Temp := TBitmap.Create;
|
---|
68 | Temp.Handle := BitmapHandle;
|
---|
69 | Temp.MaskHandle := MaskHandle;
|
---|
70 | ACanvas.StretchDraw(Rect, Temp);
|
---|
71 | Temp.Free;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | { TBGRAMacBitmap }
|
---|
75 |
|
---|
76 | procedure TBGRAMacBitmap.DataDrawOpaque(ACanvas: TCanvas; Rect: TRect;
|
---|
77 | AData: Pointer; ALineOrder: TRawImageLineOrder; AWidth, AHeight: integer);
|
---|
78 | begin
|
---|
79 | DataDrawOpaqueImplementation(ACanvas, Rect, AData, ALineOrder, AWidth, AHeight);
|
---|
80 | end;
|
---|
81 |
|
---|
82 | end.
|
---|
83 |
|
---|