forked from ying32/govcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitmap.go
396 lines (329 loc) · 9.08 KB
/
bitmap.go
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
//----------------------------------------
// The code is automatically generated by the GenlibLcl tool.
// Copyright © ying32. All Rights Reserved.
//
// Licensed under Apache License 2.0
//
//----------------------------------------
package vcl
import (
. "github.com/ying32/govcl/vcl/api"
. "github.com/ying32/govcl/vcl/types"
"unsafe"
)
type TBitmap struct {
IGraphic
instance uintptr
// 特殊情况下使用,主要应对Go的GC问题,与LCL没有太多关系。
ptr unsafe.Pointer
}
// 创建一个新的对象。
//
// Create a new object.
func NewBitmap() *TBitmap {
b := new(TBitmap)
b.instance = Bitmap_Create()
b.ptr = unsafe.Pointer(b.instance)
setFinalizer(b, (*TBitmap).Free)
return b
}
// 动态转换一个已存在的对象实例。
//
// Dynamically convert an existing object instance.
func AsBitmap(obj interface{}) *TBitmap {
instance, ptr := getInstance(obj)
if instance == 0 { return nil }
return &TBitmap{instance: instance, ptr: ptr}
}
// -------------------------- Deprecated begin --------------------------
// 新建一个对象来自已经存在的对象实例指针。
//
// Create a new object from an existing object instance pointer.
// Deprecated: use AsBitmap.
func BitmapFromInst(inst uintptr) *TBitmap {
return AsBitmap(inst)
}
// 新建一个对象来自已经存在的对象实例。
//
// Create a new object from an existing object instance.
// Deprecated: use AsBitmap.
func BitmapFromObj(obj IObject) *TBitmap {
return AsBitmap(obj)
}
// 新建一个对象来自不安全的地址。注意:使用此函数可能造成一些不明情况,慎用。
//
// Create a new object from an unsecured address. Note: Using this function may cause some unclear situations and be used with caution..
// Deprecated: use AsBitmap.
func BitmapFromUnsafePointer(ptr unsafe.Pointer) *TBitmap {
return AsBitmap(ptr)
}
// -------------------------- Deprecated end --------------------------
// 释放对象。
//
// Free object.
func (b *TBitmap) Free() {
if b.instance != 0 {
Bitmap_Free(b.instance)
b.instance, b.ptr = 0, nullptr
}
}
// 返回对象实例指针。
//
// Return object instance pointer.
func (b *TBitmap) Instance() uintptr {
return b.instance
}
// 获取一个不安全的地址。
//
// Get an unsafe address.
func (b *TBitmap) UnsafeAddr() unsafe.Pointer {
return b.ptr
}
// 检测地址是否为空。
//
// Check if the address is empty.
func (b *TBitmap) IsValid() bool {
return b.instance != 0
}
// 检测当前对象是否继承自目标对象。
//
// Checks whether the current object is inherited from the target object.
func (b *TBitmap) Is() TIs {
return TIs(b.instance)
}
// 动态转换当前对象为目标对象。
//
// Dynamically convert the current object to the target object.
//func (b *TBitmap) As() TAs {
// return TAs(b.instance)
//}
// 获取类信息指针。
//
// Get class information pointer.
func TBitmapClass() TClass {
return Bitmap_StaticClassType()
}
// 从设备驱动中加载Bitmap。
//
// Load the Bitmap from the device driver.
func (b *TBitmap) LoadFromDevice(ADc HDC) {
Bitmap_LoadFromDevice(b.instance, ADc)
}
// 用于ScanLine属性,aStreamIsValid 默认为 false。
//
// Used for ScanLine property, aStreamIsValid defaults to false.
func (b *TBitmap) EndUpdate(AStreamIsValid bool) {
Bitmap_EndUpdate(b.instance, AStreamIsValid)
}
// 用于ScanLine属性,aCanvasOnly 默认为 false。
//
// Used for ScanLine properties, aCanvasOnly defaults to false.
func (b *TBitmap) BeginUpdate(ACanvasOnly bool) {
Bitmap_BeginUpdate(b.instance, ACanvasOnly)
}
// 清除bitmap数据。
//
// Clear bitmap data.
func (b *TBitmap) Clear() {
Bitmap_Clear(b.instance)
}
// 复制一个对象,如果对象实现了此方法的话。
//
// Copy an object, if the object implements this method.
func (b *TBitmap) Assign(Source IObject) {
Bitmap_Assign(b.instance, CheckPtr(Source))
}
func (b *TBitmap) FreeImage() {
Bitmap_FreeImage(b.instance)
}
// 句柄是否已经分配。
//
// Is the handle already allocated.
func (b *TBitmap) HandleAllocated() bool {
return Bitmap_HandleAllocated(b.instance)
}
// 文件流加载。
func (b *TBitmap) LoadFromStream(Stream IStream) {
Bitmap_LoadFromStream(b.instance, CheckPtr(Stream))
}
// 保存至流。
func (b *TBitmap) SaveToStream(Stream IStream) {
Bitmap_SaveToStream(b.instance, CheckPtr(Stream))
}
func (b *TBitmap) SetSize(AWidth int32, AHeight int32) {
Bitmap_SetSize(b.instance, AWidth , AHeight)
}
func (b *TBitmap) LoadFromResourceName(Instance uintptr, ResName string) {
Bitmap_LoadFromResourceName(b.instance, Instance , ResName)
}
func (b *TBitmap) LoadFromResourceID(Instance uintptr, ResID int32) {
Bitmap_LoadFromResourceID(b.instance, Instance , ResID)
}
// 与一个对象进行比较。
//
// Compare with an object.
func (b *TBitmap) Equals(Obj IObject) bool {
return Bitmap_Equals(b.instance, CheckPtr(Obj))
}
// 从文件加载。
func (b *TBitmap) LoadFromFile(Filename string) {
Bitmap_LoadFromFile(b.instance, Filename)
}
// 保存至文件。
func (b *TBitmap) SaveToFile(Filename string) {
Bitmap_SaveToFile(b.instance, Filename)
}
// 获取类名路径。
//
// Get the class name path.
func (b *TBitmap) GetNamePath() string {
return Bitmap_GetNamePath(b.instance)
}
// 获取类的类型信息。
//
// Get class type information.
func (b *TBitmap) ClassType() TClass {
return Bitmap_ClassType(b.instance)
}
// 获取当前对象类名称。
//
// Get the current object class name.
func (b *TBitmap) ClassName() string {
return Bitmap_ClassName(b.instance)
}
// 获取当前对象实例大小。
//
// Get the current object instance size.
func (b *TBitmap) InstanceSize() int32 {
return Bitmap_InstanceSize(b.instance)
}
// 判断当前类是否继承自指定类。
//
// Determine whether the current class inherits from the specified class.
func (b *TBitmap) InheritsFrom(AClass TClass) bool {
return Bitmap_InheritsFrom(b.instance, AClass)
}
// 获取类的哈希值。
//
// Get the hash value of the class.
func (b *TBitmap) GetHashCode() int32 {
return Bitmap_GetHashCode(b.instance)
}
// 文本类信息。
//
// Text information.
func (b *TBitmap) ToString() string {
return Bitmap_ToString(b.instance)
}
// 获取画布。
func (b *TBitmap) Canvas() *TCanvas {
return AsCanvas(Bitmap_GetCanvas(b.instance))
}
// 获取控件句柄。
//
// Get Control handle.
func (b *TBitmap) Handle() HBITMAP {
return Bitmap_GetHandle(b.instance)
}
// 设置控件句柄。
//
// Set Control handle.
func (b *TBitmap) SetHandle(value HBITMAP) {
Bitmap_SetHandle(b.instance, value)
}
func (b *TBitmap) HandleType() TBitmapHandleType {
return Bitmap_GetHandleType(b.instance)
}
func (b *TBitmap) SetHandleType(value TBitmapHandleType) {
Bitmap_SetHandleType(b.instance, value)
}
func (b *TBitmap) MaskHandle() HBITMAP {
return Bitmap_GetMaskHandle(b.instance)
}
func (b *TBitmap) SetMaskHandle(value HBITMAP) {
Bitmap_SetMaskHandle(b.instance, value)
}
func (b *TBitmap) PixelFormat() TPixelFormat {
return Bitmap_GetPixelFormat(b.instance)
}
func (b *TBitmap) SetPixelFormat(value TPixelFormat) {
Bitmap_SetPixelFormat(b.instance, value)
}
func (b *TBitmap) TransparentMode() TTransparentMode {
return Bitmap_GetTransparentMode(b.instance)
}
func (b *TBitmap) SetTransparentMode(value TTransparentMode) {
Bitmap_SetTransparentMode(b.instance, value)
}
func (b *TBitmap) Empty() bool {
return Bitmap_GetEmpty(b.instance)
}
// 获取高度。
//
// Get height.
func (b *TBitmap) Height() int32 {
return Bitmap_GetHeight(b.instance)
}
// 设置高度。
//
// Set height.
func (b *TBitmap) SetHeight(value int32) {
Bitmap_SetHeight(b.instance, value)
}
// 获取修改。
//
// Get modified.
func (b *TBitmap) Modified() bool {
return Bitmap_GetModified(b.instance)
}
// 设置修改。
//
// Set modified.
func (b *TBitmap) SetModified(value bool) {
Bitmap_SetModified(b.instance, value)
}
func (b *TBitmap) Palette() HPALETTE {
return Bitmap_GetPalette(b.instance)
}
func (b *TBitmap) SetPalette(value HPALETTE) {
Bitmap_SetPalette(b.instance, value)
}
func (b *TBitmap) PaletteModified() bool {
return Bitmap_GetPaletteModified(b.instance)
}
func (b *TBitmap) SetPaletteModified(value bool) {
Bitmap_SetPaletteModified(b.instance, value)
}
// 获取透明。
//
// Get transparent.
func (b *TBitmap) Transparent() bool {
return Bitmap_GetTransparent(b.instance)
}
// 设置透明。
//
// Set transparent.
func (b *TBitmap) SetTransparent(value bool) {
Bitmap_SetTransparent(b.instance, value)
}
// 获取宽度。
//
// Get width.
func (b *TBitmap) Width() int32 {
return Bitmap_GetWidth(b.instance)
}
// 设置宽度。
//
// Set width.
func (b *TBitmap) SetWidth(value int32) {
Bitmap_SetWidth(b.instance, value)
}
// 设置改变事件。
//
// Set changed event.
func (b *TBitmap) SetOnChange(fn TNotifyEvent) {
Bitmap_SetOnChange(b.instance, fn)
}
func (b *TBitmap) ScanLine(Row int32) uintptr {
return Bitmap_GetScanLine(b.instance, Row)
}