Hello,
When i try to save an image using the lib, where is there an image with less than 4 pixel sized in width or height, there is a divison error on the DDSGeneral.cs script at line 342:
Error: An exception of type 'System.DivideByZeroException' occurred in CSharpImageLibrary.dll
Additional information: Attempted to divide by zero.
After a simple check to avoid less or equal 4 pixels width/height image saving where the image size is 111:20, another error appears on the DDS_Enconders.cs script at the line 37:
Error: An exception of type 'System.IndexOutOfRangeException' occurred in CSharpImageLibrary.dll
Additional information: Index was outside the bounds of the array.
Here is a chunk of the code used:
` Rectangle rect = Rectangle.FromLTRB(left, top, right, bottom);
if (rect.Width <= 0 || rect.Height <= 0)
return;
if (rect.Width <= 4 || rect.Height <= 4)
return;
try
{
bmp = bmp.Clone(rect, bmp.PixelFormat);
using (var stream = new MemoryStream())
{
bmp.Save(stream, ImageFormat.Png);
ImageEngineImage img = new ImageEngineImage(stream.ToArray());
img.Save(path + @"\" + subImage.name + "." + extension, ImageEngineFormat.DDS_DXT3, MipHandling.KeepExisting, 0, 0, false);
}
}
catch (Exception e)
{
LogManager.Instance.MsgError("Could not save image " + path + @"\" + subImage.name + "." + extension
+ "\nError: " + e.Message);
}`
Best Regards