Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

Width or Height equal or under 4 pixels #10

Description

@OriDevTeam

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions