Skip to main content
YTalh.1
Associate II
April 30, 2021
Question

Is there a way to dynamically scale/resize widgets along one axis only?

  • April 30, 2021
  • 4 replies
  • 1264 views

Hi there,

I am using a 800x480 display that does not have square pixels. Therefore, my custom containers are always "stretched" along the y-axis. This is not a problem for static images in my container, since I can scale the image before on the PC side. However, for more complex assets, like images that need to be rotated, I cannot scale the images on the PC side because the scaling needs to change depending at what angle the image is rotated. In other words, the image needs to be scaled dynamically along the y-axis only. Is there a way to do that with TouchGFX?

This topic has been closed for replies.

4 replies

MM..1
Chief III
April 30, 2021

I use this on scalable image

background.setWidth(2*background.getWidth());	
 background.setScalingAlgorithm(touchgfx::ScalableImage::NEAREST_NEIGHBOR);

YTalh.1
YTalh.1Author
Associate II
April 30, 2021

I don't think this will work with any widget though (I tried on my custom container, and it does not rescale the image, it just crops the container to whatever width/height you set it to).

Thank you for your input though.

MM..1
Chief III
May 1, 2021

Oh yes you ask widget but write about images. Widgets except scalable image cant be rescaled only resized as you write result is crop.

Alexandre RENOUX
Visitor II
May 3, 2021

Hello YTalh,

As MM..1 mentioned, you cannot re-scale widgets like this. The only widgets that are re-scalable are only the scalable image, the zoomAnimatedImage and the Texture Mapper. Scaling requires a lot of MCU power so I would suggest you to avoid using it too much depending on which MCU you're working on.

/Alexandre