PxRotateImage()

Rotate an image

Synopsis:

#include <photon/PxImage.h>

int PxRotateImage( PhImage_t const *src,
                   PhImage_t *dst,
                   unsigned angle,
                   PxMethods_t const *methods );

Arguments:

src
A pointer to the image that you want to rotate.
dst
A pointer to a PhImage_t structure where the function can store the rotated image.
angle
The angle to rotate the image by; one of the following:
methods
A pointer to a PxMethods_t structure that lets you modify the behavior of the function. For full details about the structure, see the entry for PxLoadImage(); for information about the methods that PxRotateImage() uses, see below.

Library:

phexlib

Description:

This function reads a graphic file into memory. Photon supports at least the BMP, GIF, JPEG, PCX, PNG, and SGI file formats.

To load an image, call PxLoadImage(); to draw an image, call PgDrawPhImage() or PgDrawPhImagemx().

When you're finished with the image, you can free the allocated members of the image structure by calling PhReleaseImage() after setting the image's flag member to indicate which parts of the image should be freed. You can then free the PhImage_t structure. For more information, see PhImage_t.

Methods

The PxMethods_t structure alters how PxRotateImage() behaves. The only methods that PxRotateImage() uses (if specified) are px_alloc, px_free, and px_error: void *(*px_error)( char *msg ); An error routine that you supply. The loader calls this function if it encounters a fatal error while loading the graphic file. The msg argument is a pointer to an error string.

void *(*px_alloc)( long nbytes, int type );
void *(*px_free)( void *memory, int type );
Memory allocation/deallocation routines that you supply. The deallocation routine is called only if the image can't be rotated. The type can be one of the following:

Your px_alloc function must return a pointer to the allocated memory.

void *(*px_error)( char *msg );
An error routine that you supply. PxRotateImage() calls this function if it encounters a fatal error while rotating the image. The msg argument is a pointer to an error string.

Note: Before calling this function, PxRotateImage() frees all of the memory that it allocated


Note: PxRotateImage() doesn't use the value that px_free, px_error, px_warning, and px_progress return. These functions can return NULL to avoid compiler warnings.

Returns:

0 on success, or 1 if an error occurred.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PgDrawPhImage*(), PgDrawPhImageRect*(), PgDrawRepPhImage*(), PgSetPalette(), PgSetFillColor(), PgSetTextColor(), PgShmemCleanup(), PhCreateImage(), PhImage_t, PhMakeGhostBitmap(), PhMakeTransBitmap(), PhMakeTransparent(), PhReleaseImage(), PtCRC(), PtCRCValue(), PxLoadImage(), PxTerminate()

Images in the Raw Drawing and Animation chapter of the Photon Programmer's Guide