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_Driver.cxx | 101 ++++++++++++++++++++- 1 file changed, 97 insertions(+), 4 deletions(-) (limited to 'src/drivers/Android/Fl_Android_Graphics_Driver.cxx') diff --git a/src/drivers/Android/Fl_Android_Graphics_Driver.cxx b/src/drivers/Android/Fl_Android_Graphics_Driver.cxx index 7b74c0c01..a53cb7795 100644 --- a/src/drivers/Android/Fl_Android_Graphics_Driver.cxx +++ b/src/drivers/Android/Fl_Android_Graphics_Driver.cxx @@ -1031,10 +1031,10 @@ fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Pixmap *img) const uchar *src = rgba + yy*rowBytes; uint32_t *dst = cache->pWords + yy*cache->pStride; for (int xx=0; xx> 3) & 0x001f) ) << 16) | src[3]; // FIXME: alpha - *dst++ = c; +// uint32_t c = ((((src[0] << 8) & 0xf800) | +// ((src[1] << 3) & 0x07e0) | +// ((src[2] >> 3) & 0x001f) ) << 16) | src[3]; // FIXME: alpha + *dst++ = Fl_Android_565A_Map::toRGBA(src[0],src[1], src[2], src[3]); src+=4; } } @@ -1044,6 +1044,86 @@ fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Pixmap *img) } +void Fl_Android_Graphics_Driver::uncache_pixmap(fl_uintptr_t p) +{ + Fl_Android_565A_Map *img = (Fl_Android_565A_Map*)p; + delete img; +} + + +void Fl_Android_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) +{ + int X, Y, W, H; + // Don't draw an empty image... + if (!img->d() || !img->array) { + Fl_Graphics_Driver::draw_empty(img, XP, YP); + return; + } + if (start_image(img, XP, YP, WP, HP, cx, cy, X, Y, W, H)) { + return; + } + Fl_Android_565A_Map *cgimg = (Fl_Android_565A_Map*)*Fl_Graphics_Driver::id(img); + if (!cgimg) { + int w = img->w(), h = img->h(), d = img->d(), stride = w*d + img->ld(); + cgimg = new Fl_Android_565A_Map(w, h); + *Fl_Graphics_Driver::id(img) = (fl_uintptr_t)cgimg; + if (d==1) { // grayscale + for (int iy=0; iyarray + iy*stride; + uint32_t *dst = cgimg->pWords + iy*cgimg->pStride; + for (int ix=0; ixarray + iy*stride; + uint32_t *dst = cgimg->pWords + iy*cgimg->pStride; + for (int ix=0; ixarray + iy*stride; + uint32_t *dst = cgimg->pWords + iy*cgimg->pStride; + for (int ix=0; ixarray + iy*stride; + uint32_t *dst = cgimg->pWords + iy*cgimg->pStride; + for (int ix=0; ixclipped_rect()); + } + } +} + + +void Fl_Android_Graphics_Driver::uncache(Fl_RGB_Image*, fl_uintptr_t &id_, fl_uintptr_t&) +{ + Fl_Android_565A_Map *cgimg = (Fl_Android_565A_Map*)id_; + delete cgimg; +} + + void Fl_Android_Graphics_Driver::set_color(Fl_Color i, unsigned int c) { if (i>255) return; @@ -1056,6 +1136,19 @@ void Fl_Android_Graphics_Driver::color(uchar r, uchar g, uchar b) color( (((Fl_Color)r)<<24)|(((Fl_Color)g)<<16)|(((Fl_Color)b)<<8) ); } +/** + * Draw a rectangle that may be dithered if we are in colormap mode (which in + * the year 2018 is as likely has a user with a berstein colored tube TV). + * FIXME: This function should be virtual as well, or should not exist at all. + */ +void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) { +#if USE_COLORMAP + // ... +#endif + fl_color(r,g,b); + fl_rectf(x,y,w,h); +} + // // End of "$Id$". -- cgit v1.2.3