B2016-235: files with extension of ‘.tiff’ failed in Embedded image support.

B2016-234: Inserting image ‘after’ with delete caused crash.
This commit is contained in:
Kathy Ruffing 2016-10-21 14:05:49 +00:00
parent a25957b79c
commit 85d774a273

View File

@ -788,11 +788,12 @@ namespace Volian.Controls.Library
using (Item _MyItem = MyItemInfo.Get())
{
byte[] imgToByte = imageToByteArray(MyPictureBox.Image, FileName);
if (imgToByte == null) return;
int origLen = imgToByte.Length;
bool compressed = false;
// if file is a tif or bmp see if compressing it saves space and if so, save the
// compressed data with a flag in config, the size needed to decompress, to show it is compressed.
if (FileName.ToUpper().EndsWith(".TIF") || FileName.ToUpper().EndsWith(".BMP"))
if (FileName.ToUpper().EndsWith(".TIFF") || FileName.ToUpper().EndsWith(".TIF") || FileName.ToUpper().EndsWith(".BMP"))
{
byte[] cmp = ROImageInfo.Compress(imgToByte);
if (origLen > cmp.Length)
@ -874,6 +875,7 @@ namespace Volian.Controls.Library
ifmt = System.Drawing.Imaging.ImageFormat.Jpeg;
break;
case ("TIF"):
case ("TIFF"):
ifmt = System.Drawing.Imaging.ImageFormat.Tiff;
break;
case ("WMF"):
@ -930,27 +932,43 @@ namespace Volian.Controls.Library
else
img = null;
}
if (img==null)
if (img == null)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
// check that it is an image
img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
try
{
img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
}
catch (Exception ex)
{
img = null;
}
if (img != null) filename = openFileDialog1.FileName;
}
if (filename == null) return; // user must have existed out. How to handle??
if (filename == null)
{
if (dr != DialogResult.Cancel)
{
string msg = string.Format("Could not display image {0}.", openFileDialog1.FileName);
MessageBox.Show(msg);
}
return; // user must have exited out or entered a bad filename.
}
}
byte[] imgToByte = imageToByteArray(img, filename);
int origLen = imgToByte.Length;
bool compressed = false;
// if file is a tif or bmp see if compressing it saves space and if so, save the
// compressed data with a flag in config, the size needed to decompress, to show it is compressed.
if (filename.ToUpper().EndsWith(".TIF") || filename.ToUpper().EndsWith(".BMP"))
if (filename.ToUpper().EndsWith(".TIFF") || filename.ToUpper().EndsWith(".TIF") || filename.ToUpper().EndsWith(".BMP"))
{
byte[] cmp = ROImageInfo.Compress(imgToByte);
if (origLen > cmp.Length)