lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.03k stars 189 forks source link

Image Header File generation tool for device WT32-SC01 #490

Closed gbernaldo82 closed 4 months ago

gbernaldo82 commented 5 months ago

Hi, good morning!

I've a WT32-SC01 device which I'm testing. The device works correctly with the library. I've been playing with the example FlashMemSprite without any problem. The problem comes when I try to load a header file generated by ImageMagick tool.

The command I execute is: magick convert .\IconoCintaGrabacion.png -depth 16 .\IconoCintaGrabacion.h

After that, I put the hader file into the project folder and after build the code and load it into the device, it hangs completely.

The source code is: ` / Simple Demo with WT32-SC01 + LovyanGFX + LVGL8.x /

define LGFX_WT32_SC01 // Seeed WT32-SC01

define LGFX_AUTODETECT // Autodetect board

define LGFX_USE_V1

include

include "IconoCintaGrabacion.h"

//#include "image480x320x8.h" //#include "image640x480x4.h" //#include "image1280x960x1.h"

define c1 0xFFFFFF //white

static LGFX lcd; static LGFX_Sprite sprite;

void setup() { lcd.init(); if (lcd.width() < lcd.height()) { lcd.setRotation(lcd.getRotation() ^ 1); }

// Set the backlight brightness in the range 0-255 lcd.setBrightness(128);

// Set the color mode as needed. (Initial value is 16) // 16 - Faster, but the red and blue tones are 5 bits. // 24 - Slower, but the gradation expression is cleaner. //lcd.setColorDepth(16); // Set to 16 bits of RGB565 lcd.setColorDepth(24); // Set to 24 bits for RGB888 - Note that the actual // number of colors displayed may be 18 bits (RGB666) // depending on the display hardware.

// setBufferを使用することで、予め用意されたデータを用いてスプライトを使用できるようにする。 sprite.setBuffer(const_cast<std::uint8_t>(MagickImage), 64, 64, 16); // sprite.setBuffer(const_cast<std::uint8_t>(image480x320x8), 480, 320, 8); // sprite.setBuffer(const_cast<std::uint8_t>(image640x480x4), 640, 480, 4); // sprite.setBuffer(const_cast<std::uint8_t>(image1280x960x1), 1280, 960, 1); // sprite.createPalette();

// ※ 本来const(書換不可能)なデータをconst_castにより非constと偽って使用しています。 // このため、このスプライトに対して描画を行うとプログラムはクラッシュします。 // LCDや他のスプライトに描画する関数など、読出しを行う関数のみが使用できます。 // OK) sprite.pushSprite // OK) sprite.pushRotated // OK) sprite.pushRotateZoom // OK) sprite.readRect // NG) sprite.drawPixel // NG) sprite.fillRect // NG) sprite.scroll

//sprite.pushSprite(0,0); }

void loop() { //static std::uint32_t count; //if (++count == 360) count = 0; //float zoom = (((float)count) / 200) + 0.1; //sprite.pushRotateZoom(&lcd, lcd.width() >> 1, lcd.height() >> 1, count, zoom, zoom);

// You can fill the entire screen with clear or fillScreen. // fillScreen is the same as specifying the entire screen of fillRect, and // the color specification is treated as the drawing color. lcd.fillScreen(0xFFFFFFu); // Fill with white

sprite.pushRotateZoom(0, 0, 0, 3, 3, 0); } `

I forget to say the size of the image is 64x64 pixels with 16 bpp.

Please, can anyone tell me how can I generate an image file? What tool can I use to make it? or at least, tell me where is the error?

Thank you so much in advance!

lovyan03 commented 4 months ago

setBufferでROM領域を割り当てたSpriteに対しては、描画命令は一切使用できません。