74 #include <nuttx/config.h> 76 #include <sys/types.h> 82 #include <nuttx/nx/nxglib.h> 83 #include <nuttx/video/rgbcolors.h> 113 #ifdef CONFIG_NX_WRITEONLY 146 struct nxgl_point_s pos;
160 struct nxgl_point_s pos;
174 nxgl_mxpixel_t color)
176 struct nxgl_point_s pos;
192 nxgl_coord_t width, nxgl_mxpixel_t color)
194 FAR
struct nxgl_rect_s dest;
200 dest.pt2.x = x + width - 1;
207 gerr(
"ERROR: INxWindow::fill failed\n");
222 nxgl_coord_t height, nxgl_mxpixel_t color)
224 FAR
struct nxgl_rect_s dest;
231 dest.pt2.y = y + height - 1;
237 gerr(
"ERROR: INxWindow::fill failed\n");
254 nxgl_coord_t x2, nxgl_coord_t y2,
257 struct nxgl_vector_s vector;
266 gerr(
"ERROR: INxWindow::drawLine failed\n");
281 nxgl_coord_t width, nxgl_coord_t height,
282 nxgl_mxpixel_t color)
284 struct nxgl_rect_s rect;
287 rect.pt2.x = x + width - 1;
288 rect.pt2.y = y + height - 1;
303 nxgl_coord_t width, nxgl_coord_t height,
304 nxgl_mxpixel_t color)
324 nxgl_coord_t width, nxgl_coord_t height,
325 nxgl_mxpixel_t shineColor,
326 nxgl_mxpixel_t shadowColor)
331 drawVertLine(x + width - 1, y + 1, height - 2, shadowColor);
349 nxgl_coord_t width, nxgl_coord_t height,
351 int bitmapX,
int bitmapY)
357 struct nxgl_point_s origin;
358 origin.x = x - bitmapX;
359 origin.y = y - bitmapY;
364 struct nxgl_rect_s dest;
367 dest.pt2.x = x + width - 1;
368 dest.pt2.y = y + height - 1;
392 nxgl_coord_t width, nxgl_coord_t height,
394 int bitmapX,
int bitmapY,
395 nxgl_mxpixel_t transparentColor)
399 FAR uint8_t *srcLine = (uint8_t *)bitmap->
data +
400 bitmapY * bitmap->
stride +
401 ((bitmapX * bitmap->
bpp + 7) >> 3);
406 nxgl_coord_t firstX = x;
407 nxgl_coord_t lastX = x + width;
408 nxgl_coord_t lastY = y + height;
414 while (*srcPtr == transparentColor)
437 srcLine += bitmap->
stride;
452 nxgl_coord_t runX = x;
453 nxgl_coord_t runWidth = 0;
477 srcLine += bitmap->
stride;
485 while (*srcPtr != transparentColor);
495 struct nxgl_point_s origin;
502 struct nxgl_rect_s dest;
505 dest.pt2.x = runX + runWidth - 1;
529 nxgl_coord_t width, nxgl_coord_t height,
531 int bitmapX,
int bitmapY)
538 ginfo(
"ERROR: Failed to allocated run buffer\n");
544 FAR uint8_t *src = (FAR uint8_t *)bitmap->
data + bitmapY * bitmap->
stride + bitmapX;
548 struct nxgl_point_s origin;
552 struct nxgl_rect_s dest;
555 dest.pt2.x = x + width - 1;
560 for (
int row = 0; row < height; row++)
567 for (
int col = 0; col < width; col++)
580 *runDest++ = MKRGB(avg, avg, avg);
612 _drawText(pos, bound, font,
string, 0,
string.getLength(), 0,
true);
630 int startIndex,
int length,
631 nxgl_mxpixel_t color)
635 nxgl_mxpixel_t savedColor = font->
getColor();
640 _drawText(pos, bound, font,
string, startIndex, length, 0,
true);
660 int startIndex,
int length)
662 _drawText(pos, bound, font,
string, startIndex, length, 0,
true);
681 int startIndex,
int length,
682 nxgl_mxpixel_t color,
683 nxgl_mxpixel_t background)
685 nxgl_mxpixel_t savedColor = font->
getColor();
688 _drawText(pos, bound, font,
string, startIndex, length, background,
false);
708 int startIndex,
int length,
709 nxgl_mxpixel_t background,
714 int stringLength =
string.getLength();
715 if (startIndex >= stringLength)
720 int endIndex = startIndex + length;
721 if (endIndex > stringLength)
723 endIndex = stringLength;
726 #ifdef CONFIG_NX_WRITEONLY 739 unsigned int bmHeight = (
unsigned int)font->
getHeight();
741 unsigned int glyphSize = bmWidth * bmHeight;
742 FAR uint8_t *glyph =
new uint8_t[glyphSize];
746 struct nxgl_rect_s boundingBox;
754 bitmap.
data = (FAR
const nxgl_mxpixel_t*)glyph;
758 for (
int i = startIndex; i < endIndex; i++)
766 struct nx_fontmetric_s metrics;
771 nxgl_coord_t fontWidth = (nxgl_coord_t)(metrics.width + metrics.xoffset);
775 if (metrics.height > 0 || !transparent)
779 bitmap.
width = fontWidth;
781 bitmap.
stride = (fontWidth * bitmap.
bpp + 7) >> 3;
785 struct nxgl_rect_s dest;
788 dest.pt2.x = pos->x + fontWidth - 1;
789 dest.pt2.y = pos->y + bmHeight - 1;
793 struct nxgl_rect_s intersection;
794 nxgl_rectintersect(&intersection, &dest, &boundingBox);
799 if (!nxgl_nullrect(&intersection))
810 unsigned int npixels = fontWidth * bmHeight;
811 for (
unsigned int j = 0; j < npixels; j++)
813 *bmPtr++ = background;
832 ginfo(
"nx_bitmapwindow failed: %d\n", errno);
858 nxgl_coord_t destX, nxgl_coord_t destY,
859 nxgl_coord_t width, nxgl_coord_t height)
861 struct nxgl_rect_s rect;
862 struct nxgl_point_s offset;
864 rect.pt1.x = sourceX;
865 rect.pt1.y = sourceY;
866 rect.pt1.x = sourceX + width - 1;
867 rect.pt1.y = sourceY + height - 1;
869 offset.x = destX - sourceX;
870 offset.y = destY - sourceY;
887 nxgl_coord_t deltaX, nxgl_coord_t deltaY,
888 nxgl_coord_t width, nxgl_coord_t height)
890 struct nxgl_rect_s rect;
893 rect.pt2.x = x + width - 1;
894 rect.pt2.y = y + height - 1;
896 struct nxgl_point_s offset;
913 nxgl_coord_t width, nxgl_coord_t height)
918 FAR uint8_t *rowBuffer =
new uint8_t[height * stride];
929 rowBitmap.
width = width;
931 rowBitmap.
stride = stride;
932 rowBitmap.
data = (FAR
const nxgl_mxpixel_t *)rowBuffer;
936 struct nxgl_rect_s rect;
938 rect.pt2.x = x + width - 1;
942 struct nxgl_point_s origin;
947 for (
int row = 0; row < height; row++)
951 rect.pt1.y = rect.pt2.y = y + row;
957 for (
int col = 0; col < width; col++)
962 uint8_t red = RGB2RED(color);
963 uint8_t green = RGB2GREEN(color);
964 uint8_t blue = RGB2BLUE(color);
970 *ptr++ = MKRGB(avg, avg, avg);
975 origin.y = rect.pt1.y;
977 &origin, rowBitmap.
stride) ;
996 nxgl_coord_t width, nxgl_coord_t height)
1001 FAR uint8_t *rowBuffer =
new uint8_t[height * stride];
1012 rowBitmap.
width = width;
1014 rowBitmap.
stride = stride;
1015 rowBitmap.
data = (FAR
const nxgl_mxpixel_t *)rowBuffer;
1019 struct nxgl_rect_s rect;
1021 rect.pt2.x = x + width - 1;
1025 struct nxgl_point_s origin;
1030 for (
int row = 0; row < height; row++)
1034 rect.pt1.y = rect.pt2.y = y + row;
1040 for (
int col = 0; col < width; col++)
1043 uint8_t red = RGB2RED(color);
1044 uint8_t green = RGB2GREEN(color);
1045 uint8_t blue = RGB2BLUE(color);
1046 *ptr++ = MKRGB(~red, ~green, ~blue);
1051 origin.y = rect.pt1.y;
1053 &origin, rowBitmap.
stride) ;
virtual bool bitmap(FAR const struct nxgl_rect_s *pDest, FAR const void *pSrc, FAR const struct nxgl_point_s *pOrigin, unsigned int stride)=0
void copy(nxgl_coord_t sourceX, nxgl_coord_t sourceY, nxgl_coord_t destX, nxgl_coord_t destY, nxgl_coord_t width, nxgl_coord_t height)
void drawVertLine(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t height, nxgl_mxpixel_t color)
const nxgl_coord_t getY(void) const
void getNxRect(FAR struct nxgl_rect_s *rect) const
nxgl_mxpixel_t m_backColor
virtual bool move(FAR const struct nxgl_rect_s *pRect, FAR const struct nxgl_point_s *pOffset)=0
CGraphicsPort(INxWindow *pNxWnd, nxgl_mxpixel_t backColor=CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR)
void drawBevelledRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, nxgl_mxpixel_t shineColor, nxgl_mxpixel_t shadowColor)
void drawBitmap(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, const struct SBitmap *bitmap, int bitmapX, int bitmapY)
virtual void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest)=0
void drawHorizLine(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_mxpixel_t color)
void drawBitmapGreyScale(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, const struct SBitmap *bitmap, int bitmapX, int bitmapY)
const nxgl_mxpixel_t getColor() const
virtual bool setPixel(FAR const struct nxgl_point_s *pPos, nxgl_mxpixel_t color)=0
const uint8_t getMaxWidth(void) const
void setColor(const nxgl_mxpixel_t color)
void greyScale(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height)
virtual bool drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, enum ELineCaps caps)=0
void drawFilledRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, nxgl_mxpixel_t color)
void drawChar(FAR SBitmap *bitmap, nxwidget_char_t letter)
void drawLine(nxgl_coord_t x1, nxgl_coord_t y1, nxgl_coord_t x2, nxgl_coord_t y2, nxgl_mxpixel_t color, enum INxWindow::ELineCaps caps)
virtual bool getPosition(FAR struct nxgl_point_s *pPos)=0
void invert(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height)
const uint8_t getHeight(void) const
const nxgl_coord_t getX(void) const
void drawPixel(nxgl_coord_t x, nxgl_coord_t y, nxgl_mxpixel_t color)
virtual bool fill(FAR const struct nxgl_rect_s *pRect, nxgl_mxpixel_t color)=0
void move(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t deltaX, nxgl_coord_t deltaY, nxgl_coord_t width, nxgl_coord_t height)
static const NXWidgets::SRlePaletteBitmapEntry bitmap[]
void _drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font, const CNxString &string, int startIndex, int length, nxgl_mxpixel_t background, bool transparent)
void getCharMetrics(nxwidget_char_t letter, FAR struct nx_fontmetric_s *metrics) const
void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font, const CNxString &string)
void drawRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, nxgl_mxpixel_t color)