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