Hello, I am trying to reverse an image of a texture2D. I have tried many different attempts at this problem to no avail (including, but not limited to: Reverse() of arraylist, mixing jagged arrays, and looping through individual pixels). Here is a snippet of code for the reverse function.
void ReverseImageX(Texture2D image)
{
//Get the array ready
Color[][] newColorArrayWidth = new Color[image.height][];
//Deconstruct the picture and get every pixel
for(int i = 0; i < image.height; i++)
{
//Get the width of the picture
for(int j = image.width - 1; j >= 0; j--)
{
newColorArrayWidth*[j] = image.GetPixel(j, i); //Error here: NullReferenceException: Object reference not set to an instance of an object*
-
}* -
}* -
//Reconstruct the picture reveresed in the X-axis* -
for(int i = 0; i < image.height; i++)* -
{* -
//use the width of the picture to reconstruct the image* -
for(int j = 0; j > image.width; j++)* -
{* -
//Reconstruct*
_ image.SetPixel(j, i, newColorArrayWidth*[j]);_
_ }_
_ }_
_ }_
I am also trying to not only reverse the image horizontally, but also vertically. But I assume that it is just messing with the for loops to get that desired effect.
_The error is happening on line 364 (in this case it is: "newColorArrayWidth[j] = image.GetPixel(j, i);") and is not storing the color in the multidimensional array. I know this function is working by reciving the image through the parameter and going through the loop conditions, but stops at that line.*_