图片处理指对PixelMap进行相关的操作,如获取图片信息、裁剪、缩放、偏移、旋转、翻转、设置透明度、读写像素数据等。图片处理主要包括图像变换、位图操作,本文介绍图像变换。
开发步骤
图像变换相关API的详细介绍请参见API参考。
1.完成图片解码,获取Pixelmap对象。
2.获取图片信息。
import {
BusinessError} from '@ohos.base'
// 获取图片大小
pixelMap.getImageInfo().then( (info : image.ImageInfo) => {
console.info('info.width = ' + info.size.width);
console.info('info.height = ' + info.size.height);
}).catch((err : BusinessError) => {
console.error("Failed to obtain the image pixel map information.And the error is: " + err)