cancel
Showing results for 
Search instead for 
Did you mean: 

How to change needle as image file instead of shape point?

JongOk Baek
Associate III

Hello,

I tested Gauge widget.

So, I modified source code to change needle shape in Gauge.hpp.

// triangle

original : ShapePoint<float> points[3] = { { -2.5f, 0}, {0.0f, -70}, {2.5f, 0} };

// rectangle

modify : ShapePoint<float> points[4] = { { -1.0f, 0}, {-1.0f, -90}, {1.0f, -90}, {1.0f, 0} };

It was good.

But, I want to apply image file instead of shape point.

How to change needle as image file?

Let me know it!

Best regards,

Thanks.

3 REPLIES 3
Martin KJELDSEN
Chief III

Which "Gauge" Widget is this?

Dear Martin,

Thanks for your reply.

Refer to the below link

https://github.com/touchgfx/touchgfx-open-repository/tree/master/widgets/Gauge

Best regards,

scottSD
Senior III

There is a function in the Gauge class you provided called "setBitmaps" where you can change the background image and center image:

void Gauge::setBitmaps(Bitmap backgroundBmp, Bitmap centerBmp)
{
    background.setBitmap(backgroundBmp);
    background.setXY(0, 0);

I am pretty sure this Gauge class uses the "Shape" widget to create the points of the needle(s), so you won't be able to apply an "image" to the needle.

About the only way to do this is to use the Texture Mapper with an image and rotate it with animation. The Texture Mapper is very processor resource intensive (doesn't use ChromArt). If you want to experiment with it, take a look at the Analog Clock widget. Awhile back I played around changing the image for that widget, so I know it can be done.

That being said, I did manually create some decently detailed needles using the Shape class it just takes a lot of points and multiple shapes set to different colors. :smirking_face:

And the best part about that was that the Shape widget utilizes ChromArt.