Starting from version 1078, the API prefix has been changed from hbs to qg. The original prefix hbs is still supported.
API | Description |
|---|---|
Selects an image from the album or takes a photo. | |
Previews an image in full mode in a new scenario. | |
Saves an image to the album. User authorization is required before calling this API. | |
Asynchronously saves binary image data as a local temporary image file. | |
Saves the binary image data as a local temporary image file synchronously and returns the local temporary file path. |
Selects an image from the album or takes a photo.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
count | number | No | Maximum number of images that can be selected. |
sourceType | array.string | No | Image source. Value album indicates selecting an image from the album. Value camera indicates taking a photo. The default value is ["album","camera"].
|
success | function | No | Callback function triggered upon a successful API call. |
fail | function | No | Callback function triggered upon a failed API call. |
complete | function | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
Parameter | Type | Description |
|---|---|---|
tempFilePaths | array.string | List of local temporary image paths. |
tempFiles | string[] | List of local temporary images. |
Attribute | Type | Description |
|---|---|---|
path | string | Local temporary file path. |
size | number | Size of a local temporary file, in bytes. |
qg.chooseImage({
count: 1,
sourceType: ['album', 'camera'],
success (res) {
console.log("qg.chooseImage success"+ res.tempFilePaths);
},
fail(){
console.log("qg.chooseImage fail");
},
complete(){
console.log("qg.chooseImage complete");
}
}) Parameter | Type | Mandatory | Description |
|---|---|---|---|
urls | array.string | Yes | List of URLs of images to be previewed. |
current | string | No | URL of the currently displayed image. By default, the first image in urls is displayed. |
success | function | No | Callback function triggered upon a successful API call. |
fail | function | No | Callback function triggered upon a failed API call. |
complete | function | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.previewImage({
urls: [] // List of HTTP URLs of images to be previewed.
}) Parameter | Type | Mandatory | Description |
|---|---|---|---|
filePath | string | Yes | Image file path. The value can be either a temporary file path or a permanent file path. Network image URLs are not supported. |
success | function | No | Callback function triggered upon a successful API call. |
fail | function | No | Callback function triggered upon a failed API call. |
complete | function | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.saveImageToPhotosAlbum({
filePath : 'image path',
success() {
console.log("save success");
}
}) Parameter | Type | Mandatory | Description |
|---|---|---|---|
data | uint8array | Yes | Pixel data in RGBA8888 format, represented as a Uint8Array. |
width | number | Yes | Image width. The maximum value is 4096. |
height | number | Yes | Image height. The maximum value is 4096. |
fileType | string | Yes | Image format. The options are jpg and png. |
reverse | boolean | No | Indicates whether to flip the written data along the Y axis. The default value is false. |
success | function | No | Callback function triggered upon a successful API call. |
fail | function | No | Callback function triggered upon a failed API call. |
complete | function | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
Parameter | Type | Description |
|---|---|---|
tempFilePath | string | Local temporary path to which an image is saved. |
errMsg | string | Message. |
qg.saveImageTemp({
'data': data,
'width': width,
'height': height,
'fileType': "png",
'reverse': true,
'success': function (res) {
rt.saveImageToPhotosAlbum({
"filePath": res.tempFilePath,
success: successCb,
fail: failCb,
});
},
'fail': function (res) {
failCb("Failed to take a screenshot.")
}
}); Saves the binary image data as a local temporary image file synchronously and returns the local temporary file path.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
data | uint8array | Yes | Pixel data in RGBA8888 format, represented as a Uint8Array. |
width | number | Yes | Image width. The maximum value is 4096. |
height | number | Yes | Image height. The maximum value is 4096. |
fileType | string | Yes | Image format. The options are jpg and png. |
reverse | boolean | No | Indicates whether to flip the written data along the Y axis. The default value is false. |
var result = qg.saveImageTempSync({
data : [],
width : 666,
height : 666,
fileType : 'jpg',
reverse : false
})