[NECTO Studio 2.1.0] gl_set_crop_borders doesn't work [solved]

Cross-platform IDE for the rapid development of applications for the embedded world, available on Windows, Linux, and macOS.
Post Reply
Author
Message
frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

[NECTO Studio 2.1.0] gl_set_crop_borders doesn't work [solved]

#1 Post by frank.malik » 16 Sep 2022 10:57

Hello,

made a small project on mikromedia 3 with PIC32MZ to test the gl_set_crop_borders function.

However, this doesn't work. Project attached.
Test_CropBorder.zip
(13.13 KiB) Downloaded 41 times

Code: Select all

    // Specify area on display for drawing.
    err_ret = gl_set_crop_borders(-1, -1, -1, -1); // Set hole display enabled because the area is invalid
    gl_draw_rect(50,50, 50, 50);         // Hole rect is visible

    // Specify area on display for drawing
    err_ret = gl_set_crop_borders(-5,-3, 75, 75); // Set borders for drawing on y=75 and x = 75 at right and bottom, while top and right borders are corrected to zeros.
    gl_draw_rect(65, 65, 50,50);          // Part of rect is cropped, and display has only rect between 50,50,75, 75

    // Specify area on display for drawing
    err_ret = gl_set_crop_borders(250,250, 300, 300); // Set borders for drawing between coordinates y=250 and y=300, x=250 and x=300
    gl_draw_rect(40, 40, 50,50);                 // Since rectangle does not appears in previously specified area, hole rect is not visible.
The code contains the commands to draw three rectangles, however, only one, the first one, should be
drawn completely. The second should be cropped and the third rectangle shouldn't be drawn at all.

In reality, all three rectangles are visible on the display.
Attachments
NECTO Studio v2.1.0 - gl_set_crop_borders.png
NECTO Studio v2.1.0 - gl_set_crop_borders.png (25.16 KiB) Viewed 1021 times
Last edited by frank.malik on 27 Oct 2022 20:09, edited 1 time in total.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: [NECTO Studio 2.1.0] gl_set_crop_borders doesn't work

#2 Post by frank.malik » 16 Sep 2022 13:29

Hello again,

further tests show that in the end only one condition seems to fail:

Code: Select all

err_ret = gl_set_crop_borders(-5,-3, 75, 75);
This function returns with "true" and the borders are set to the display size ( 0, 0, 240, 320 )
Actually, according to the comment, it should only correct the minus values to zero, so that the borders are set like this ( 0, 0, 75, 75 )

This might be caused by the first if-clause in the gl.c file that checks the top and left values against the height resp the width. However,
the type of top is gl_coord_t, which is in fact int16_t, whereas the type of display_height is uint16_t. I think the comparison
of int16_t with uint16_t type variables might fail.

Code: Select all

    // If area is out of screen then set crop rect to screen's dimension
    if (top >= instance.driver.display_height
        || left >= instance.driver.display_width
        || right < 0
        || bottom < 0
        || bottom < top
        || right < left
    )
Using only positive numbers, except you want to reset the crop borders to the displays defaults, works as far as I could test so far.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [NECTO Studio 2.1.0] gl_set_crop_borders doesn't work

#3 Post by filip » 27 Oct 2022 10:14

Hi,

For cropping, please refer to the following code :

Code: Select all

// left crop
gl_set_crop_borders(27, 0, 52, 54);    

// top crop
// gl_set_crop_borders(0, 27, 52, 54);

// bottom crop
// gl_set_crop_borders(0, 0, 26, 54);    

// right crop
// gl_set_crop_borders(0, 0, 52, 27); 

// draw rectangle
gl_draw_rect(3, 1, 50,50);
The first line will crop the half of rectangle from the left border of the screen and the other similarly.

See the gl_set_crop_borders function explanation in the mikroSDK reference manual :
https://docs.mikroe.com/mikrosdk/ref-ma ... 66c1b0e243

As for the example code that you are referring to, I presume it some kind of left over from previous iterations, I'm sorry for the confusion.

Regards,
Filip.

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: [NECTO Studio 2.1.0] gl_set_crop_borders doesn't work [solved]

#4 Post by frank.malik » 27 Oct 2022 20:08

Hello Filip,

thanks for your reply, and the new example. No negative values seems to be ok for the gl_set_crop_borders function.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

Post Reply

Return to “IDE”