Rotation (XForms (Forms Library) - Version 1.2 (Rev. 4) A Graphical User Interface Toolkit for X)

Next: Image Flipping, Previous: Tint, Up: Simple Image Processing [Contents][Index]

#### 37.7.3 Rotation

Image rotation can be easily done with the following routine

    int flimage_rotate(FL_IMAGE *im, int angle, int subpixel);

where `angle` is the angle in one-tenth of a degree (i.e., a 45 degree rotation should be specified as 450) with a positive sign for counter-clock rotation. The parameter `subpixel` should be one of the following, specifying if subpixel sampling should be enabled. It can be set to either `FLIMAGE_NOSUBPIXEL` or `FLIMAGE_SUBPIXEL`.

If subpixel sampling is enabled, the resulting image pixels are interpolated from the original pixels. This usually has an "anti-aliasing" effect that leads to less severe jagged edges and similar artifacts commonly encountered in rotations. However, it also means that a color indexed image gets converted to a RGB image. If preserving the pixel value is important, you should not turn subpixel sampling on.

`flimage_rotate()` return a negative number if it for some reason (usually due to running out of memory) fails to perform the rotation.

Since the rotated image has to be on a rectangular grid, the regions that are not occupied by the image are filled with a fill color, where the default is black. If a different fill color is desired you can set the `image->fill_ccolor` field to a packed RGB color before calling the rotation function. Note that even for color indexed images the fill color should be specified in RGB. The rotation function will search the colormap for the appropriate index if no subpixel sampling is used.

Repeated rotations should be avoided if possible. If you have to call it more than once it’s a good idea to crop after rotations in order to get rid of the regions that contain only fill color.

Next: Image Flipping, Previous: Tint, Up: Simple Image Processing [Contents][Index]