From 936fbd096f3cf1df506bf98a7dd9bece5391b624 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 31 Mar 2018 21:29:33 +0000 Subject: Android: Drawing RGB image data (and probaly rgba and grayscale as well). Testing unsing test/color_chooser.cxx git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12817 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/Android/Fl_Android_Graphics_Font.H | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/drivers/Android/Fl_Android_Graphics_Font.H') diff --git a/src/drivers/Android/Fl_Android_Graphics_Font.H b/src/drivers/Android/Fl_Android_Graphics_Font.H index 4bab47786..358af6fa0 100644 --- a/src/drivers/Android/Fl_Android_Graphics_Font.H +++ b/src/drivers/Android/Fl_Android_Graphics_Font.H @@ -23,7 +23,10 @@ #include "Fl_Android_Graphics_Driver.H" // We violate FLTKs avoidance of STL because we live in a defined driver space +#define FL_ALLOW_STL 1 +#ifdef FL_ALLOW_STL #include +#endif #include "stb_truetype.h" @@ -31,6 +34,8 @@ /** * A bytemap is an array of bytes, used as an alpha channel when redering glyphs * in a given color. + * TODO: reate a class for RGB only and for grayscale and grayscale with alpha + * TODO: derive all this from a baseclass, so we can create the correct class for the required image */ class Fl_Android_Bytemap { @@ -58,6 +63,12 @@ public: Fl_Android_565A_Map(); Fl_Android_565A_Map(int w, int h); ~Fl_Android_565A_Map(); + static inline uint32_t toRGBA(uchar r, uchar g, uchar b, uchar a) + { + return ((((r << 8) & 0xf800) | + ((g << 3) & 0x07e0) | + ((b >> 3) & 0x001f)) << 16) | a; + } public: int pWidth = 0, pHeight = 0, pStride = 0; @@ -98,7 +109,11 @@ public: */ class Fl_Android_Font_Descriptor : public Fl_Font_Descriptor { +#ifdef FL_ALLOW_STL typedef std::map BytemapTable; +#else + typedef Fl_Android_Bytemap* BytemapTable[256]; +#endif private: Fl_Android_Font_Source *pFontSource; Fl_Font pFontIndex; -- cgit v1.2.3