Index was outside the bounds of the array

I am getting the following exception when trying to resize an image using Aspose.Imaging for .NET.


System.IndexOutOfRangeException was unhandled by user code
Message=Index was outside the bounds of the array.
Source=Aspose.Imaging
StackTrace:
at ..a(Color[] , Int32 , Int32 , Int32 , Int32 , ResizeType )
at ..(Color[] , Int32 , Int32 , Int32 , Int32 , ResizeType )
at ..(Bitmap , ImageFormat , StreamContainer , Int32 , Int32 , ResizeType )
at Aspose.Imaging.FileFormats.Png.PngImage.Resize(Int32 newWidth, Int32 newHeight, ResizeType resizeType)
at Aspose.Imaging.Image.Resize(Int32 newWidth, Int32 newHeight)
at PetroTrek.Document.Formatters.DrawingHelper.Resize(Int32 width, Int32 height) in C:\Workspaces\PetroTrek.Document.Formatters\PetroTrek.Document.Formatters\DrawingHelper.cs:line 72
at OpenXmlWebApp.EditImage.Page_Load(Object sender, EventArgs e) in C:\Workspaces\PetroTrek.Document.Formatters\OpenXmlWebApp\EditImage.aspx.cs:line 49
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

Here is the C# code I am running.
int width = 690;
int height = 100;
m_image.Resize(width, height);

Attached is the file I am trying to resize.

Thanks for any help you can provide!

Jorge

Hi Jorge,

Sorry for the inconvenience faced. While using the latest version of Aspose.Imaging i.e. v1.7.0, I have managed to reproduce this issue on my side. I have logged the issue in our bug tracking system, the issue ID is IMAGING-33307. I have also linked your request to this issue and you will be notified as soon as it is resolved via this thread.

Meanwhile, you can use another Resize overload method with an additional parameter of Resizetype. Please try it as following; hopefully it will serve the purpose.

using (Aspose.Imaging.Image Image = spose.Imaging.Image.Load("C:\\temp\\rpt_blank.png"))
{
    Image.Resize(690, 100, Aspose.Imaging.ResizeType.NearestNeighbourResample);
    Image.Save("C:\\temp\\690output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

Please feel free to contact us for any further assistance.

Best Regards,

Thank you! This seemed to workaround the issue. The output image still looks fine.

Jorge

Hi Jorge,

Thanks for your feedback. It is perfect that you managed to achieve your desired results. However, we will keep you updated about logged issue status, IMAGING-33307.

Please feel free to contact us for any further assistance.

Best Regards,

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.