1.ArkTs整改6 更改ImageKnife->pngj文件夹

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2023-09-18 18:31:38 +08:00
parent f122a19f40
commit 2c2dacb367
6 changed files with 24 additions and 23 deletions

View File

@ -17,17 +17,18 @@ import { CropImage } from '@ohos/imageknife'
import { CropOptions } from '@ohos/imageknife'
import { Crop } from '@ohos/imageknife'
import { RecourseProvider } from '@ohos/imageknife'
import { PixelMapCropNameSpace } from '@ohos/imageknife'
import { PixelMapCrop } from '@ohos/imageknife'
import { CropCallback } from '@ohos/imageknife'
import { FileUtils } from '@ohos/imageknife'
import { ImageKnifeGlobal } from '@ohos/imageknife'
import { BusinessError } from '@ohos.base'
@Entry
@Component
export struct CropImagePage2 {
@State options1: PixelMapCrop.Options = new PixelMapCrop.Options();
@State options1: Options = new Options();
@State cropTap: boolean = false;
@State width1: number = 0;
@ -46,10 +47,10 @@ export struct CropImagePage2 {
.getMediaContent($r('app.media.bmpSample').id)
.then(data => {
let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data);
let optionx = new PixelMapCrop.Options();
let optionx = new Options();
optionx.setWidth(800)
.setHeight(800)
.setCropFunction((err, pixelmap, sx, sy) => {
.setCropFunction((err:BusinessError, pixelmap:PixelMap, sx:number, sy:number) => {
console.log('PMC setCropFunction callback')
if (err) {
console.error('PMC crop err =' + err)

View File

@ -802,7 +802,7 @@ export class Options {
pixelScale: number = 1;
// 用户裁剪后的回调
cropFunction: (error:BusinessError, pixelmap:PixelMap, sx:number, sy:number) => void = (error:BusinessError, pixelmap:PixelMap, sx:number, sy:number)=>{};
cropFunction: (error:BusinessError|string, pixelmap:PixelMap, sx:number, sy:number) => void = (error:BusinessError, pixelmap:PixelMap, sx:number, sy:number)=>{};
// 本地裁剪框 回调
cropAction: (topLeftPoint:number[], bottomRightPoint:number[], scaleInside:number) =>void = (topLeftPoint:number[], bottomRightPoint:number[], scaleInside:number)=>{};

View File

@ -14,5 +14,5 @@
*/
export interface PngCallback<R,T>{
(sender:R, receover:T)
pngCallback: (sender:R, receover:T)=>void
}

View File

@ -12,16 +12,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Closeable} from "/imageknife/pngj/io/Closeable"
import {ImageInfo} from "/imageknife/pngj/entry/ImageInfo"
import {Closeable} from "./io/Closeable"
import {ImageInfo} from "./entry/ImageInfo"
export class PngReader implements Closeable {
private static LOG_TAG: string= "PngReader";
private static MAX_TOTAL_BYTES_READ_DEFAULT: number= 901001001;
private static MAX_BYTES_METADATA_DEFAULT: number= 5024024;
private static MAX_CHUNK_SIZE_SKIP: number= 2024024;
public imgInfo: ImageInfo;
public interlaced: boolean;
public imgInfo: ImageInfo = new ImageInfo(0,0,0,false,false,false);
public interlaced: boolean = false;
constructor(shouldCloseStream: boolean) {

View File

@ -13,20 +13,20 @@
* limitations under the License.
*/
import {UPNG} from '../../3rd_party/upng/UPNG';
import {PngCallback} from '../pngj/PngCallback';
import {PngCallback} from './PngCallback';
import image from '@ohos.multimedia.image';
import resourceManager from '@ohos.resourceManager';
import ArkWorker from '@ohos.worker'
import { BusinessError } from '@ohos.base'
export class Pngj {
readPngImageInfo(arraybuffer: ArrayBuffer, callback:PngCallback<ArrayBuffer, any>) {
let imageSource = image.createImageSource(arraybuffer as any);
readPngImageInfo(arraybuffer: ArrayBuffer, callback:PngCallback<ArrayBuffer, image.ImageInfo>) {
let imageSource:image.ImageSource = image.createImageSource(arraybuffer);
if (imageSource != undefined){
imageSource.getImageInfo((err, value) => {
imageSource.getImageInfo((err:BusinessError, value:image.ImageInfo) => {
if (err) {
return;
}
callback(arraybuffer, value);
callback.pngCallback(arraybuffer, value);
});
}
@ -47,19 +47,19 @@ export class Pngj {
*/
readPngImage(pngBuffer: ArrayBuffer, callback:PngCallback<ArrayBuffer, any>) {
var png = UPNG.decode(pngBuffer);
callback(pngBuffer, png)
callback.pngCallback(pngBuffer, png)
}
writePngWithString(addInfo:string, pngBuffer: ArrayBuffer,callback:PngCallback<ArrayBuffer, any>) {
var pngDecode = UPNG.decode(pngBuffer);
var newPng = UPNG.encodeWithString(addInfo, UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0)
callback(pngBuffer, newPng);
callback.pngCallback(pngBuffer, newPng);
}
writePng(pngBuffer: ArrayBuffer,callback:PngCallback<ArrayBuffer, any>) {
var pngDecode = UPNG.decode(pngBuffer);
var newPng = UPNG.encode(UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0)
callback(pngBuffer, newPng);
callback.pngCallback(pngBuffer, newPng);
}
readPngImageAsync(worker: any, pngBuffer: ArrayBuffer, callback: PngCallback<ArrayBuffer, any>) {
@ -79,7 +79,7 @@ export class Pngj {
var data = e.data;
switch (data.type) {
case 'readPngImageAsync':
callback(data.receiver, data.data)
callback.pngCallback(data.receiver, data.data)
break;
default:
break
@ -107,7 +107,7 @@ export class Pngj {
var data = e.data;
switch (data.type) {
case 'writePngWithStringAsync':
callback(data.receiver, data.data)
callback.pngCallback(data.receiver, data.data)
break;
default:
break
@ -137,7 +137,7 @@ export class Pngj {
var data = e.data;
switch (data.type) {
case 'writePngAsync':
callback(data.receiver, data.data)
callback.pngCallback(data.receiver, data.data)
break;
default:
break

View File

@ -162,7 +162,7 @@ export class ImageInfo {
return true;
if (obj == null)
return false;
var other = obj;
let other = obj;
if (this.alpha != other.alpha)
return false;
if (this.bitDepth != other.bitDepth)