-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCEF_LCL_Image.inc
156 lines (142 loc) · 5.03 KB
/
CEF_LCL_Image.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//----------------------------------------
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Lazarus.modifiedLGPL
//----------------------------------------
procedure CEFImage_New(var Result: ICefImage); extdecl;
begin
handleExceptionBegin
Result := TCefImageRef.New;
handleExceptionEnd
end;
function CEFImage_AddPng(const TObj: ICefImage; scaleFactor: PSingle; const pngData: Pointer; pngDataSize: NativeUInt): longbool; extdecl;
begin
handleExceptionBegin
Result := TObj.AddPng(Single(scaleFactor^), pngData, pngDataSize);
handleExceptionEnd
end;
function CEFImage_AddJpeg(const TObj: ICefImage; scaleFactor: PSingle; const pngData: Pointer; pngDataSize: NativeUInt): longbool; extdecl;
begin
handleExceptionBegin
Result := TObj.AddJpeg(Single(scaleFactor^), pngData, pngDataSize);
handleExceptionEnd
end;
function CEFImage_GetWidth(const TObj: ICefImage): integer; extdecl;
begin
handleExceptionBegin
Result := Integer(TObj.GetWidth());
handleExceptionEnd
end;
function CEFImage_GetHeight(const TObj: ICefImage): integer; extdecl;
begin
handleExceptionBegin
Result := Integer(TObj.GetHeight());
handleExceptionEnd
end;
function CEFImage_AddBitmap(const TObj: ICefImage; scaleFactor: PSingle; pixelWidth, pixelHeight: Integer; colorType: Integer; alphaType: Integer; const pixelData: Pointer; pixelDataSize: NativeUInt): longbool; extdecl;
var
ct: TCefColorType;
at: TCefAlphaType;
begin
handleExceptionBegin
//colorType = TCefColorType = (
// CEF_COLOR_TYPE_RGBA_8888,
// CEF_COLOR_TYPE_BGRA_8888
//);
//alphaType = TCefAlphaType = (
// CEF_ALPHA_TYPE_OPAQUE,
// CEF_ALPHA_TYPE_PREMULTIPLIED,
// CEF_ALPHA_TYPE_POSTMULTIPLIED
//);
if colorType = 0 then
ct := TCefColorType.CEF_COLOR_TYPE_RGBA_8888
else if colorType = 1 then
ct := TCefColorType.CEF_COLOR_TYPE_BGRA_8888
else
ct := TCefColorType.CEF_COLOR_TYPE_RGBA_8888;
if alphaType = 0 then
at := TCefAlphaType.CEF_ALPHA_TYPE_OPAQUE
else if alphaType = 1 then
at := TCefAlphaType.CEF_ALPHA_TYPE_PREMULTIPLIED
else if alphaType = 1 then
at := TCefAlphaType.CEF_ALPHA_TYPE_POSTMULTIPLIED
else
at := TCefAlphaType.CEF_ALPHA_TYPE_OPAQUE;
Result := TObj.AddBitmap(Single(scaleFactor^), pixelWidth, pixelHeight, ct, at, pixelData, pixelDataSize);
handleExceptionEnd
end;
function CEFImage_HasRepresentation(const TObj: ICefImage; scaleFactor: PSingle): longbool; extdecl;
begin
handleExceptionBegin
Result := TObj.HasRepresentation(Single(scaleFactor^));
handleExceptionEnd
end;
function CEFImage_RemoveRepresentation(const TObj: ICefImage; scaleFactor: PSingle): longbool; extdecl;
begin
handleExceptionBegin
Result := TObj.RemoveRepresentation(Single(scaleFactor^));
handleExceptionEnd
end;
function CEFImage_GetRepresentationInfo(const TObj: ICefImage; scaleFactor: PSingle; var actualScaleFactor: PSingle; var pixelWidth, pixelHeight: Integer): longbool; extdecl;
begin
handleExceptionBegin
Result := TObj.GetRepresentationInfo(Single(scaleFactor^), Single(actualScaleFactor^), pixelWidth, pixelHeight);
handleExceptionEnd
end;
procedure CEFImage_GetAsBitmap(const TObj: ICefImage; scaleFactor: PSingle; colorType: Integer; alphaType: Integer; var pixelWidth, pixelHeight: Integer; var Result: ICefBinaryValue); extdecl;
var
ct: TCefColorType;
at: TCefAlphaType;
begin
handleExceptionBegin
//colorType = TCefColorType = (
// CEF_COLOR_TYPE_RGBA_8888,
// CEF_COLOR_TYPE_BGRA_8888
//);
//alphaType = TCefAlphaType = (
// CEF_ALPHA_TYPE_OPAQUE,
// CEF_ALPHA_TYPE_PREMULTIPLIED,
// CEF_ALPHA_TYPE_POSTMULTIPLIED
//);
if colorType = 0 then
ct := TCefColorType.CEF_COLOR_TYPE_RGBA_8888
else if colorType = 1 then
ct := TCefColorType.CEF_COLOR_TYPE_BGRA_8888
else
ct := TCefColorType.CEF_COLOR_TYPE_RGBA_8888;
if alphaType = 0 then
at := TCefAlphaType.CEF_ALPHA_TYPE_OPAQUE
else if alphaType = 1 then
at := TCefAlphaType.CEF_ALPHA_TYPE_PREMULTIPLIED
else if alphaType = 1 then
at := TCefAlphaType.CEF_ALPHA_TYPE_POSTMULTIPLIED
else
at := TCefAlphaType.CEF_ALPHA_TYPE_OPAQUE;
Result := TObj.GetAsBitmap(Single(scaleFactor^), ct, at, pixelWidth, pixelHeight);
handleExceptionEnd
end;
procedure CEFImage_GetAsPng(const TObj: ICefImage; scaleFactor: PSingle; withTransparency: longbool; var pixelWidth, pixelHeight: Integer; var Result: ICefBinaryValue); extdecl;
begin
handleExceptionBegin
Result := TObj.GetAsPng(Single(scaleFactor^), withTransparency, pixelWidth, pixelHeight);
handleExceptionEnd
end;
procedure CEFImage_GetAsJpeg(const TObj: ICefImage; scaleFactor: PSingle; quality: Integer; var pixelWidth, pixelHeight: Integer; var Result: ICefBinaryValue); extdecl;
begin
handleExceptionBegin
Result := TObj.GetAsJpeg(Single(scaleFactor^), quality, pixelWidth, pixelHeight);
handleExceptionEnd
end;
exports
CEFImage_New,
CEFImage_AddPng,
CEFImage_AddJpeg,
CEFImage_GetWidth,
CEFImage_GetHeight,
CEFImage_AddBitmap,
CEFImage_HasRepresentation,
CEFImage_RemoveRepresentation,
CEFImage_GetRepresentationInfo,
CEFImage_GetAsBitmap,
CEFImage_GetAsPng,
CEFImage_GetAsJpeg;