feat:Image add pixel API,pass pixels directly to Image
This commit is contained in:
@@ -85,8 +85,17 @@ export class BundleResource extends iOSResource {
|
||||
}
|
||||
|
||||
export class ArrayBufferResource extends Resource {
|
||||
data: ArrayBuffer
|
||||
constructor(data: ArrayBuffer) {
|
||||
super("arrayBuffer", "")
|
||||
this.data = data
|
||||
}
|
||||
toModel() {
|
||||
return {
|
||||
data: this.data,
|
||||
resId: this.resId,
|
||||
type: this.type,
|
||||
identifier: this.identifier,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -26,6 +26,11 @@ export enum ScaleType {
|
||||
}
|
||||
|
||||
export class Image extends View {
|
||||
/**
|
||||
* Set pixels for image directly
|
||||
*/
|
||||
@Property
|
||||
imagePixels?: { width: number, height: number, pixels: ArrayBuffer }
|
||||
/**
|
||||
* This could be loaded by customized resource loader
|
||||
*/
|
||||
@@ -132,6 +137,18 @@ export class Image extends View {
|
||||
stopAnimating(context: BridgeContext) {
|
||||
return this.nativeChannel(context, "stopAnimating")()
|
||||
}
|
||||
|
||||
getImageInfo(context: BridgeContext): Promise<{
|
||||
width: number,
|
||||
height: number,
|
||||
mimeType: string,
|
||||
}> {
|
||||
return this.nativeChannel(context, "getImageInfo")()
|
||||
}
|
||||
|
||||
getImagePixels(context: BridgeContext): Promise<ArrayBuffer> {
|
||||
return this.nativeChannel(context, "getImagePixels")()
|
||||
}
|
||||
}
|
||||
|
||||
export function image(config: Partial<Image>) {
|
||||
|
Reference in New Issue
Block a user