source: trunk/Packages/bgrabitmap/bgrafpgui.inc

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 2.2 KB
Line 
1{$IFDEF INCLUDE_USES}
2{$UNDEF INCLUDE_USES}
3,fpg_base, fpg_main
4{$ENDIF}
5
6{$IFDEF INCLUDE_INTERFACE}
7{$UNDEF INCLUDE_INTERFACE}
8type
9 TColor = TfpgColor;
10 TRawImage = class(TfpgImage)
11 procedure BGRASetSizeAndTransparency(AWidth,AHeight: Integer; ATransparent: boolean);
12 end;
13 TGUICanvas = TfpgCanvas;
14
15const
16 clNone = fpg_base.clNone;
17 clBlack = fpg_base.clBlack;
18 clWhite = fpg_base.clWhite;
19
20function clRgbBtnHighlight: TColor;
21function clRgbBtnShadow: TColor;
22function ColorToRGB(c: TColor): TColor; inline;
23function RGBToColor(R, G, B: Byte): TColor;
24procedure RedGreenBlue(rgb: TColor; out Red, Green, Blue: Byte); // does not work on system color
25function GetScreenDPIX: integer;
26function GetScreenDPIY: integer;
27{$ENDIF}
28
29{$IFDEF INCLUDE_IMPLEMENTATION}
30{$UNDEF INCLUDE_IMPLEMENTATION}
31
32procedure TRawImage.BGRASetSizeAndTransparency(AWidth,AHeight: Integer; ATransparent: boolean);
33var
34 tempData: pointer;
35begin
36 if (Width <> AWidth) or (Height <> AHeight) then
37 begin
38 AllocateImage(32,AWidth,AHeight);
39 if ATransparent then AllocateMask;
40 end else
41 begin
42 if ATransparent and not Masked then AllocateMask else
43 if not ATransparent and Masked then
44 begin
45 getmem(tempData, ImageDataSize);
46 if tempData <> nil then
47 begin
48 move(ImageData^, tempData^, ImageDataSize);
49 FreeImage;
50 AllocateImage(32,AWidth,AHeight);
51 move(tempData^, ImageData^, ImageDataSize);
52 freemem(tempData);
53 end;
54 end;
55 end;
56end;
57
58function clRgbBtnHighlight: TColor;
59begin
60 result := fpgColorToRGB(fpg_base.clHilite2);
61end;
62
63function clRgbBtnShadow: TColor;
64begin
65 result := fpgColorToRGB(fpg_base.clShadow2);
66end;
67
68function ColorToRGB(c: TColor): TColor; inline;
69begin
70 result := fpgColorToRGB(c);
71end;
72
73function RGBToColor(R, G, B: Byte): TColor;
74begin
75 Result := (R shl 16) or (G shl 8) or B;
76end;
77
78procedure RedGreenBlue(rgb: TColor; out Red, Green, Blue: Byte);
79begin
80 Blue := rgb and $000000ff;
81 Green := (rgb shr 8) and $000000ff;
82 Red := (rgb shr 16) and $000000ff;
83end;
84
85function GetScreenDPIX: integer;
86begin
87 result := fpgApplication.Screen_dpi_x;
88end;
89
90function GetScreenDPIY: integer;
91begin
92 result := fpgApplication.Screen_dpi_y;
93end;
94
95{$ENDIF}
Note: See TracBrowser for help on using the repository browser.