cancel
Showing results for 
Search instead for 
Did you mean: 

How to drawing geometric shapes on dynamic bitmap - suggestions needed

rBlr
Associate III

Hello

I need to draw on the dynamic bitmap up to hundred of different geom. shapes, starting from basic line, than rectangle, ellipse, triangle, and some more complex like Bezier curves.
How could one achieve this, if I need  set pixel-by-pixel of all these shapes to bitmap cache?
Is there any libraries that could helps with this implementation, I assume it is not rare task and already implemented?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @rBlr ,

The project you have is very complex, I will try to give you some hints you can use, if you wanted an application where you can only draw figures like a paint canvas then the dynamic bitmap would be sufficient but since you also want to edit/remove these figures it's much more complex.

For very complex figures (freehand writing, Bezier curve), you will need to find a way to store them separately in a dynamic bitmap that you will feed into a scalable image, to be able to edit it.

You may use widgets directly then for line/circle/box , and if you want to export your final image then you may fill it to a dynamic bitmap and save it. Otherwise, if you want to save the result and be able to modify it after, then you'll need to save it somehow and parse it back to their original state in the app.

I hope that helps you,

Regards,

Louis BOUDO
ST Software Developer | TouchGFX

View solution in original post

6 REPLIES 6
rBlr
Associate III

Or any example/suggestion for init Canvas, draw lines on it (using built-in function, ex. lineTo) and/or classes ex: Line, Circle and then copy to dynamic bitmap?

Thank you

LouisB
ST Employee

Hi @rBlr ,

You can refer to the documentation here : Canvas Widgets | TouchGFX Documentation , it gives you some examples on how to use it. You may try to use the Canvas to draw and set the buffer the dynamic bitmap's buffer.

Otherwise if you only use dynamic bitmap, you'll have to implement the calculations by yourself.
I hope that helps you.
Regards,

Louis BOUDO
ST Software Developer | TouchGFX
rBlr
Associate III

Thank you for reply

For me it is bit complicated to understand. Even I can't figure out could I use canvas only new widgets (created by myself) or I could use directly in my app. Than I looking for very simple example app that just use canvas widget to draw eg. line and that will be enough for me to move forward (copy canvas to bitmap to display it contest).

LouisB
ST Employee

Hello @rBlr ,

Could you tell me what do you mean by drawing ? You want to draw them at once or draw them dynamically like in paint application ?

Regards,

Louis BOUDO
ST Software Developer | TouchGFX
rBlr
Associate III

Hello  @LouisB 

User will specify coordinates and other options of figures (start and end position for line, radius and center point for circle, etc),  user could add/edit/remove any, in result it could be up to 1000 different figures (will be stored in some kind of memory like SD card, etc, user could load and save the drawing) and all figures should be displayed altogether despite is there only 1 or 1000. Figures will not be filled and have only 1 color, but user could select any from RGB colors range.

Hope this explanation will be clarify for you. Regards.

Hello @rBlr ,

The project you have is very complex, I will try to give you some hints you can use, if you wanted an application where you can only draw figures like a paint canvas then the dynamic bitmap would be sufficient but since you also want to edit/remove these figures it's much more complex.

For very complex figures (freehand writing, Bezier curve), you will need to find a way to store them separately in a dynamic bitmap that you will feed into a scalable image, to be able to edit it.

You may use widgets directly then for line/circle/box , and if you want to export your final image then you may fill it to a dynamic bitmap and save it. Otherwise, if you want to save the result and be able to modify it after, then you'll need to save it somehow and parse it back to their original state in the app.

I hope that helps you,

Regards,

Louis BOUDO
ST Software Developer | TouchGFX