40 #include <nuttx/config.h> 46 #include <nuttx/nx/nxglib.h> 68 : m_bitmap(bitmap), m_size(newSize)
198 nxgl_coord_t width, FAR
void *data)
200 #if CONFIG_NXWIDGETS_FMT == FB_FMT_RGB8_332 || CONFIG_NXWIDGETS_FMT == FB_FMT_RGB24 201 FAR uint8_t *dest = (FAR uint8_t *)data;
202 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB16_565 203 FAR uint16_t *dest = (FAR uint16_t *)data;
204 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB32 205 FAR uint32_t *dest = (FAR uint32_t *)data;
207 # error Unsupported, invalid, or undefined color format 212 if (((
unsigned int)x >= (
unsigned int)
m_size.w) &&
213 ((
unsigned int)(x + width) > (
unsigned int)
m_size.w) &&
214 ((
unsigned int)y <= (
unsigned int)
m_size.h))
224 nxgl_coord_t row = b16toi(row16);
239 for (
int i = 0; i < width; i++, x++)
249 struct rgbcolor_s color1;
252 gerr(
"ERROR: rowColor failed for the first row\n");
258 struct rgbcolor_s color2;
261 gerr(
"ERROR: rowColor failed for the second row\n");
270 #if CONFIG_NXWIDGETS_FMT == FB_FMT_RGB8_332 271 uint8_t color = RGBTO8(color1.r, color1.g, color1.b);
272 transparent1 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
274 color = RGBTO8(color2.r, color2.g, color2.b);
275 transparent2 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
277 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB16_565 278 uint16_t color = RGBTO16(color1.r, color1.g, color1.b);
279 transparent1 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
281 color = RGBTO16(color2.r, color2.g, color2.b);
282 transparent2 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
284 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB24 || CONFIG_NXWIDGETS_FMT == FB_FMT_RGB32 285 uint32_t color = RGBTO24(color1.r, color1.g, color1.b);
286 transparent1 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
288 color = RGBTO24(color2.r, color2.g, color2.b);
289 transparent2 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
292 # error Unsupported, invalid, or undefined color format 297 struct rgbcolor_s scaledColor;
298 b16_t fraction b16frac(row16);
300 if (transparent1 || transparent2)
307 if (fraction < b16HALF)
309 scaledColor.r = color1.r;
310 scaledColor.g = color1.g;
311 scaledColor.b = color1.b;
315 scaledColor.r = color2.r;
316 scaledColor.g = color2.g;
317 scaledColor.b = color2.b;
324 if (!
scaleColor(color1, color2, fraction, scaledColor))
332 #if CONFIG_NXWIDGETS_FMT == FB_FMT_RGB8_332 333 color = RGBTO8(scaledColor.r, scaledColor.g, scaledColor.b);
336 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB16_565 337 color = RGBTO16(scaledColor.r, scaledColor.g, scaledColor.b);
340 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB24 345 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB32 346 color = RGBTO24(scaledColor.r, scaledColor.g, scaledColor.b);
350 # error Unsupported, invalid, or undefined color format 371 if (row ==
m_row + 1)
385 if (++row >= (
unsigned int)bitmapHeight)
387 row = bitmapHeight - 1;
392 gerr(
"ERROR: Failed to read bitmap row %d\n", row);
400 else if (row !=
m_row)
404 if (row >= (
unsigned int)bitmapHeight)
406 row = bitmapHeight - 1;
411 gerr(
"ERROR: Failed to read bitmap row %d\n", row);
421 if (++row >= (
unsigned int)bitmapHeight)
423 row = bitmapHeight - 1;
428 gerr(
"ERROR: Failed to read bitmap row %d\n", row);
447 FAR
const struct rgbcolor_s &incolor2,
448 b16_t fraction, FAR
struct rgbcolor_s &outcolor)
458 b16_t remainder = b16ONE - fraction;
462 red = (b16_t)incolor1.r * remainder + (b16_t)incolor2.r * fraction;
463 green = (b16_t)incolor1.g * remainder + (b16_t)incolor2.g * fraction;
464 blue = (b16_t)incolor1.b * remainder + (b16_t)incolor2.b * fraction;
469 component = b16toi(red);
470 outcolor.r = component < 256 ? component : 255;
472 component = b16toi(green);
473 outcolor.g = component < 256 ? component : 255;
475 component = b16toi(blue);
476 outcolor.b = component < 256 ? component : 255;
491 FAR
struct rgbcolor_s &outcolor)
495 nxgl_coord_t col1 = b16toi(column);
496 nxgl_coord_t col2 = col1 + 1;
499 if (col2 >= bitmapWidth)
501 col2 = bitmapWidth - 1;
504 b16_t fraction = b16frac(column);
506 struct rgbcolor_s color1;
507 struct rgbcolor_s color2;
512 #if CONFIG_NXWIDGETS_FMT == FB_FMT_RGB8_332 513 uint8_t color = row[col1];
514 color1.r = RGB8RED(color);
515 color1.g = RGB8GREEN(color);
516 color1.b = RGB8BLUE(color);
518 transparent1 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
521 color2.r = RGB8RED(color);
522 color2.g = RGB8GREEN(color);
523 color2.b = RGB8BLUE(color);
525 transparent2 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
527 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB16_565 528 FAR uint16_t *row16 = (FAR uint16_t*)row;
529 uint16_t color = row16[col1];
530 color1.r = RGB16RED(color);
531 color1.g = RGB16GREEN(color);
532 color1.b = RGB16BLUE(color);
534 transparent1 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
537 color2.r = RGB16RED(color);
538 color2.g = RGB16GREEN(color);
539 color2.b = RGB16BLUE(color);
541 transparent2 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
543 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB24 544 unsigned int ndx = 3*col1;
545 color1.r = row[ndx+2];
546 color1.g = row[ndx+1];
549 uint32_t color = RGBTO24(color1.r, color1.g, color1.b);
550 transparent1 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
553 color2.r = row[ndx+2];
554 color2.g = row[ndx+1];
557 color = RGBTO24(color2.r, color2.g, color2.b);
558 transparent2 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
560 #elif CONFIG_NXWIDGETS_FMT == FB_FMT_RGB32 561 FAR uint32_t *row32 = (FAR uint32_t*)row;
562 uint32_t color = row32[col1];
563 color1.r = RGB24RED(color);
564 color1.g = RGB24GREEN(color);
565 color1.b = RGB24BLUE(color);
567 transparent1 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
570 color2.r = RGB24RED(color);
571 color2.g = RGB24GREEN(color);
572 color2.b = RGB24BLUE(color);
574 transparent2 = (color == CONFIG_NXWIDGETS_TRANSPARENT_COLOR);
577 # error Unsupported, invalid, or undefined color format 582 if (transparent1 || transparent2)
592 if (fraction < b16HALF)
594 outcolor.r = color1.r;
595 outcolor.g = color1.b;
596 outcolor.g = color1.g;
600 outcolor.r = color2.r;
601 outcolor.g = color2.b;
602 outcolor.g = color2.g;
611 return scaleColor(color1, color2, fraction, outcolor);
virtual bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, FAR void *data)=0
virtual const nxgl_coord_t getHeight(void) const =0
bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, FAR void *data)
const uint8_t getBitsPerPixel(void) const
bool cacheRows(unsigned int row)
const uint8_t getColorFormat(void) const
virtual const size_t getStride(void) const =0
FAR uint8_t * m_rowCache[2]
bool rowColor(FAR uint8_t *row, b16_t column, FAR struct rgbcolor_s &outcolor)
virtual const nxgl_coord_t getWidth(void) const =0
CScaledBitmap(const CScaledBitmap &bitmap)
const nxgl_coord_t getWidth(void) const
const size_t getStride(void) const
static const NXWidgets::SRlePaletteBitmapEntry bitmap[]
virtual const uint8_t getBitsPerPixel(void) const =0
virtual const uint8_t getColorFormat(void) const =0
const nxgl_coord_t getHeight(void) const
bool scaleColor(FAR const struct rgbcolor_s &incolor1, FAR const struct rgbcolor_s &incolor2, b16_t fraction, FAR struct rgbcolor_s &outcolor)
struct nxgl_size_s m_size