summaryrefslogtreecommitdiff
path: root/src/drivers/Android/Fl_Android_Graphics_Font.H
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2018-03-31 21:29:33 +0000
committerMatthias Melcher <fltk@matthiasm.com>2018-03-31 21:29:33 +0000
commit936fbd096f3cf1df506bf98a7dd9bece5391b624 (patch)
treefe873e6e4c3fd1a5304971be6ec8847dd2a48199 /src/drivers/Android/Fl_Android_Graphics_Font.H
parente4916d617e989faefa8f8c1004e20174a0efcbdb (diff)
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
Diffstat (limited to 'src/drivers/Android/Fl_Android_Graphics_Font.H')
-rw-r--r--src/drivers/Android/Fl_Android_Graphics_Font.H15
1 files changed, 15 insertions, 0 deletions
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 <map>
+#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<uint32_t, Fl_Android_Bytemap*> BytemapTable;
+#else
+ typedef Fl_Android_Bytemap* BytemapTable[256];
+#endif
private:
Fl_Android_Font_Source *pFontSource;
Fl_Font pFontIndex;