Methods
(static) this.fromAlbum(imageSource, onImage, onFailure, settings)
Presents an interface for the user to select an image from the device's photo album
Parameters:
| Name | Type | Description |
|---|---|---|
imageSource |
number | Source album to use. Use constant from QBrowser.ImageSource. |
onImage |
function | JavaScript function that receives the image data. Parameters: - image(string) - Base64 encoded image data. |
onFailure |
function | JavaScript function called if an error occurs. Parameters: - errorCode(number) - Error code - errorDescription(string) - Textual description of the error. |
settings |
Object | Optional object of settings you can pass. Supported settings: - quality(number) - Controls image quality. The higher the quality, the bigger the resulting image. Valid values: 10 - 100, default is 75. |
- Source:
Example
// Example function call
QBrowser.Image.fromAlbum(QBrowser.ImageSource.PHOTOLIBRARY, ImageSuccess, ImageError);
(static) this.fromCamera(onImage, onFailure, settings)
Uses device's camera to capture an image and send it back
Parameters:
| Name | Type | Description |
|---|---|---|
onImage |
function | JavaScript function that receives the image data. Parameters: - image(string) - Base64 encoded image data. |
onFailure |
function | JavaScript function called if an error occurs. Parameters: - errorCode(number) - Error code - errorDescription(string) - Textual description of the error. |
settings |
Object | Optional object of settings you can pass. Supported settings: - quality(number) - Controls image quality. The higher the quality, the bigger the resulting image. Valid values: 10 - 100, default is 75. |
- Source:
Example
// Example callback function that receives image data
function ImageSuccess(picture) {
document.body.innerHTML+="<img name=\"importedImage\" src=\"data:image/jpeg;base64,"+picture+"\" alt=\"1231232.jpg\" /><br/>";
}
// Example callback function if failure
function ImageError(errorCode, errorDescription) {
alert("Image failed ("+errorCode+"): "+errorDescription);
}
// Example function call
QBrowser.Image.fromCamera(ImageSuccess, ImageError, {quality:50});
(static) this.getTiff(width, height, data, onSuccess, onFailure)
Returns a TIFF CCITT B&W compressed image
Parameters:
| Name | Type | Description |
|---|---|---|
width |
number | Image width in pixels |
height |
number | Image height in pixels |
data |
string | Base64 encoded image data |
onSuccess |
function | JavaScript function that receives the image data. Parameters: - image(string) - Base64 encoded image data. |
onFailure |
function | JavaScript function called if an error occurs. Parameters: - errorCode(number) - Error code - errorDescription(string) - Textual description of the error. |
- Source:
(static) this.simulate(onImage, settings)
Helper function that provides a sample image for testing purposes
Parameters:
| Name | Type | Description |
|---|---|---|
onImage |
function | JavaScript function that receives the image data. Parameters: - image(string) - Base64 encoded image data. |
settings |
Object | Optional object of settings you can pass. Supported settings: - quality(number) - Controls image quality. The higher the quality, the bigger the resulting image. Valid values: 10 - 100, default is 75. |
- Source:
Example
// Example callback function that receives image data
function ImageSuccess(picture) {
document.body.innerHTML+="<img name=\"importedImage\" src=\"data:image/jpeg;base64,"+picture+"\" alt=\"1231232.jpg\" /><br/>";
}
// Example function call
QBrowser.Image.fromCamera(ImageSuccess, {quality:50});