e. Scissor Function

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 09 - Setting Graphics Context >

e. Scissor Function

This section shows how to crop images using the Scissor() command.

 

 

Command Prototype

 

uint16_t Scissor(int X,int Y,int Width,int Height)

 

Parameters

Description

X Y

(x,y) coordinates

Width

Scissor width

Height

Scissor height

 

 

Code

 

 

void setup()

{

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

 CleO.begin();

 

/* Get bitmap handle */

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

 

/* Start building a screen frame */

 CleO.Start();

 

/* Display original bitmap */

 CleO.Bitmap(handle, 0, 0);

 

/* Select the scissor area */

 CleO.Scissor(200, 290, 100, 130);

 

 /* Display bitmap - only area under scissor will get displayed */

 CleO.Bitmap(handle, 130, 250);

 

 /* Display completed screen frame */

 CleO.Show();

}

 

void loop() {}

 

 

Description

 

In the above code snippet, "ctg.jpg" bitmap is loaded and drawn at (0,0).

Subsequently, using the Scissor() command, scissor area is selected by defining the region using left, top, right and bottom coordinate values. The same bitmap is drawn again at (130,250) to display the cropped image (i.e. only the face in the bitmap).

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 -

 

ScissorFunction