提交 973b12a1 编写于 作者: G Gloria

Update docs against 11415+11940

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 578c5ce2
...@@ -21,23 +21,27 @@ let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { ...@@ -21,23 +21,27 @@ let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {
// Create a PixelMap object. // Create a PixelMap object.
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } } let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } }
image.createPixelMap(color, opts, pixelmap => { image.createPixelMap(color, opts, (err, pixelmap) => {
console.log('Succeeded in creating pixelmap.'); console.log('Succeeded in creating pixelmap.');
}) })
// Read pixels. // Read pixels.
pixelmap.readPixels(area,(data) => { const area = {
if(data !== null) { pixels: new ArrayBuffer(8),
var bufferArr = new Uint8Array(area.pixels); offset: 0,
var res = true; stride: 8,
for (var i = 0; i < bufferArr.length; i++) { region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
console.info(' buffer ' + bufferArr[i]); }
if(res) { pixelmap.readPixels(area,() => {
if(bufferArr[i] == 0) { var bufferArr = new Uint8Array(area.pixels);
res = false; var res = true;
console.log('readPixels end.'); for (var i = 0; i < bufferArr.length; i++) {
break; console.info(' buffer ' + bufferArr[i]);
} if(res) {
if(bufferArr[i] == 0) {
res = false;
console.log('readPixels end.');
break;
} }
} }
} }
...@@ -96,7 +100,7 @@ pixelmap.writeBufferToPixels(writeColor).then(() => { ...@@ -96,7 +100,7 @@ pixelmap.writeBufferToPixels(writeColor).then(() => {
}) })
// Obtain image information. // Obtain image information.
pixelmap.getImageInfo( imageInfo => { pixelmap.getImageInfo((error, imageInfo) => {
if (imageInfo !== null) { if (imageInfo !== null) {
console.log('Succeeded in getting imageInfo'); console.log('Succeeded in getting imageInfo');
} }
...@@ -128,7 +132,7 @@ imageSourceApi.release(() => { ...@@ -128,7 +132,7 @@ imageSourceApi.release(() => {
const imagePackerApi = image.createImagePacker(); const imagePackerApi = image.createImagePacker();
const imageSourceApi = image.createImageSource(0); const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 }; let packOpts = { format:"image/jpeg", quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, data => { imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.log('Succeeded in packing'); console.log('Succeeded in packing');
}) })
...@@ -156,7 +160,7 @@ let decodingOptions = { ...@@ -156,7 +160,7 @@ let decodingOptions = {
}; };
// Create a pixel map in callback mode. // Create a pixel map in callback mode.
imageSourceApi.createPixelMap(decodingOptions, pixelmap => { imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
console.log('Succeeded in creating pixelmap.'); console.log('Succeeded in creating pixelmap.');
}) })
...@@ -171,17 +175,13 @@ catch(error => { ...@@ -171,17 +175,13 @@ catch(error => {
}) })
// Obtain the number of bytes in each line of pixels. // Obtain the number of bytes in each line of pixels.
pixelmap.getBytesNumberPerRow( num => { var num = pixelmap.getBytesNumberPerRow();
console.log('Succeeded in getting BytesNumber PerRow.');
})
// Obtain the total number of pixel bytes. // Obtain the total number of pixel bytes.
pixelmap.getPixelBytesNumber(num => { var pixelSize = pixelmap.getPixelBytesNumber();
console.log('Succeeded in getting PixelBytesNumber.');
})
// Obtain the pixel map information. // Obtain the pixel map information.
pixelmap.getImageInfo( imageInfo => {}) pixelmap.getImageInfo().then( imageInfo => {});
// Release the PixelMap object. // Release the PixelMap object.
pixelmap.release(()=>{ pixelmap.release(()=>{
...@@ -229,7 +229,7 @@ imagePackerApi.packing(imageSourceApi, packOpts) ...@@ -229,7 +229,7 @@ imagePackerApi.packing(imageSourceApi, packOpts)
imagePackerApi.release(); imagePackerApi.release();
// Obtain the image source information. // Obtain the image source information.
imageSourceApi.getImageInfo(imageInfo => { imageSourceApi.getImageInfo((err, imageInfo) => {
console.log('Succeeded in getting imageInfo'); console.log('Succeeded in getting imageInfo');
}) })
...@@ -249,8 +249,9 @@ public async init(surfaceId: any) { ...@@ -249,8 +249,9 @@ public async init(surfaceId: any) {
var receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1); var receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1);
// Obtain the surface ID. // Obtain the surface ID.
var surfaceId = await receiver.getReceivingSurfaceId(); receiver.getReceivingSurfaceId((err, surfaceId) => {
console.info("receiver getReceivingSurfaceId success");
});
// Register a surface listener, which is triggered after the buffer of the surface is ready. // Register a surface listener, which is triggered after the buffer of the surface is ready.
receiver.on('imageArrival', () => { receiver.on('imageArrival', () => {
// Obtain the latest buffer of the surface. // Obtain the latest buffer of the surface.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册