-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathraw_nativeimage.go
55 lines (49 loc) · 2.53 KB
/
raw_nativeimage.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
package electron
import "github.com/gopherjs/gopherjs/js"
// NativeImage [email protected]
//
// Natively wrap images such as tray, dock, and application icons.
type NativeImage struct {
*js.Object
ToPNG func() (Obj *js.Object) `js:"toPNG"`
ToJPEG func(Quality int64) (Obj *js.Object) `js:"toJPEG"`
ToBitmap func() (Obj *js.Object) `js:"toBitmap"`
ToDataURL func() (Obj string) `js:"toDataURL"`
// The difference between getBitmap() and toBitmap() is, getBitmap() does not copy the bitmap data, so you have to use the returned Buffer immediately in current event loop tick, otherwise the data might be changed or destroyed.
GetBitmap func() (Obj *js.Object) `js:"getBitmap"`
// Notice that the returned pointer is a weak pointer to the underlying native image instead of a copy, so you must ensure that the associated nativeImage instance is kept around.
GetNativeHandle func() (Obj *js.Object) `js:"getNativeHandle"`
IsEmpty func() (Obj bool) `js:"isEmpty"`
GetSize func() (Obj *NativeImageGetSizeObj) `js:"getSize"`
// Marks the image as a template image.
SetTemplateImage func(Option bool) `js:"setTemplateImage"`
IsTemplateImage func() (Obj bool) `js:"isTemplateImage"`
Crop func(Rect *NativeImageCropRect) (Obj *NativeImage) `js:"crop"`
// If only the height or the width are specified then the current aspect ratio will be preserved in the resized image.
Resize func(Options *NativeImageResizeOptions) (Obj *NativeImage) `js:"resize"`
GetAspectRatio func() (Obj float64) `js:"getAspectRatio"`
}
func WrapNativeImage(o *js.Object) *NativeImage {
return &NativeImage{
Object: o,
}
}
type NativeImageGetSizeObj struct {
*js.Object
Width int64 `js:"width"`
Height int64 `js:"height"`
}
type NativeImageCropRect struct {
*js.Object
X int64 `js:"x"`
Y int64 `js:"y"`
Width int64 `js:"width"`
Height int64 `js:"height"`
}
type NativeImageResizeOptions struct {
*js.Object
Width int64 `js:"width"`
Height int64 `js:"height"`
// The desired quality of the resize image. Possible values are , or . The default is . These values express a desired quality/speed tradeoff. They are translated into an algorithm-specific method that depends on the capabilities (CPU, GPU) of the underlying platform. It is possible for all three methods to be mapped to the same algorithm on a given platform.
Quality string `js:"quality"`
}