Color[][] is not storing color. Object reference not set to an instance of an object.

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.*_

For multidemention array use:

 void ReverseImageX(Texture2D image) {
  //Get the array ready
  //Create right multidemention array
  Color[ , ] newColorArrayWidth = new Color[image.height, image.width];

  //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--) {
    //In your case newColorArrayWidth*[j] is not always GetPixel(j, i), only square picture*

newColorArrayWidth[image.width - 1 - j , i] = image.GetPixel(j, i); //get right colors and position into array
}
}
//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]);
}
}
image.Apply(); //apply to memory
}
I hope that it will help you.
P.S.: If you want use array[][], than you must initialization it:
Color[][] newColorArrayWidth = null;
newColorArrayWidth = new Color[image.height][];
for(int i = 0; i < image.height; i++) {
newColorArrayWidth = new Color[image.width];
}

The enclosed function shows an easier way to flip a texture horizontally and vertically.

Texture2D FlipTexture(Texture2D original){
           Texture2D flipped = new Texture2D(original.width,original.height);
           int xN = original.width;
           int yN = original.height;
           for(int i=0;i<xN;i++){
              for(int j=0;j<yN;j++){
                  flipped.SetPixel(xN-i-1, yN-j-1, original.GetPixel(i,j));
              }
			}
	flipped.Apply();
	return flipped;
}

Note code is not tested
code_warrior