Hi Thomas,

Where I could find some information about the palette?
A way is to open fb driver code in your kernel:
in s1d13xxxfb_set_par() function there's a switch that initialize the hw of your video card. In case of 8bpp, this card works in "pseudo color"; this mean that it use a hw palette.

Normally I

use as explained for framebuffer MWPF_TRUECOLOR0888.
OK, because nano-x when works with framebuffer ask to kernel the hw config of your video card. In this case, your videocard works in FB_VISUAL_PSEUDOCOLOR and then set-up the 256 system color palette.


The problem is that Fltk+nxlib+nanox system works only in TrueColor because in
nxlib it's not implemented the possibility to convert the
palette index <=> color value
for images.

For solve this problem I make a "brutal" hack....
1 - I compile FTLK with enable USE_COLORMAP in config.h
2 - I apply a patch that force FLTK to pass its internal index palette to nano-x. 3 - I replace nano-x system palette with FLTK palette applying an other patch.

The result is that nano-x now works only with FLTK but Image colors are good.

This isn't a right solution of the problem... but it works :-)

Is there anyone that can give me a feedback to suggest a better way?
or help me to develop the part needed for give the solution for this problem?
I think that this feauture can be interesting for the project.

In attachment there are all patches to apply.

Regards,
Matteo Facchinetti



diff -Naur fltk-1.1.x-r5653_orig/configh.in fltk-1.1.x-r5653/configh.in
--- fltk-1.1.x-r5653_orig/configh.in	2005-12-14 01:39:55.000000000 +0100
+++ fltk-1.1.x-r5653/configh.in	2007-04-02 17:55:04.000000000 +0200
@@ -73,7 +73,7 @@
  * Setting this to zero will save a good deal of code (especially for
  * fl_draw_image), but FLTK will only work on TrueColor visuals.
  */
-
+#define SIRIUS_TARGET 1
 #define USE_COLORMAP 1
 
 /*
diff -Naur fltk-1.1.x-r5653_orig/src/fl_draw_image.cxx fltk-1.1.x-r5653/src/fl_draw_image.cxx
--- fltk-1.1.x-r5653_orig/src/fl_draw_image.cxx	2006-06-09 18:16:34.000000000 +0200
+++ fltk-1.1.x-r5653/src/fl_draw_image.cxx	2007-04-02 17:55:42.000000000 +0200
@@ -95,16 +95,26 @@
     td = 1;
   }
   for (; w--; from += d, to += td) {
+#ifdef SIRIUS_TARGET
+    r = from[0]; if (r < 0) r = 0; else if (r>255) r = 255;
+    g = from[1]; if (g < 0) g = 0; else if (g>255) g = 255;
+    b = from[2]; if (b < 0) b = 0; else if (b>255) b = 255;
+#else
     r += from[0]; if (r < 0) r = 0; else if (r>255) r = 255;
     g += from[1]; if (g < 0) g = 0; else if (g>255) g = 255;
     b += from[2]; if (b < 0) b = 0; else if (b>255) b = 255;
+#endif
     Fl_Color i = fl_color_cube(r*FL_NUM_RED/256,g*FL_NUM_GREEN/256,b*FL_NUM_BLUE/256);
+#ifndef SIRIUS_TARGET
     Fl_XColor& xmap = fl_xmap[0][i];
     if (!xmap.mapped) {if (!fl_redmask) fl_xpixel(r,g,b); else fl_xpixel(i);}
     r -= xmap.r;
     g -= xmap.g;
     b -= xmap.b;
     *to = uchar(xmap.pixel);
+#else
+    *to=uchar(i);
+#endif
   }
   ri = r; gi = g; bi = b;
 }
diff -Naur microwin_orig/src/config microwin_FINAL/src/config
--- microwin_orig/src/config	2007-04-20 17:32:34.000000000 +0200
+++ microwin_FINAL/src/config	2007-04-23 12:00:44.000000000 +0200
@@ -103,6 +103,15 @@
 
 ####################################################################
 #
+# If using Linux framebuffer, nxlib, and Fast Light Toolkit Libraries 
+# with a 8bpp PALETTE card, enable FLTK_8BPP_PALETTE. 
+# This is for compatibility with FLTK internal palette.
+#
+####################################################################
+FLTK_8BPP_PALETTE = Y
+
+####################################################################
+#
 # NanoX: Put Y to the following line to link the nano-X application
 # with the server.  This is required for ELKS, if no network is present,
 # or for speed or debugging.  This affects the nano-X server only.
diff -Naur microwin_orig/src/engine/devopen.c microwin_FINAL/src/engine/devopen.c
--- microwin_orig/src/engine/devopen.c	2005-11-10 23:06:28.000000000 +0100
+++ microwin_FINAL/src/engine/devopen.c	2007-04-23 12:02:05.000000000 +0200
@@ -323,6 +323,32 @@
 	return GdFindNearestColor(gr_palette, (int)gr_ncolors, c);
 }
 
+#if FLTK_8BPP_PALETTE
+
+#define FL_NUM_RED		5
+#define FL_NUM_GREEN	8
+#define FL_NUM_BLUE		5
+#define FL_COLOR_CUBE	56
+
+inline MWPIXELVAL fl_color_cube(int r, int g, int b) {
+  return (MWPIXELVAL)((b*FL_NUM_RED + r) * FL_NUM_GREEN + g + FL_COLOR_CUBE);}
+
+MWPIXELVAL
+GdFindNearestColor(MWPALENTRY *pal, int size, MWCOLORVAL cr)
+{
+	int		r, g, b;
+	MWPIXELVAL i;
+	
+	r = REDVALUE(cr);
+	g = GREENVALUE(cr);
+	b = BLUEVALUE(cr);
+	i = fl_color_cube(r*FL_NUM_RED/256,g*FL_NUM_GREEN/256,b*FL_NUM_BLUE/256);
+	
+	return i;
+}
+
+#else
+
 /**
  * Search a palette to find the nearest color requested.
  * Uses a weighted squares comparison.
@@ -367,6 +393,9 @@
 	return best;
 }
 
+#endif
+
+
 /**
  * Convert a color from a driver-dependent PIXELVAL to a COLORVAL.
  *
diff -Naur microwin_orig/src/engine/devpal8_fltk.c microwin_FINAL/src/engine/devpal8_fltk.c
--- microwin_orig/src/engine/devpal8_fltk.c	1970-01-01 01:00:00.000000000 +0100
+++ microwin_FINAL/src/engine/devpal8_fltk.c	2007-04-23 12:01:07.000000000 +0200
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2007 Matteo Facchinetti <[EMAIL PROTECTED]>
+ * 		Sirius Electronic Systems
+ *
+ * 8bpp (256 color) FLTK palette definition
+ */
+#include "device.h"
+
+const MWPALENTRY mwstdpal8[256] = {
+	RGBDEF(0x00,0x00,0x00),
+	RGBDEF(0xff,0x00,0x00),
+	RGBDEF(0x00,0xff,0x00),
+	RGBDEF(0xff,0xff,0x00),
+	RGBDEF(0x00,0x00,0xff),
+	RGBDEF(0xff,0x00,0xff),
+	RGBDEF(0x00,0xff,0xff),
+	RGBDEF(0xff,0xff,0xff),
+	RGBDEF(0x55,0x55,0x55),
+	RGBDEF(0xc6,0x71,0x71),
+	RGBDEF(0x71,0xc6,0x71),
+	RGBDEF(0x8e,0x8e,0x38),
+	RGBDEF(0x71,0x71,0xc6),
+	RGBDEF(0x8e,0x38,0x8e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+	RGBDEF(0x00,0x24,0x00),
+	RGBDEF(0x00,0x48,0x00),
+	RGBDEF(0x00,0x6d,0x00),
+	RGBDEF(0x00,0x91,0x00),
+	RGBDEF(0x00,0xb6,0x00),
+	RGBDEF(0x00,0xda,0x00),
+	RGBDEF(0x00,0xff,0x00),
+	RGBDEF(0x3f,0x00,0x00),
+	RGBDEF(0x3f,0x24,0x00),
+	RGBDEF(0x3f,0x48,0x00),
+	RGBDEF(0x3f,0x6d,0x00),
+	RGBDEF(0x3f,0x91,0x00),
+	RGBDEF(0x3f,0xb6,0x00),
+	RGBDEF(0x3f,0xda,0x00),
+	RGBDEF(0x3f,0xff,0x00),
+	RGBDEF(0x7f,0x00,0x00),
+	RGBDEF(0x7f,0x24,0x00),
+	RGBDEF(0x7f,0x48,0x00),
+	RGBDEF(0x7f,0x6d,0x00),
+	RGBDEF(0x7f,0x91,0x00),
+	RGBDEF(0x7f,0xb6,0x00),
+	RGBDEF(0x7f,0xda,0x00),
+	RGBDEF(0x7f,0xff,0x00),
+	RGBDEF(0xbf,0x00,0x00),
+	RGBDEF(0xbf,0x24,0x00),
+	RGBDEF(0xbf,0x48,0x00),
+	RGBDEF(0xbf,0x6d,0x00),
+	RGBDEF(0xbf,0x91,0x00),
+	RGBDEF(0xbf,0xb6,0x00),
+	RGBDEF(0xbf,0xda,0x00),
+	RGBDEF(0xbf,0xff,0x00),
+	RGBDEF(0xff,0x00,0x00),
+	RGBDEF(0xff,0x24,0x00),
+	RGBDEF(0xff,0x48,0x00),
+	RGBDEF(0xff,0x6d,0x00),
+	RGBDEF(0xff,0x91,0x00),
+	RGBDEF(0xff,0xb6,0x00),
+	RGBDEF(0xff,0xda,0x00),
+	RGBDEF(0xff,0xff,0x00),
+	RGBDEF(0x00,0x00,0x3f),
+	RGBDEF(0x00,0x24,0x3f),
+	RGBDEF(0x00,0x48,0x3f),
+	RGBDEF(0x00,0x6d,0x3f),
+	RGBDEF(0x00,0x91,0x3f),
+	RGBDEF(0x00,0xb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0x6d,0xbf),
+	RGBDEF(0x3f,0x91,0xbf),
+	RGBDEF(0x3f,0xb6,0xbf),
+	RGBDEF(0x3f,0xda,0xbf),
+	RGBDEF(0x3f,0xff,0xbf),
+	RGBDEF(0x7f,0x00,0xbf),
+	RGBDEF(0x7f,0x24,0xbf),
+	RGBDEF(0x7f,0x48,0xbf),
+	RGBDEF(0x7f,0x6d,0xbf),
+	RGBDEF(0x7f,0x91,0xbf),
+	RGBDEF(0x7f,0xb6,0xbf),
+	RGBDEF(0x7f,0xda,0xbf),
+	RGBDEF(0x7f,0xff,0xbf),
+	RGBDEF(0xbf,0x00,0xbf),
+	RGBDEF(0xbf,0x24,0xbf),
+	RGBDEF(0xbf,0x48,0xbf),
+	RGBDEF(0xbf,0x6d,0xbf),
+	RGBDEF(0xbf,0x91,0xbf),
+	RGBDEF(0xbf,0xb6,0xbf),
+	RGBDEF(0xbf,0xda,0xbf),
+	RGBDEF(0xbf,0xff,0xbf),
+	RGBDEF(0xff,0x00,0xbf),
+	RGBDEF(0xff,0x24,0xbf),
+	RGBDEF(0xff,0x48,0xbf),
+	RGBDEF(0xff,0x6d,0xbf),
+	RGBDEF(0xff,0x91,0xbf),
+	RGBDEF(0xff,0xb6,0xbf),
+	RGBDEF(0xff,0xda,0xbf),
+	RGBDEF(0xff,0xff,0xbf),
+	RGBDEF(0x00,0x00,0xff),
+	RGBDEF(0x00,0x24,0xff),
+	RGBDEF(0x00,0x48,0xff),
+	RGBDEF(0x00,0x6d,0xff),
+	RGBDEF(0x00,0x91,0xff),
+	RGBDEF(0x00,0xb,0x6ff),
+	RGBDEF(0x00,0xda,0xff),
+	RGBDEF(0x00,0xff,0xff),
+	RGBDEF(0x3f,0x00,0xff),
+	RGBDEF(0x3f,0x24,0xff),
+	RGBDEF(0x3f,0x48,0xff),
+	RGBDEF(0x3f,0x6d,0xff),
+	RGBDEF(0x3f,0x91,0xff),
+	RGBDEF(0x3f,0xb6,0xff),
+	RGBDEF(0x3f,0xda,0xff),
+	RGBDEF(0x3f,0xff,0xff),
+	RGBDEF(0x7f,0x00,0xff),
+	RGBDEF(0x7f,0x24,0xff),
+	RGBDEF(0x7f,0x48,0xff),
+	RGBDEF(0x7f,0x6d,0xff),
+	RGBDEF(0x7f,0x91,0xff),
+	RGBDEF(0x7f,0xb6,0xff),
+	RGBDEF(0x7f,0xda,0xff),
+	RGBDEF(0x7f,0xff,0xff),
+	RGBDEF(0xbf,0x00,0xff),
+	RGBDEF(0xbf,0x24,0xff),
+	RGBDEF(0xbf,0x48,0xff),
+	RGBDEF(0xbf,0x6d,0xff),
+	RGBDEF(0xbf,0x91,0xff),
+	RGBDEF(0xbf,0xb6,0xff),
+	RGBDEF(0xbf,0xda,0xff),
+	RGBDEF(0xbf,0xff,0xff),
+	RGBDEF(0xff,0x00,0xff),
+	RGBDEF(0xff,0x24,0xff),
+	RGBDEF(0xff,0x48,0xff),
+	RGBDEF(0xff,0x6d,0xff),
+	RGBDEF(0xff,0x91,0xff),
+	RGBDEF(0xff,0xb6,0xff),
+	RGBDEF(0xff,0xda,0xff),
+	RGBDEF(0xff,0xff,0xff)
+};
+
+#if TEST
+main()
+{
+	int	c;
+
+	DPRINTF("%d\n", ((int)&stdpalette[1]) - (int)&stdpalette[0]);
+
+	c = FindNearestColor(stdpalette, 224, 224, 224);
+	DPRINTF("%d = %02x %02x %02x\n", c, stdpalette[c].r, stdpalette[c].g,
+		stdpalette[c].b);
+}
+#endif
+
diff -Naur microwin_orig/src/engine/Objects.rules microwin_FINAL/src/engine/Objects.rules
--- microwin_orig/src/engine/Objects.rules	2004-02-28 18:07:35.000000000 +0100
+++ microwin_FINAL/src/engine/Objects.rules	2007-04-23 12:01:26.000000000 +0200
@@ -75,8 +75,12 @@
 #endif
 
 ifneq ($(ARCH), ELKS)
+ifeq ($(FLTK_8BPP_PALETTE), Y)
+MW_CORE_OBJS += $(MW_DIR_OBJ)/engine/devpal8_fltk.o
+else
 MW_CORE_OBJS += $(MW_DIR_OBJ)/engine/devpal8.o
 endif
+endif
 
 ifeq ($(GRAYPALETTE), Y)
 MW_CORE_OBJS += $(MW_DIR_OBJ)/engine/devpalgray4.o
diff -Naur microwin_orig/src/Makefile.rules microwin_FINAL/src/Makefile.rules
--- microwin_orig/src/Makefile.rules	2007-04-20 17:31:21.000000000 +0200
+++ microwin_FINAL/src/Makefile.rules	2007-04-23 11:59:54.000000000 +0200
@@ -40,6 +40,9 @@
 # Libraries required for the 'engine' functionality.
 MW_CORE_LIBS :=
 
+ifeq ($(FLTK_8BPP_PALETTE), Y)
+DEFINES += -DFLTK_8BPP_PALETTE=1
+endif
 
 ifeq ($(VTSWITCH), Y)
 DEFINES += -DVTSWITCH=1
diff -Naur microwin_orig/src/drivers/scr_fb.c microwin_sirius/src/drivers/scr_fb.c
--- microwin_orig/src/drivers/scr_fb.c	2005-06-15 04:31:16.000000000 +0200
+++ microwin_sirius/src/drivers/scr_fb.c	2006-11-08 15:04:56.000000000 +0100
@@ -505,9 +505,9 @@
 		break;
 	case MWPF_PALETTE:
 	default:
-		psi->rmask 	= 0xff;
-		psi->gmask 	= 0xff;
-		psi->bmask	= 0xff;
+		psi->rmask 	= 0xe0;
+		psi->gmask 	= 0x1c;
+		psi->bmask	= 0x03;
 		break;
 	}
 
diff -Naur microwin_orig/src/engine/devdraw.c microwin_sirius/src/engine/devdraw.c
--- microwin_orig/src/engine/devdraw.c	2005-12-21 03:56:46.000000000 +0100
+++ microwin_sirius/src/engine/devdraw.c	2006-11-08 15:09:34.000000000 +0100
@@ -1342,7 +1342,7 @@
 		r = *PIXELS++;
 		g = *PIXELS++;
 		b = *PIXELS++;
-		gr_foreground = RGB2PIXEL888(r, g, b);
+		gr_foreground = GdFindColor(psd, RGB2PIXEL888(r, g, b)); 
 		break;
 	case MWPF_TRUECOLOR565:
 	case MWPF_TRUECOLOR555:

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to