修复步骤横表手册流程图显示超宽高的显示图内容缺失问题

This commit is contained in:
anhc 2022-09-22 17:16:41 +08:00
parent 5653f21c1d
commit 98e5af9d7b
2 changed files with 17 additions and 2 deletions

View File

@ -328,7 +328,7 @@ public class PrReportComment {
int width = sourceImg.getWidth();
int height = sourceImg.getHeight();
// 如果宽高比大于最大值的宽高比说明图形较宽需判断宽度是否大于最大值
if (width / height > OutputWordUtil.PL_DIAGRAM_MAX_WIDTH / maxHeight) {
/*if (width / height > OutputWordUtil.PL_DIAGRAM_MAX_WIDTH / maxHeight) {
if (width > OutputWordUtil.PL_DIAGRAM_MAX_WIDTH) {
newWidth = OutputWordUtil.PL_DIAGRAM_MAX_WIDTH;
newHeight = height * OutputWordUtil.PL_DIAGRAM_MAX_WIDTH / width;
@ -338,12 +338,27 @@ public class PrReportComment {
}
} else {// 如果宽高比小于最大值的宽高比说明图形较高需判断高度是否大于最大值
if (height > maxHeight) {
newWidth = width * maxHeight / height;
newWidth = width * maxHeight / height - 80;
newHeight = maxHeight;
} else {
newWidth = width;
newHeight = height;
}
}*/
//按照宽高超宽最大比例缩小width与height
if (width> OutputWordUtil.PL_DIAGRAM_MAX_WIDTH || height>maxHeight){
double heightRate = (double) height / maxHeight;
double widthRate = (double) width / OutputWordUtil.PL_DIAGRAM_MAX_WIDTH;
if (widthRate>heightRate){
newWidth = (int) (width/widthRate);
newHeight = (int) (height/widthRate);
}else {
newWidth = (int) (width/heightRate);
newHeight = (int) (height/heightRate);
}
}else {
newWidth = width;
newHeight = height;
}
} catch (FileNotFoundException e) {
e.printStackTrace();