d. Bitmap Rotation

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 03 - Displaying Bitmaps & Icons >

d. Bitmap Rotation

This section shows how to rotate the bitmaps at various angles on justification using the BitmapTransform() command.

 

 

Command Prototype

 

uint16_t BitmapTransform(int Scale, int16_t Rotate);

 

Parameters

Description

Scale

decides the scaling value, 1 indicates no scaling

Rotate

angle of rotation

 

 

Code

 

 

void setup()

{

 int centerX = 800 / 2, centerY = 480 / 2;

 

/* Initialize CleO - needs to be done only once */

 CleO.begin();

 

/* Get the handle by loading bitmap */

 int16_t handle = CleO.LoadImageFile("@Pictures/ctg.jpg", 0);

 

/* Start building a screen frame */

 CleO.Start();

 

 CleO.StringExt(FONT_MEDIUM, centerX, 50, LIGHT_GREEN, MM, 0, 0,"30 degrees rotation");

 CleO.StringExt(FONT_MEDIUM, centerX, 425, LIGHT_GREEN, MM, 0, 0, "MM Justification");

 

/* Draw bitmap at 30 degrees rotation with MM justification */

 CleO.BitmapJustification(MM);

 CleO.BitmapTransform(1, 30);

 CleO.Bitmap(handle, centerX, centerY);

 

/* Draw a point at bitmap justification for a reference */

 CleO.PointRadius(10);

 CleO.PointColor(LIGHT_GREEN);

 CleO.Point(centerX, centerY);

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop() { }

 

 

Description

 

The above code snippet uses the BitmapJustification() command to select the justification.

The BitmapTransform() command rotates the bitmap on this rationale.

Since there is no change to the scaling of the bitmap, value one is passed as a parameter to the BitmapTransform() command.

A point is drawn as a reference to show the center of rotation.

Use the @ symbol only when performing the file operation from the eFlash and not from the SD Card.

 

Note: The range is from (minimum) 1/8th of the bitmap size and it is up to (maximum) 256 times of the bitmap size.

 

 

Output

 

Here is the output  upon executing the above sample code snippet -

 

Tutorials03-BitmapRotation.50