|
@@ -43,7 +43,7 @@ export class SImageItem extends SObjectItem {
|
|
this.update();
|
|
this.update();
|
|
console.log("加载图片错误!");
|
|
console.log("加载图片错误!");
|
|
console.log(e);
|
|
console.log(e);
|
|
- }
|
|
|
|
|
|
+ };
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -89,16 +89,18 @@ export class SImageItem extends SObjectItem {
|
|
onDraw(painter: SPainter): void {
|
|
onDraw(painter: SPainter): void {
|
|
if (this.isLoadOver) {
|
|
if (this.isLoadOver) {
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
- let width: number = 0;
|
|
|
|
|
|
+ let width = 0;
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
- let height: number = 0;
|
|
|
|
|
|
+ let height = 0;
|
|
// 图片item的宽高比
|
|
// 图片item的宽高比
|
|
let itemAspectRatio: number = this.width / this.height;
|
|
let itemAspectRatio: number = this.width / this.height;
|
|
// 原始图片的宽高比
|
|
// 原始图片的宽高比
|
|
let imgAspectRatio: number =
|
|
let imgAspectRatio: number =
|
|
|
|
+ // @ts-ignore
|
|
(this.img.width as number) / (this.img.height as number);
|
|
(this.img.width as number) / (this.img.height as number);
|
|
// 原始图片的高宽比
|
|
// 原始图片的高宽比
|
|
let imgHwRatio: number =
|
|
let imgHwRatio: number =
|
|
|
|
+ // @ts-ignore
|
|
(this.img.height as number) / (this.img.width as number);
|
|
(this.img.height as number) / (this.img.width as number);
|
|
if (this.showType == SImageShowType.Full) {
|
|
if (this.showType == SImageShowType.Full) {
|
|
width = this.width;
|
|
width = this.width;
|
|
@@ -115,18 +117,18 @@ export class SImageItem extends SObjectItem {
|
|
height = this.height;
|
|
height = this.height;
|
|
}
|
|
}
|
|
} else if (this.showType == SImageShowType.AutoFit) {
|
|
} else if (this.showType == SImageShowType.AutoFit) {
|
|
|
|
+ // @ts-ignore
|
|
this.width = this.img.width as number;
|
|
this.width = this.img.width as number;
|
|
|
|
+ // @ts-ignore
|
|
this.height = this.img.height as number;
|
|
this.height = this.img.height as number;
|
|
width = this.width;
|
|
width = this.width;
|
|
height = this.height;
|
|
height = this.height;
|
|
}
|
|
}
|
|
|
|
+ // @ts-ignore
|
|
painter.drawImage(this.img, -width / 2, -height / 2, width, height);
|
|
painter.drawImage(this.img, -width / 2, -height / 2, width, height);
|
|
} else {
|
|
} else {
|
|
painter.pen.lineWidth = painter.toPx(1);
|
|
painter.pen.lineWidth = painter.toPx(1);
|
|
- painter.pen.lineDash = [
|
|
|
|
- painter.toPx(3),
|
|
|
|
- painter.toPx(7)
|
|
|
|
- ];
|
|
|
|
|
|
+ painter.pen.lineDash = [painter.toPx(3), painter.toPx(7)];
|
|
painter.pen.color = new SColor("#c0ccda");
|
|
painter.pen.color = new SColor("#c0ccda");
|
|
painter.brush.color = SColor.Transparent;
|
|
painter.brush.color = SColor.Transparent;
|
|
painter.drawRect(this.boundingRect());
|
|
painter.drawRect(this.boundingRect());
|