demo: update ImageProcessorDemo, copy arraybuffer from Native
This commit is contained in:
parent
f393891545
commit
dd10c7f832
@ -92,7 +92,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
const containerRef = createRef<GestureContainer>();
|
const containerRef = createRef<GestureContainer>();
|
||||||
this.addOnRenderFinishedCallback(async () => {
|
this.addOnRenderFinishedCallback(async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
const data = new Uint8Array(pixels);
|
const data = new Uint8Array(pixels);
|
||||||
|
|
||||||
async function changeAlpha(alpha: number) {
|
async function changeAlpha(alpha: number) {
|
||||||
@ -146,7 +148,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
const containerRef = createRef<GestureContainer>();
|
const containerRef = createRef<GestureContainer>();
|
||||||
this.addOnRenderFinishedCallback(async () => {
|
this.addOnRenderFinishedCallback(async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
const data = new Uint32Array(pixels);
|
const data = new Uint32Array(pixels);
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
let { r, g, b } = pixelToRGBA(data[i]);
|
let { r, g, b } = pixelToRGBA(data[i]);
|
||||||
@ -205,7 +209,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
const containerRef = createRef<GestureContainer>();
|
const containerRef = createRef<GestureContainer>();
|
||||||
this.addOnRenderFinishedCallback(async () => {
|
this.addOnRenderFinishedCallback(async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const rawPixels = await iv.current.getImagePixels(context);
|
const rawPixels = (
|
||||||
|
await iv.current.getImagePixels(context)
|
||||||
|
).slice(0);
|
||||||
async function blurEffect(radius: number) {
|
async function blurEffect(radius: number) {
|
||||||
radius = Math.round(radius);
|
radius = Math.round(radius);
|
||||||
const buffer = rawPixels.slice(0);
|
const buffer = rawPixels.slice(0);
|
||||||
@ -258,7 +264,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
layoutConfig={layoutConfig().just()}
|
layoutConfig={layoutConfig().just()}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
const data = new Uint32Array(pixels);
|
const data = new Uint32Array(pixels);
|
||||||
vampix(data);
|
vampix(data);
|
||||||
iv.current.imagePixels = {
|
iv.current.imagePixels = {
|
||||||
@ -275,7 +283,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
loge(imageInfo);
|
loge(imageInfo);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
loge(pixels.byteLength);
|
loge(pixels.byteLength);
|
||||||
const data = new Uint8Array(pixels);
|
const data = new Uint8Array(pixels);
|
||||||
for (let i = 0; i < data.length - 4; i += 4) {
|
for (let i = 0; i < data.length - 4; i += 4) {
|
||||||
@ -304,7 +314,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
layoutConfig={layoutConfig().just()}
|
layoutConfig={layoutConfig().just()}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
const data = new Uint32Array(pixels);
|
const data = new Uint32Array(pixels);
|
||||||
fastBlur(data, imageInfo.width, imageInfo.height, 30);
|
fastBlur(data, imageInfo.width, imageInfo.height, 30);
|
||||||
iv.current.imagePixels = {
|
iv.current.imagePixels = {
|
||||||
@ -320,7 +332,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
layoutConfig={layoutConfig().just()}
|
layoutConfig={layoutConfig().just()}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
const data = new Uint32Array(pixels);
|
const data = new Uint32Array(pixels);
|
||||||
gaussianBlur(data, imageInfo.width, imageInfo.height, 1);
|
gaussianBlur(data, imageInfo.width, imageInfo.height, 1);
|
||||||
iv.current.imagePixels = {
|
iv.current.imagePixels = {
|
||||||
@ -346,7 +360,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
layoutConfig={layoutConfig().just()}
|
layoutConfig={layoutConfig().just()}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
const data = new Uint32Array(pixels);
|
const data = new Uint32Array(pixels);
|
||||||
extractGrayValue(data);
|
extractGrayValue(data);
|
||||||
binarization(data, 127);
|
binarization(data, 127);
|
||||||
@ -363,7 +379,9 @@ export class ImageProcessorDemo extends Panel {
|
|||||||
layoutConfig={layoutConfig().just()}
|
layoutConfig={layoutConfig().just()}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const imageInfo = await iv.current.getImageInfo(context);
|
const imageInfo = await iv.current.getImageInfo(context);
|
||||||
const pixels = await iv.current.getImagePixels(context);
|
const pixels = (await iv.current.getImagePixels(context)).slice(
|
||||||
|
0
|
||||||
|
);
|
||||||
const data = new Uint32Array(pixels);
|
const data = new Uint32Array(pixels);
|
||||||
extractGrayValue(data);
|
extractGrayValue(data);
|
||||||
const t = ostu(data);
|
const t = ostu(data);
|
||||||
|
Reference in New Issue
Block a user