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:
parent
a25957b79c
commit
85d774a273
@ -788,11 +788,12 @@ namespace Volian.Controls.Library
|
|||||||
using (Item _MyItem = MyItemInfo.Get())
|
using (Item _MyItem = MyItemInfo.Get())
|
||||||
{
|
{
|
||||||
byte[] imgToByte = imageToByteArray(MyPictureBox.Image, FileName);
|
byte[] imgToByte = imageToByteArray(MyPictureBox.Image, FileName);
|
||||||
|
if (imgToByte == null) return;
|
||||||
int origLen = imgToByte.Length;
|
int origLen = imgToByte.Length;
|
||||||
bool compressed = false;
|
bool compressed = false;
|
||||||
// if file is a tif or bmp see if compressing it saves space and if so, save the
|
// 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.
|
// 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);
|
byte[] cmp = ROImageInfo.Compress(imgToByte);
|
||||||
if (origLen > cmp.Length)
|
if (origLen > cmp.Length)
|
||||||
@ -874,6 +875,7 @@ namespace Volian.Controls.Library
|
|||||||
ifmt = System.Drawing.Imaging.ImageFormat.Jpeg;
|
ifmt = System.Drawing.Imaging.ImageFormat.Jpeg;
|
||||||
break;
|
break;
|
||||||
case ("TIF"):
|
case ("TIF"):
|
||||||
|
case ("TIFF"):
|
||||||
ifmt = System.Drawing.Imaging.ImageFormat.Tiff;
|
ifmt = System.Drawing.Imaging.ImageFormat.Tiff;
|
||||||
break;
|
break;
|
||||||
case ("WMF"):
|
case ("WMF"):
|
||||||
@ -930,27 +932,43 @@ namespace Volian.Controls.Library
|
|||||||
else
|
else
|
||||||
img = null;
|
img = null;
|
||||||
}
|
}
|
||||||
if (img==null)
|
if (img == null)
|
||||||
{
|
{
|
||||||
OpenFileDialog openFileDialog1 = new OpenFileDialog();
|
OpenFileDialog openFileDialog1 = new OpenFileDialog();
|
||||||
openFileDialog1.InitialDirectory = "c:\\";
|
openFileDialog1.InitialDirectory = "c:\\";
|
||||||
openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
|
openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
|
||||||
openFileDialog1.FilterIndex = 0;
|
openFileDialog1.FilterIndex = 0;
|
||||||
openFileDialog1.RestoreDirectory = true;
|
openFileDialog1.RestoreDirectory = true;
|
||||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
DialogResult dr = openFileDialog1.ShowDialog();
|
||||||
|
if (dr == DialogResult.OK)
|
||||||
{
|
{
|
||||||
// check that it is an image
|
// check that it is an image
|
||||||
|
try
|
||||||
|
{
|
||||||
img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
|
img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
img = null;
|
||||||
|
}
|
||||||
if (img != null) filename = openFileDialog1.FileName;
|
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);
|
byte[] imgToByte = imageToByteArray(img, filename);
|
||||||
int origLen = imgToByte.Length;
|
int origLen = imgToByte.Length;
|
||||||
bool compressed = false;
|
bool compressed = false;
|
||||||
// if file is a tif or bmp see if compressing it saves space and if so, save the
|
// 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.
|
// 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);
|
byte[] cmp = ROImageInfo.Compress(imgToByte);
|
||||||
if (origLen > cmp.Length)
|
if (origLen > cmp.Length)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user