This post was last edited by lemon1394 on 2022-9-25 21:30
To display pictures and text on a TFT color screen, several problems need to be overcome:
1. Get the RGB data of the image for use by TFT .
TFT color screens generally need dot matrix data of images, but only BMP format files have dot matrix information, which needs to be extracted by yourself. Common images are JPG, so use PS to convert them.
BMP images are commonly used in RGB888 format, that is, each pixel is represented by three bytes. If you want to extract it, you need to understand the BMP file format. You can read the file in binary mode, offset to the position of RGB data, and then read the RGB data.
2. The RGB data format does not match the data required by the TFT screen
What TFT needs is RGB565 dot matrix information, and BMP is generally in RGB888 mode. At this time, RGB888 needs to be converted to RGB565.
The conversion method is to take the high 5 bits of R, the high 6 bits of G, and the high 5 bits of B, and combine them into a new 2 bytes, a total of 16 bits to represent a pixel.
In fact, you can use PS to convert it, and then read the RGB565 data in binary mode.
At this time, you will find that the displayed picture is upside down and left and right. Adjust it again. Of course, you can also adjust the TFT driver. After adjusting the driver, the displayed text will be upside down again. . .
You can also convert it yourself. It's okay for small screens, a 240X320 screen. I converted it and it took 6 seconds for a PC, let alone a single-chip computer.
3. You can use the firmware shared by some netizens.
These firmwares can display text and pictures, but you can only use their firmware. If they don't update, you can't use the new firmware.
Moreover, I can't do anything with other people's ready-made products, and I have no idea how they achieve it. If I want to achieve an effect of my own, I don't know what to change, and I can't change it because it's in the firmware.
4. Display HZK16, ASC16, HZK32
Using framebuf is more efficient, but it can only use the default small font. I want to use 16X16 HZK16, but the format is wrong.
You can write a program to expand an RGB565 framebuf according to the dot matrix information. Just writing the program will take a long time to think and adjust, but the key conversion efficiency must be gratifying.
5. Summary:
If you want to display pictures and text on the TFT screen without using other firmware, you will have to step into many pitfalls, and many of them are basically impossible to climb out of.
Using other people's firmware, it can only display text on some screens, and even fewer can display pictures. The main problem is that it is not flexible.
Regarding other methods of displaying pictures and texts on TFT screens, I have not seen a perfect solution yet, and I don’t know how everyone solves this problem.