Hello. I am trying to rotate an image by any angle in embedded c and I am stuck on how to move forward. The current code I have is the following:

/* Calculate Trig Paramters for Rotation */ float tmpCos = cos(rot), tmpSin = sin(rot); /* For each point */ for(int bmp_row = 0; bmp_row < 29; bmp_row++) for(int bmp_col = 0; bmp_col < 29; bmp_col++) /* Push color if point is '1' at rotated position*/ if(arrow_BMP[bmp_row][bmp_col] == 1) ili9341_drawPixel(x + bmp_row*tmpCos - bmp_col*tmpSin, y + bmp_row*tmpSin + bmp_col*tmpCos, color);

The image is rotating by the correct angle, but the pivot point is not the center. Furthermore, some pixels are not filled in, which I assume is due to integer cutoff from cos/sin calculation.

Can someone please tell me if there is a better way to rotate an image by any angle in embedded c or how to fix these problems?