Pre Merge pull request !139 from Megasu/N/A

This commit is contained in:
Megasu 2024-05-07 03:48:57 +00:00 committed by Gitee
commit f927fa4cad
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 57 additions and 35 deletions

View File

@ -12,10 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {ImageKnife} from '@ohos/libraryimageknife'
import {OnRenameListener} from '@ohos/libraryimageknife'
import {OnCompressListener} from '@ohos/libraryimageknife'
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
import { ImageKnife, ImageKnifeGlobal, OnCompressListener, OnRenameListener } from '@ohos/libraryimageknife';
@Entry
@Component
@ -32,18 +29,23 @@ struct CompressPage {
Column() {
Column() {
Text("Resource image compress").fontColor(Color.Gray).fontSize(16);
Text("Resource image compress")
.fontColor(Color.Gray)
.fontSize(16);
Button() {
Text("同步压缩").fontSize(13).fontColor(Color.White)
Text("同步压缩")
.fontSize(13)
.fontColor(Color.White)
}
.height(35)
.width(120)
.margin({ top: 10 })
.onClick(() => {
this.compressAsyncRecource();
this.compressAsyncResource();
});
Scroll() {
Text(this.mAsyncPathHint).fontSize(13)
Text(this.mAsyncPathHint)
.fontSize(13)
}
.height(55)
.width(350)
@ -56,26 +58,37 @@ struct CompressPage {
.backgroundColor(Color.Pink)
Button() {
Text($r("app.string.resource_image_compress")).fontSize(13).fontColor(Color.White)
Text($r("app.string.resource_image_compress"))
.fontSize(13)
.fontColor(Color.White)
}
.height(35)
.width(120)
.margin({ top: 10 })
.onClick(() => {
this.cropressRecource();
this.compressResource();
});
Image(this.mRPixelMap == undefined ? '' : this.mRPixelMap!)
.width(200)
.height(200)
.margin({ top: 10 })
Text(this.mResultText).fontColor(Color.Gray).fontSize(16);
Text(this.mResultPath).fontColor(Color.Gray).fontSize(16);
}.margin({ top: 10 });
Text(this.mResultText)
.fontColor(Color.Gray)
.fontSize(16);
Text(this.mResultPath)
.fontColor(Color.Gray)
.fontSize(16);
}
.margin({ top: 10 });
Column() {
Text("file image compress").fontColor(Color.Gray).fontSize(16);
Text("file image compress")
.fontColor(Color.Gray)
.fontSize(16);
Button() {
Text($r("app.string.file_image_compress")).fontSize(13).fontColor(Color.White)
Text($r("app.string.file_image_compress"))
.fontSize(13)
.fontColor(Color.White)
}
.height(35)
.width(120)
@ -86,15 +99,22 @@ struct CompressPage {
.width(200)
.height(200)
.margin({ top: 10 });
}.margin({ top: 10 }).visibility(Visibility.Hidden);
}.margin({ bottom: 30 });
}.width('100%').height('100%');
}
private compressAsyncRecource() {
.margin({ top: 10 })
.visibility(Visibility.Hidden);
}
.margin({ bottom: 30 });
}
.width('100%')
.height('100%');
}
private compressAsyncResource() {
let data = new Array<Resource>();
data.push($r('app.media.jpgSample'))
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
let imageKnife: ImageKnife | undefined = ImageKnifeGlobal.getInstance()
.getImageKnife()
if (imageKnife != undefined) {
imageKnife
.compressBuilder()
@ -108,7 +128,8 @@ struct CompressPage {
}
console.info("asasd start compress end")
}
private cropressRecource() {
private compressResource() {
let data = new Array<Resource>();
data.push($r('app.media.jpgSample'))
let rename: OnRenameListener = {
@ -137,7 +158,8 @@ struct CompressPage {
}
}
console.info("asasd start compress")
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
let imageKnife: ImageKnife | undefined = ImageKnifeGlobal.getInstance()
.getImageKnife()
if (imageKnife != undefined) {
imageKnife
.compressBuilder()