[Crash] Out of bounds error when redrawing image after a making another conversion
When doing another conversion, the array of RGB values used to draw the image is accessed incorrectly.
The maxSize variable, responsible for telling the program how big the image is, was not being set to the new maxSize after conversion. It was still the default width of 100.
The correct height and width values from the first conversion were being used to index the smaller 100 width rgb array This meant when the image was resized to be larger than 100 width, the program was attempting to pull information from a position that was no longer there.
The actual source of this, is not only that maxSize was not set after a resize. But is also because when a conversion is complete, a SaveSession and LoadSession call is made. Resulting in the resized image being loaded in with the default maxSize of 100. Which leads to an indexing when the first conversion was made with a width larger than this.
Will leave issue open for further testing.
Currently the same crash occurs after loading a previous conversion, then attempting to convert the same image again without modifying the width/height of the loaded conversion.
For some reason when loading the previous image dimensions to the numericUpDown controlls, it is not reading the correct value in the loop. For example, image width was 68, leading to the 0-67 index in the rgbArray. The loop then tries to access position 68. Despite when the original conversion took place, the numericUpDown was actually set to 68.
So, when loading the converted image, the rgbArray width is being reduced by 1. So when you try to convert, the rgbarray doesn't match the loaded height and width, causing the out of bounds error.
A somewhat easy fix would be to modify the width up and down, removing the conversion. Since a conversion is being made anyway. When doing this manually, everything works fine, and it converts properly.
I'll try to find where this size reduction originates from.