c. Bitmap Justification Parameters

<< Click to Display Table of Contents >>

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

c. Bitmap Justification Parameters

CleO currently supports ten different justifications for the bitmap, namely -

 

1.TL - Top Left

2.TM - Top Middle

3.TR - Top Right

4.ML - Middle Left

5.MM - Middle Middle

6.MR - Middle Right

7.BL - Bottom Left

8.BM - Bottom Middle

9.BB - Bottom Bottom

10.BR - Bottom Right

 

The Default justification is TL - Top Left.

 

Note: Bottom Right (BR) and Bottom Bottom (BB) are equivalent of each other.

 

To draw an image using a bitmap file, you are required to load the bitmap file first and get the handle. The following command prototype is used to select the desired justification. Bitmap() command is used to draw a bitmap at (x,y) location.

 

 

Command Prototype

 

uint16_t BitmapJustification(just_t Justification);

 

Parameters

Description

Justification

Top Left (TL), Top Middle (TM), Top Right (TR), Middle Left (ML), Middle Middle (MM), Middle Right (MR), Bottom Left (BL), Bottom Middle (BM) or Bottom Bottom (BB) or Bottom Right (BR)

 

uint16_t Bitmap(int16_t Handle, int X, int Y)

 

Parameters

Description

Handle

returns value from LoadImageFile() commmand

X

x coordinate value

Y

y coordinate value

 

 

Code

 

 

void setup()

{

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

 CleO.begin();

 

/* Get the handle for the image */

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

 

/* Start building a screen frame */

 CleO.Start();

 

 /* Select MM as a justification for bitmap drawing */

 CleO.BitmapJustification(MM);

 

/* Draw a bitmap at (400, 240) using im handle */

 CleO.Bitmap(im, 400, 240);

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop() { }

 

 

Description

 

In the above sample code snippet, the bitmap justification is set at MM using the BitmapJustification() command. A Bitmap is drawn using Bitmap() command at the center of the screen. Different values of justification may be tried using the BitmapJustification() command to see its effect on the bitmap drawing.

 

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

 

 

Output

 

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

Tutorials03-BitmapParameters.50

 

The sample screen shot below shows different bitmap justification locations -

 

Tutorials03-JustificationParameters1

Tutorials03-JustificationParameters2

Tutorials03-JustificationParameters3

Tutorials03-JustificationParameters4

Tutorials03-JustificationParameters5