Compare commits
2 Commits
28a082737c
...
1d165c951d
Author | SHA1 | Date |
---|---|---|
|
1d165c951d | |
|
7e28f28f8f |
|
@ -23,66 +23,39 @@ struct LocalImage {
|
|||
build() {
|
||||
Scroll(this.scroller) {
|
||||
Column() {
|
||||
Column() {
|
||||
Text($r('app.string.base_image'))
|
||||
.fontSize(20)
|
||||
Text("Base Image")
|
||||
.fontSize(30)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
Row() {
|
||||
Image($rawfile('rotate/rotate.jpg')).width(100).height(100).margin({ right: 10 })
|
||||
ImageKnifeComponent({
|
||||
imageKnifeOption: {
|
||||
loadSrc: $rawfile('rotate/rotate.jpg'),
|
||||
objectFit: ImageFit.Contain
|
||||
}
|
||||
}).width(100).height(100)
|
||||
}
|
||||
}
|
||||
.margin({ bottom: 20 })
|
||||
Image($rawfile("rotate/rotate.jpg")).width(100).height(100)
|
||||
|
||||
Column() {
|
||||
Text($r('app.string.rotate_mirror'))
|
||||
.fontSize(20)
|
||||
Text($r("app.string.rotate_mirror"))
|
||||
.fontSize(30)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
Row() {
|
||||
Image($rawfile('rotate/rotate_mirror.jpg')).width(100).height(100).margin({ right: 10 })
|
||||
ImageKnifeComponent({
|
||||
imageKnifeOption: {
|
||||
loadSrc: $rawfile('rotate/rotate_mirror.jpg'),
|
||||
objectFit: ImageFit.Contain
|
||||
}
|
||||
}).width(100).height(100)
|
||||
}
|
||||
}.margin({ bottom: 20 })
|
||||
|
||||
Column() {
|
||||
Text($r('app.string.rotate_rotate90'))
|
||||
.fontSize(20)
|
||||
.fontSize(30)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
Row() {
|
||||
Image($rawfile('rotate/rotate_rotate90.jpg')).width(100).height(100).margin({ right: 10 })
|
||||
ImageKnifeComponent({
|
||||
imageKnifeOption: {
|
||||
loadSrc: $rawfile('rotate/rotate_rotate90.jpg'),
|
||||
objectFit: ImageFit.Contain
|
||||
}
|
||||
}).width(100).height(100)
|
||||
}
|
||||
}.margin({ bottom: 20 })
|
||||
|
||||
Column() {
|
||||
Text($r('app.string.rotate_mirror_rotate270'))
|
||||
.fontSize(20)
|
||||
.fontSize(30)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
Row() {
|
||||
Image($rawfile('rotate/rotate_mirror_rotate270.jpg')).width(100).height(100).margin({ right: 10 })
|
||||
ImageKnifeComponent({
|
||||
imageKnifeOption: {
|
||||
loadSrc: $rawfile('rotate/rotate_mirror_rotate270.jpg'),
|
||||
objectFit: ImageFit.Contain
|
||||
}
|
||||
}).width(100).height(100)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
|
|
|
@ -694,7 +694,7 @@
|
|||
},
|
||||
{
|
||||
"name": "base_image",
|
||||
"value": "The image don't carry rotation information"
|
||||
"value": "Original Image"
|
||||
},
|
||||
{
|
||||
"name": "rotate_mirror",
|
||||
|
|
|
@ -682,7 +682,7 @@
|
|||
},
|
||||
{
|
||||
"name": "base_image",
|
||||
"value": "图片不携带旋转信息"
|
||||
"value": "原始图片"
|
||||
},
|
||||
{
|
||||
"name": "test_exif",
|
||||
|
|
|
@ -196,15 +196,11 @@ export class ImageKnifeLoader {
|
|||
LogUtil.error('PixelMap setTransferDetached failed:' + JSON.stringify(e))
|
||||
}
|
||||
// 设置翻转和旋转角度
|
||||
if(exif && exif !== 'Top-left'){
|
||||
if(exif){
|
||||
let result = ImageKnifeLoader.getOrientation(exif);
|
||||
if(result.horizontal || result.vertical) {
|
||||
resPixelmap?.flipSync(result.horizontal, result.vertical);
|
||||
}
|
||||
if(result.rotate > 0) {
|
||||
resPixelmap?.rotateSync(result.rotate);
|
||||
}
|
||||
LogUtil.log('The normal image set flip , horizontal=' + result.horizontal + ', vertical=' +result.vertical + ', rotate=' + result.rotate);
|
||||
LogUtil.log('Image set flip , horizontal=' + result.horizontal + ', vertical=' +result.vertical + ', rotate=' + result.rotate);
|
||||
}
|
||||
|
||||
//获取各个pixelMap的大小
|
||||
|
@ -279,7 +275,7 @@ export class ImageKnifeLoader {
|
|||
await imageSource.getImageProperty(image.PropertyKey.ORIENTATION).then((res)=>{
|
||||
exif = res;
|
||||
}).catch((error: BusinessError)=>{
|
||||
LogUtil.info("Svg image don't have rotation information, " + error.message);
|
||||
LogUtil.info("The normal image don't have rotation information, " + error.message);
|
||||
})
|
||||
|
||||
await imageSource.createPixelMap(opts)
|
||||
|
@ -290,15 +286,11 @@ export class ImageKnifeLoader {
|
|||
try {
|
||||
resPixelmap.setTransferDetached(true)
|
||||
// 设置翻转和旋转角度
|
||||
if(exif && exif !== 'Top-left'){
|
||||
if(exif){
|
||||
let result = ImageKnifeLoader.getOrientation(exif);
|
||||
if(result.horizontal || result.vertical) {
|
||||
resPixelmap?.flipSync(result.horizontal, result.vertical);
|
||||
}
|
||||
if(result.rotate > 0) {
|
||||
resPixelmap?.rotateSync(result.rotate);
|
||||
}
|
||||
LogUtil.log('Svg image set flip , horizontal=' + result.horizontal + ', vertical=' +result.vertical + ', rotate=' + result.rotate);
|
||||
LogUtil.log('SvgImage set flip , horizontal=' + result.horizontal + ', vertical=' +result.vertical + ', rotate=' + result.rotate);
|
||||
}
|
||||
} catch (e) {
|
||||
LogUtil.error('PixelMap setTransferDetached failed:' + JSON.stringify(e))
|
||||
|
@ -535,27 +527,27 @@ export class ImageKnifeLoader {
|
|||
let vertical: boolean = false;
|
||||
let rotate: number= 0;
|
||||
switch (orientation){
|
||||
case 'Top-left': break
|
||||
case 'Top-right':
|
||||
case "Top-left": break
|
||||
case "Top-right":
|
||||
horizontal = true;
|
||||
break;
|
||||
case 'Bottom-left':
|
||||
case "Bottom-left":
|
||||
vertical = true;
|
||||
break
|
||||
case 'Bottom-right':
|
||||
case "Bottom-right":
|
||||
rotate = 180;
|
||||
break;
|
||||
case 'Left-top':
|
||||
case "Left-top":
|
||||
horizontal = true;
|
||||
rotate = 270;
|
||||
break
|
||||
case 'Right-top':
|
||||
case "Right-top":
|
||||
rotate = 90;
|
||||
break;
|
||||
case 'Left-bottom':
|
||||
case "Left-bottom":
|
||||
rotate = 270;
|
||||
break
|
||||
case 'Right-bottom':
|
||||
case "Right-bottom":
|
||||
horizontal = true;
|
||||
rotate = 90;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue