1.cropImage default size changed
2.delete MyAbilityStage.ts useless file 3.ImageKnife create DiskLruCache Function has changed 4. MaskTransformation.ets adapter stage mode getResourceManager Signed-off-by: dodozhou7 <abczp777777@163.com>
This commit is contained in:
parent
4975e0e1a7
commit
38fc363b37
|
@ -1,7 +0,0 @@
|
||||||
import AbilityStage from "@ohos.application.AbilityStage"
|
|
||||||
|
|
||||||
export default class MyAbilityStage extends AbilityStage {
|
|
||||||
onCreate() {
|
|
||||||
console.log("[Demo] MyAbilityStage onCreate")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,8 +44,8 @@ export struct CropImagePage2 {
|
||||||
.then(data => {
|
.then(data => {
|
||||||
let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data);
|
let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data);
|
||||||
let optionx = new PixelMapCrop.Options();
|
let optionx = new PixelMapCrop.Options();
|
||||||
optionx.setWidth(600)
|
optionx.setWidth(800)
|
||||||
.setHeight(400)
|
.setHeight(800)
|
||||||
.setCropFunction((err, pixelmap, sx, sy) => {
|
.setCropFunction((err, pixelmap, sx, sy) => {
|
||||||
console.log('PMC setCropFunction callback')
|
console.log('PMC setCropFunction callback')
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ export class ImageKnife {
|
||||||
this.memoryCache = new LruCache<string, any>(100);
|
this.memoryCache = new LruCache<string, any>(100);
|
||||||
|
|
||||||
// 创建disk缓存 传入的size 为多少比特 比如20KB 传入20*1024
|
// 创建disk缓存 传入的size 为多少比特 比如20KB 传入20*1024
|
||||||
this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext.filesDir + ImageKnife.SEPARATOR + this.diskCacheFolder, 30 * 1024 * 1024);
|
this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext);
|
||||||
|
|
||||||
// 创建网络下载能力
|
// 创建网络下载能力
|
||||||
this.dataFetch = new DownloadClient();
|
this.dataFetch = new DownloadClient();
|
||||||
|
@ -180,12 +180,10 @@ export class ImageKnife {
|
||||||
|
|
||||||
// 替代原来的DiskLruCache
|
// 替代原来的DiskLruCache
|
||||||
public replaceDiskLruCache(size:number) {
|
public replaceDiskLruCache(size:number) {
|
||||||
// this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext.filesDir+ImageKnife.SEPARATOR+this.diskCacheFolder, size);
|
|
||||||
|
|
||||||
if (this.diskMemoryCache.getCacheMap().size() <= 0) {
|
if (this.diskMemoryCache.getCacheMap().size() <= 0) {
|
||||||
this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext.filesDir + ImageKnife.SEPARATOR + this.diskCacheFolder, size);
|
this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext, size);
|
||||||
} else {
|
} else {
|
||||||
let newDiskLruCache = DiskLruCache.create(this.imageKnifeContext.filesDir + ImageKnife.SEPARATOR + this.diskCacheFolder, size);
|
let newDiskLruCache = DiskLruCache.create(this.imageKnifeContext, size);
|
||||||
this.diskMemoryCache.foreachDiskLruCache(function (value, key, map) {
|
this.diskMemoryCache.foreachDiskLruCache(function (value, key, map) {
|
||||||
newDiskLruCache.set(key, value);
|
newDiskLruCache.set(key, value);
|
||||||
})
|
})
|
||||||
|
|
|
@ -83,10 +83,7 @@ export class MaskTransformation implements BaseTransform<PixelMap> {
|
||||||
if (!this._mResourceData) {
|
if (!this._mResourceData) {
|
||||||
throw new Error("MaskTransformation resource is empty");
|
throw new Error("MaskTransformation resource is empty");
|
||||||
}
|
}
|
||||||
resmgr.getResourceManager()
|
globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia(this._mResourceData.id)
|
||||||
.then(result => {
|
|
||||||
result.getMedia(this._mResourceData
|
|
||||||
.id)
|
|
||||||
.then(array => {
|
.then(array => {
|
||||||
let buffer = array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
|
let buffer = array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
|
||||||
var imageSource = image.createImageSource(buffer as any);
|
var imageSource = image.createImageSource(buffer as any);
|
||||||
|
@ -105,6 +102,5 @@ export class MaskTransformation implements BaseTransform<PixelMap> {
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
func("MaskTransformation openInternal error" + err, null);
|
func("MaskTransformation openInternal error" + err, null);
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue