B2024-060-Adding-a-picture-PROMS-crashes

This commit is contained in:
2024-08-26 11:11:03 -04:00
parent 516b479c0c
commit 7a3748f7e0
2 changed files with 11 additions and 53 deletions

View File

@@ -321,11 +321,7 @@ namespace Volian.Controls.Library
int wd = img.Width * MyStepPanel.DPI / 72; // converts from screen resolution's DPI to image's points (72/inch)
int ht = img.Height * MyStepPanel.DPI / 72;
//int wd = adjustimage(img.Width); // * MyStepPanel.DPI / 72; // converts from screen resolution's DPI to image's points (72/inch)
//double ht = (double)wd * aspectratio(img.Width, img.Height);
//int ht = adjustimage(img.Height); // * MyStepPanel.DPI / 72;
if (MyItemInfo.MyContent.MyImage != null) // image is null if creating new.
{
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
@@ -333,16 +329,12 @@ namespace Volian.Controls.Library
{
wd = ic.Image_Width * MyStepPanel.DPI / 72;
ht = ic.Image_Height * MyStepPanel.DPI / 72;
//wd = adjustimage(ic.Image_Width); // * MyStepPanel.DPI / 72;
//ht = (double)wd * aspectratio(img.Width, img.Height);
//ht = wd * (int)aspectratio(img.Width, img.Height);
//ht = adjustimage(ic.Image_Height); // * MyStepPanel.DPI / 72;
}
}
MyPictureBox.Visible = true;
MyPictureBox.Width = wd;
MyPictureBox.Height = (int)ht;
MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height.
this.Width = MyPictureBox.Width + ImageMargin;
this.Height = MyPictureBox.Height + 10;
@@ -353,35 +345,7 @@ namespace Volian.Controls.Library
_displayTags.TbFSht = ht.ToString();
}
}
// B2024-060 adjust pasted image if too large. If the image is too large PROMS crashes.
private int adjustimage(int dim)
{
int dim2 = dim * MyStepPanel.DPI / 72;
if (dim2 > _displayTags.TrBarFS.Maximum)
{
//int y = dim2 - _displayTags.TrBarFS.Maximum;
////int a = y * 72 / MyStepPanel.DPI;
//int a = y * MyStepPanel.DPI / 72;
//dim = dim - a;
//dim2 = dim * MyStepPanel.DPI / 72;
dim2 = _displayTags.TrBarFS.Maximum * 72 / MyStepPanel.DPI;
}
else
{
return dim2;
}
return dim2;
}
// B2024-060 Get aspect ratio to resize pasted image.
private double aspectratio(int w, int h)
{
//double ratio = Math.Max((double)image.width / (double)box.width, (double)image.height / (double)box.height);
//image.width = (int) (image.width / ratio);
//image.height = (int) (image.height / ratio);
double ratio = (double)h / (double)w;
return ratio;
}
// the following gets called for 'NEW' images
private E_ImageSource InsType = E_ImageSource.None;