Yes, that is definitely possible. However, if you'd like some help beyond general algorithmic guidance, you'll probably need to tell us what your host program is.

That said, the formulae for 2d rotation are:

x' = x * cos(Ɵ) - y * sin(Ɵ)
y' = x * sin(Ɵ) + y * cos(Ɵ)

That needs to be done on a per-pixel basis. Also, you'll need to correct for the 0 point of your raster. You want to rotate around the center, not 0, which is probably in the lower-left, so multiply x and y by 1/2 of your image's resolution.