Rotating a 1D matrix

So the way I render images onto the screen involves having an array of color data from a buffered image. I can manipulate that one image, through the color data, and basically render any other image into that main buffered image. The problem I’m having right now is I’m having trouble implementing a rotation transformation correctly on this array.
I’ve gotten strange results, where the sprite is rotating around the origin (top left corner). I couldn’t really figure out how to make it rotate around it’s center or any point. Also with that rotation, there are tiny gaps in the sprite while it’s rotating.