nanogui: vnc for nano-X question


Previous by date: 7 Mar 2001 07:11:19 -0000 Modal dialog ?, Sunil Soman
Next by date: 7 Mar 2001 07:11:19 -0000 Re: WineCE, final answer?, Jakov af Wallby
Previous in thread: 7 Mar 2001 07:11:19 -0000 Re: vnc for nano-X question, George Harvey
Next in thread:

Subject: Re: vnc for nano-X question
From: "LC. Chang" ####@####.####
Date: 7 Mar 2001 07:11:19 -0000
Message-Id: <3AA5E14E.ECBADA8D@sis.com.tw>

Hi,

I have tried your vnc viewer but it did not work for me.
We find the problem is caused by using GrSetGCForeground().
The color format needs to be transformed before calling it.
I have modified the source from microwin0.89pre7 and it
now works fine. The attached patch is the modification we made.

Regards,
L.C. Chang


> Well, after a new hard disk, re-install, rebuild, etc. I've had
> another look and it seems that I'm still not correctly matching
> the server and client pixel formats in FindBestVisual(). However,
> there is a quick fix for 16-bit truecolour on Linux, start the
> vnc viewer as follows:
>
>   vnc -trucolour -depth 16 <hostname:n>
>
> where <hostname> is the name of the VNC server and <n> is the
> display number. I've tried this with a 16-bit Xvnc server and
> with nano-X running on a 16-bit Linux framebuffer, and the
> colours look OK.
>
> Note: this only works with the updated viewer from my web site.
> For those who missed the earlier post, get:
>
> nx-vnc332-250800.tar.gz from
> http://dspace.dial.pipex.com/town/way/fr30/uclinux/downloads/contents.shtml
>
> Regards,
> George
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####

diff -urN vnc/vncviewer/nanox.c vnc.new/vncviewer/nanox.c
--- vnc/vncviewer/nanox.c	Sun Jun 18 12:20:14 2000
+++ vnc.new/vncviewer/nanox.c	Wed Mar  7 14:54:00 2001
@@ -46,6 +46,19 @@
 #define INVALID_PIXEL 0xffffffff
 #define COLORMAP_SIZE 256
 
+/* create RGB colorval (0x00BBGGRR) from 8/8/8 format pixel*/
+#define PIXEL888TOCOLORVAL(p)   \
+        ((((p) & 0xff0000) >> 16) | ((p) & 0xff00) | (((p) & 0xff) << 16))
+
+/* create RGB colorval (0x00BBGGRR) from 5/6/5 format pixel*/
+#define PIXEL565TOCOLORVAL(p)   \
+        ((((p) & 0xf800) >> 8) | (((p) & 0x07e0) << 5) | (((p) & 0x1f) << 19))
+
+/* create BGR colorval (0x00BBGGRR) from 2/3/3 format pixel*/
+#define PIXEL233TOCOLORVAL(p)   \
+        ((((p) & 0x07) << 5) | (((p) & 0x38) << 10) | (((p) & 0x0c) << 16))
+
+
 /*
  * global data
  */
@@ -125,11 +138,31 @@
 	myFormat.bigEndian = 0;		/* how do I find this out? */
 	myFormat.trueColour = (myFormat.depth == 8 && !useBGR233) ? 0 : 1;
 	if (myFormat.trueColour) {
-		myFormat.redMax = myFormat.greenMax = 7;
-		myFormat.blueMax = 3;
-		myFormat.redShift = 0;
-		myFormat.greenShift = 3;
-		myFormat.blueShift = 6;
+		switch (myFormat.bitsPerPixel) {
+		case 8:
+			myFormat.redMax = myFormat.greenMax = 7;
+			myFormat.blueMax = 3;
+			myFormat.redShift = 0;
+			myFormat.greenShift = 3;
+			myFormat.blueShift = 6;
+			break;
+		case 16:
+			myFormat.redMax = 31;
+			myFormat.greenMax = 63;
+			myFormat.blueMax = 31;
+			myFormat.redShift = 11;
+			myFormat.greenShift = 5;
+			myFormat.blueShift = 0;
+			break;
+		case 32:
+			myFormat.redMax = 255;
+			myFormat.greenMax = 255;
+			myFormat.blueMax = 255;
+			myFormat.redShift = 16;
+			myFormat.greenShift = 8;
+			myFormat.blueShift = 0;
+
+		}
 	}
 	pixtype = si.pixtype;
 	/* get the initial server palette */
@@ -155,6 +188,7 @@
 	GrSelectEvents(wid, GR_EVENT_MASK_BUTTON_DOWN |
 		GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_KEY_DOWN |
 		GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_MOUSE_POSITION);
+
 	/* make thw window visible */
 	GrMapWindow(wid);
 	canvas = wid;
@@ -202,7 +236,7 @@
 XCopyArea(Display *dpy, Window src, Window dst, GR_GC_ID gc,
         int x1, int y1, int w, int h, int x2, int y2)
 {
-/*	printf("XCopyArea: src=%d, dst=%d, w=%d, h=%d\n",src, dst, w, h); */
+//	printf("XCopyArea: src=%d, dst=%d, w=%d, h=%d\n",src, dst, w, h); 
 	GrCopyArea(dst, gc, x2, y2, w, h, src, x1, y1, MWROP_SRCCOPY);
 	return(0);
 }
@@ -215,7 +249,7 @@
         int x, int y, int w, int h)
 {
 	GrFillRect(canvas, gc, x, y, w, h);
-/*	printf("XFillRectangle: gr_foreground=%08x\n", (int)gr_foreground); */
+//	printf("XFillRectangle: gr_foreground=%08x\n", (int)gr_foreground); 
 	return(0);
 }
 
@@ -245,7 +279,17 @@
 		 */
 		GrSetGCForeground(gc, gcv->foreground | MWF_PALINDEX);
 	} else {
-		GrSetGCForeground(gc, gcv->foreground);
+            switch (myFormat.bitsPerPixel) {
+            
+            case 8:
+            	    GrSetGCForeground(gc, PIXEL233TOCOLORVAL(gcv->foreground));
+            	    break;
+            case 16:
+		    GrSetGCForeground(gc, PIXEL565TOCOLORVAL(gcv->foreground));
+		    break;
+	    case 32:
+	    	    GrSetGCForeground(gc, PIXEL888TOCOLORVAL(gcv->foreground));
+	    }
 	}
         return(0);
 }

Previous by date: 7 Mar 2001 07:11:19 -0000 Modal dialog ?, Sunil Soman
Next by date: 7 Mar 2001 07:11:19 -0000 Re: WineCE, final answer?, Jakov af Wallby
Previous in thread: 7 Mar 2001 07:11:19 -0000 Re: vnc for nano-X question, George Harvey
Next in thread:


Powered by ezmlm-browse 0.20.