Rotate an image

Rotate an image

Hi

I'm trying to rotate a bitmap by 90 degrees, but cannot seem to manage it. My bitmap is 200 * 100 24 bit. In particular it is the roi mapping that I am having difficulty with, I can get 180 degrees to work, but 90 degrees results in a cropped image. Can anyone point me in the right direction, preferably with a code snippet.

Thanks

Chris

4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Chris,
Since you have a rectangular image (200x100) the rotation of 90 degrees will crop the image as ithas to since its trying to put 200 pixels in the vertical 100 pixel direction. If you rotate the full 180 then the (upside down) rectangle fits without cropping. To avoid cropping therefore you will need to create a new image and copy the rotated image to it. The new image can be 200 w x 100 h to avoid cropping or 200 x 200 if you don't mind black sides.
Rick

Hi,

there is a piece of code to demonstrate

#define Width 200
#define Height 100

Ipp8u src[Width * Height * 3];
Ipp8u dst[Height * Width * 3];
int srcStep = Width * 3;
int dstStep = Height * 3;
IppiRect srcROI = {0,0, Width, Height};
IppiSize srcSize = {Width, Height};
IppiSize dstROI = {0, 0, Height, Width};

ippiRotate_8u_C1R(src, srcSize, srcStep, srcROI, dst, dstStep, dstROI, 90, 0, Height - 1, IPPI_INTER_NN);

And of course, you cam use ippiMirror function if you need only 90/180/and so on rotation

Regards,
Vladimir

Thank you, got my head around it now.

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui