samavr
Junior Member
Posts: 16
|
Post by samavr on Aug 19, 2021 8:00:15 GMT -8
How can I rotate a bitmap around its center without clipping the corners? I have increased the size using
GD.BitmapSize(NEAREST, BORDER, BORDER, 189, 188);
and I use this function to rotate
static void rotate(uint16_t a) { GD.cmd_translate(F16(64), F16(64)); GD.cmd_rotate(a); GD.cmd_translate(F16(-64), F16(-64)); }
However, still one corner gets clipped.
|
|
|
Post by tftlcdcyg on Aug 20, 2021 5:11:21 GMT -8
The size that you must increase is the background of the base image, with the help of some image editing program and that allows you to preserve transparencies in case it is a png image; keeping it centered all the time, this way no part of the image will be cut off when rotated
|
|
samavr
Junior Member
Posts: 16
|
Post by samavr on Aug 20, 2021 8:33:07 GMT -8
I use FT800, I think it does not support transparency, however now I use JPG with the black background
|
|
|
Post by tftlcdcyg on Aug 21, 2021 2:25:46 GMT -8
With GRAM size limits of the screen, you could use the gd2asset tool to be able to process png images.
|
|
|
Post by jamesbowman on Aug 21, 2021 6:11:01 GMT -8
Hi samavr , I assume the bitmap size is 128x128, to avoid corner clipping, you need to make the size a couple of pixels bigger than 128*sqrt(2): GD.BitmapSize(NEAREST, BORDER, BORDER, 184, 184);
then use this function to rotate static void rotate(uint16_t a) { GD.cmd_translate(F16(184/2), F16(184/2)); GD.cmd_rotate(a); GD.cmd_translate(F16(-64), F16(-64)); } Taking the transforms in reverse order: - the first one moves the original 128x128 bitmap so its center is at (0,0)
- rotate the bitmap
- move the bitmap so its center is at (92,92)
You will see some shimmer in the bitmap due to NEAREST sampling. If you change the BitmapSize to:
GD.BitmapSize(BILINEAR, BORDER, BORDER, 184, 184);
it will look smooth as it rotates.
|
|