diff --git a/radio/src/gui/horus/bitmapbuffer.cpp b/radio/src/gui/horus/bitmapbuffer.cpp index c70c681d3..bb325bfed 100644 --- a/radio/src/gui/horus/bitmapbuffer.cpp +++ b/radio/src/gui/horus/bitmapbuffer.cpp @@ -552,7 +552,6 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename) return bmp; } - #define STB_IMAGE_IMPLEMENTATION #define STBI_ONLY_PNG #define STBI_ONLY_JPEG @@ -591,7 +590,6 @@ void *stb_realloc(void *ptr, unsigned int oldsz, unsigned int newsz) #include "thirdparty/Stb/stb_image.h" - // fill 'data' with 'size' bytes. return number of bytes actually read int stbc_read(void *user, char *data, int size) { @@ -632,18 +630,15 @@ const stbi_io_callbacks stbCallbacks = { BitmapBuffer * BitmapBuffer::load_stb(const char * filename) { - TRACE("load_stb()"); FIL imgFile; FRESULT result = f_open(&imgFile, filename, FA_OPEN_EXISTING | FA_READ); if (result != FR_OK) { return NULL; } - TRACE("load_stb() open"); int w, h, n; unsigned char *data = stbi_load_from_callbacks(&stbCallbacks, &imgFile, &w, &h, &n, 3); - TRACE("load_stb() load"); f_close(&imgFile); if (!data) { @@ -654,10 +649,9 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename) // todo use dma2d for conversion from 888 to 565 unsigned char *p = data; BitmapBuffer * bmp = new BitmapBuffer(w, h); - TRACE("load_stb() new"); uint16_t * dest = bmp->data; if (bmp == NULL) { - TRACE("load_stb() new err"); + TRACE("load_stb() malloc failed"); stbi_image_free(data); return NULL; } @@ -674,14 +668,6 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename) } p += 3 * w; } - TRACE("load_stb() free"); stbi_image_free(data); - TRACE("load_stb() end"); return bmp; } -float getBitmapScale(const BitmapBuffer * bitmap, int width, int height) -{ - float widthScale = float(width) / bitmap->getWidth(); - float heightScale = float(height) / bitmap->getHeight(); - return min(widthScale, heightScale); -} diff --git a/radio/src/gui/horus/bitmapbuffer.h b/radio/src/gui/horus/bitmapbuffer.h index 623741706..cc2832a3e 100644 --- a/radio/src/gui/horus/bitmapbuffer.h +++ b/radio/src/gui/horus/bitmapbuffer.h @@ -31,14 +31,6 @@ typedef int coord_t; typedef uint32_t LcdFlags; typedef uint16_t display_t; -inline int getBitmapScaledSize(int size, float scale) -{ - if (scale == 0.0) - return size; - else - return (0.5 + size) * scale; -} - template class BitmapBufferBase { @@ -214,7 +206,7 @@ class BitmapBuffer: public BitmapBufferBase coord_t bitmapWidth = bitmap->getWidth(); float scale = float(h) / bitmap->getHeight(); - int width = getBitmapScaledSize(bitmapWidth, scale); + int width = (0.5 + bitmapWidth) * scale; if (width > w) { int ww = (0.5 + w) / scale; drawBitmap(x, y, bitmap, (bitmapWidth - ww)/2, 0, ww, 0, scale); @@ -245,8 +237,6 @@ class BitmapBuffer: public BitmapBufferBase } }; -float getBitmapScale(const BitmapBuffer * bitmap, int width, int height); - extern BitmapBuffer * lcd; #endif // _BITMAP_BUFFER_H_