pygame documentation | || Home || Help Contents || || pygame || cdrom || constants || cursor || display || draw || || event || font || image || joystick || key || mixer || || mixer_music || mouse || movie || sndarray || surfarray || time || || transform || || CD || Channel || Clock || Font || Joystick || Movie || || Overlay || Rect || Sound || Surface || || color || cursors || sprite ||

## pygame.transform

Contains routines to transform a Surface image.
All transformation functions take a source Surface and return a new copy of that surface in the same format as the original.
Some of the filters are 'destructive', which means if you transform the image one way, you can't transform the image back to the exact same way as it was before. If you plan on doing many transforms, it is good practice to keep the original untransformed image, and only translate that image.

chop | - remove a region of an surface
flip | - flips a surface on either axis
rotate | - rotate a Surface
rotozoom | - smoothly scale and/or rotate an image
scale | - scale a Surface to an arbitrary size
scale2x | - doubles the size of the image with advanced scaling

chop
`pygame.transform.chop(Surface, rectstyle) -> Surface`

Removes an interior set of columns and rows from a Surface. All vertical and horizontal pixels surrounding the given rectangle area are removed. The resulting image is shrunken by the size of pixels removed.

flip
`pygame.transform.flip(Surface, xaxis, yaxis) -> Surface`

Flips the image on the x-axis or the y-axis if the argument for that axis is true.
The flip operation is nondestructive, you may flip the image as many times as you like, and always be able to recreate the exact original image.

rotate
`pygame.transform.rotate(Surface, angle) -> Surface`

Rotates the image counterclockwise with the given angle (in degrees). The angle can be any floating point value (negative rotation amounts will do clockwise rotations)
Unless rotating by 90 degree increments, the resulting image size will be larger than the original. There will be newly uncovered areas in the image. These will filled with either the current colorkey for the Surface, or the topleft pixel value. (with the alpha channel zeroed out if available)
This transformation is not filtered.

rotozoom
`pygame.transform.rotozoom(Surface, angle, zoom) -> Surface`

The angle argument is the number of degrees to rotate counter-clockwise. The angle can be any floating point value. (negative rotation amounts will do clockwise rotations)
This will smoothly rotate and scale an image in one pass. The resulting image will always be a 32bit version of the original surface. The scale is a multiplier for the image size, and angle is the degrees to rotate counter clockwise.
It calls the SDL_rotozoom library which is compiled in. Note that the code in SDL_rotozoom is fairly messy and your resulting image could be shifted and contain artifacts.

scale
`pygame.transform.scale(Surface, size) -> Surface`

This will resize a surface to the given resolution. The size is simply any 2 number sequence representing the width and height.
This transformation is not filtered.

scale2x
`pygame.transform.scale2x(Surface) -> Surface`

This will return a new image that is double the size of the original. It uses the AdvanceMAME Scale2X algorithm which does a 'jaggie-less' scale of bitmap graphics.
This really only has an effect on simple images with solid colors. On photographic and antialiased images it will look like a regular unfiltered scale.