feat:Remove Image's setImagePixels API

This commit is contained in:
pengfei.zhou 2021-11-30 16:20:07 +08:00 committed by osborn
parent 5b5500b6e0
commit e9e2d14a9d
10 changed files with 4 additions and 77 deletions

View File

@ -606,15 +606,4 @@ public class ImageNode extends ViewNode<ImageView> {
return new JavaValue(); return new JavaValue();
} }
} }
@DoricMethod
public void setImagePixels(JSObject prop) {
int width = prop.asObject().getProperty("width").asNumber().toInt();
int height = prop.asObject().getProperty("height").asNumber().toInt();
byte[] pixels = prop.asObject().getProperty("pixels").asArrayBuffer().value();
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
ByteBuffer byteBuffer = ByteBuffer.wrap(pixels);
bitmap.copyPixelsFromBuffer(byteBuffer);
mView.setImageBitmap(bitmap);
}
} }

View File

@ -2316,14 +2316,6 @@ var Image = /** @class */ (function (_super) {
Image.prototype.getImagePixels = function (context) { Image.prototype.getImagePixels = function (context) {
return this.nativeChannel(context, "getImagePixels")(); return this.nativeChannel(context, "getImagePixels")();
}; };
Image.prototype.setImagePixels = function (context, imagePixels) {
if (Environment.platform === 'iOS') {
imagePixels.pixels = context.function2Id(function () {
return imagePixels.pixels;
});
}
return this.nativeChannel(context, "setImagePixels")(imagePixels);
};
Image.prototype.toModel = function () { Image.prototype.toModel = function () {
var ret = _super.prototype.toModel.call(this); var ret = _super.prototype.toModel.call(this);
if (Environment.platform === 'iOS') { if (Environment.platform === 'iOS') {

View File

@ -1726,14 +1726,6 @@ class Image extends View {
getImagePixels(context) { getImagePixels(context) {
return this.nativeChannel(context, "getImagePixels")(); return this.nativeChannel(context, "getImagePixels")();
} }
setImagePixels(context, imagePixels) {
if (Environment.platform === 'iOS') {
imagePixels.pixels = context.function2Id(() => {
return imagePixels.pixels;
});
}
return this.nativeChannel(context, "setImagePixels")(imagePixels);
}
toModel() { toModel() {
const ret = super.toModel(); const ret = super.toModel();
if (Environment.platform === 'iOS') { if (Environment.platform === 'iOS') {

View File

@ -3254,14 +3254,6 @@ class Image extends View {
getImagePixels(context) { getImagePixels(context) {
return this.nativeChannel(context, "getImagePixels")(); return this.nativeChannel(context, "getImagePixels")();
} }
setImagePixels(context, imagePixels) {
if (Environment.platform === 'iOS') {
imagePixels.pixels = context.function2Id(() => {
return imagePixels.pixels;
});
}
return this.nativeChannel(context, "setImagePixels")(imagePixels);
}
toModel() { toModel() {
const ret = super.toModel(); const ret = super.toModel();
if (Environment.platform === 'iOS') { if (Environment.platform === 'iOS') {

5
doric-js/index.d.ts vendored
View File

@ -714,11 +714,6 @@ declare module 'doric/lib/src/widget/image' {
mimeType: string; mimeType: string;
}>; }>;
getImagePixels(context: BridgeContext): Promise<ArrayBuffer>; getImagePixels(context: BridgeContext): Promise<ArrayBuffer>;
setImagePixels(context: BridgeContext, imagePixels: {
width: number;
height: number;
pixels: ArrayBuffer;
}): Promise<void>;
toModel(): NativeViewModel; toModel(): NativeViewModel;
} }
export function image(config: Partial<Image>): Image; export function image(config: Partial<Image>): Image;

View File

@ -95,11 +95,6 @@ export declare class Image extends View {
mimeType: string; mimeType: string;
}>; }>;
getImagePixels(context: BridgeContext): Promise<ArrayBuffer>; getImagePixels(context: BridgeContext): Promise<ArrayBuffer>;
setImagePixels(context: BridgeContext, imagePixels: {
width: number;
height: number;
pixels: ArrayBuffer;
}): Promise<void>;
toModel(): NativeViewModel; toModel(): NativeViewModel;
} }
export declare function image(config: Partial<Image>): Image; export declare function image(config: Partial<Image>): Image;

View File

@ -48,14 +48,6 @@ export class Image extends View {
getImagePixels(context) { getImagePixels(context) {
return this.nativeChannel(context, "getImagePixels")(); return this.nativeChannel(context, "getImagePixels")();
} }
setImagePixels(context, imagePixels) {
if (Environment.platform === 'iOS') {
imagePixels.pixels = context.function2Id(() => {
return imagePixels.pixels;
});
}
return this.nativeChannel(context, "setImagePixels")(imagePixels);
}
toModel() { toModel() {
const ret = super.toModel(); const ret = super.toModel();
if (Environment.platform === 'iOS') { if (Environment.platform === 'iOS') {

View File

@ -150,22 +150,6 @@ export class Image extends View {
return this.nativeChannel(context, "getImagePixels")() return this.nativeChannel(context, "getImagePixels")()
} }
setImagePixels(
context: BridgeContext,
imagePixels: {
width: number,
height: number,
pixels: ArrayBuffer
}): Promise<void> {
if (Environment.platform === 'iOS') {
(imagePixels.pixels as unknown as any) = context.function2Id(() => {
return imagePixels.pixels
})
}
return this.nativeChannel(context, "setImagePixels")(imagePixels)
}
toModel() { toModel() {
const ret = super.toModel() const ret = super.toModel()
if (Environment.platform === 'iOS') { if (Environment.platform === 'iOS') {

View File

@ -3328,14 +3328,6 @@ class Image extends View {
getImagePixels(context) { getImagePixels(context) {
return this.nativeChannel(context, "getImagePixels")(); return this.nativeChannel(context, "getImagePixels")();
} }
setImagePixels(context, imagePixels) {
if (Environment.platform === 'iOS') {
imagePixels.pixels = context.function2Id(() => {
return imagePixels.pixels;
});
}
return this.nativeChannel(context, "setImagePixels")(imagePixels);
}
toModel() { toModel() {
const ret = super.toModel(); const ret = super.toModel();
if (Environment.platform === 'iOS') { if (Environment.platform === 'iOS') {

File diff suppressed because one or more lines are too long