qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Henrik Carlqvist <henca@users.SourceForge.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Patch against weird colors with Hummingbird eXceed X server
Date: Mon, 26 Sep 2005 19:58:06 +0200	[thread overview]
Message-ID: <20050926195806.6ef0fbc9.henca@users.SourceForge.net> (raw)

Hello and thanks for qemu which is a great program!

I posted a patch at http://m2.dad-answers.com/qemu-forum/ and got the
advice to also post the patch to this mailing list, so here it comes:

Most X servers I have seen have color masks something like this (from
xdpyinfo):
red, green, blue masks: 0xf800, 0x7e0, 0x1f

However, Hummingbird eXceed which is an X server for Microsoft Windows
instead looks something like this:
red, green, blue masks: 0xff, 0xff00, 0xff0000

With such an X server connected to a Linux host qemu version 0.7.2 gives
strange colors on screen as the red and blue components of colors gets
mixed up. For example an MS Windows blue screen of death becomes a red
screen of death instead.

The SDL_SetVideoMode function call returns some information about how the
color masks are ordered in the returned struct, and that data could be
used to correctly render the colors by modifying files like console.c and
vga.c. However, I found it easier to only call SDL_SetVideoMode again to
find a bit depth which does not correspond to the actual bit depth of the
X server. Then SDL gives a surface which has the color masks in the right
order.

My simple patch looks like this:

-8<-----------------------------------------------------------------
--- ../qemu-0.7.2/sdl.c 2005-09-04 19:11:31.000000000 +0200
+++ sdl.c       2005-09-21 14:16:26.000000000 +0200
@@ -49,17 +49,25 @@
 static void sdl_resize(DisplayState *ds, int w, int h)
 {
     int flags;
+    int i=0;
+    int a[4]={0,32,16,0};
  
     //    printf("resizing to %d %d\n", w, h);
  
     flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
     if (gui_fullscreen)
         flags |= SDL_FULLSCREEN;
-    screen = SDL_SetVideoMode(w, h, 0, flags);
-    if (!screen) {
-        fprintf(stderr, "Could not open SDL display\n");
-        exit(1);
+    do
+    {
+        screen = SDL_SetVideoMode(w, h, a[i], flags);
+        if (!screen) {
+            fprintf(stderr, "Could not open SDL display\n");
+            exit(1);
+        }
     }
+    while ( (screen->format->Rmask < screen->format->Bmask) && (++i <
4));
+    /* Trying to find a screen which won't produce wrong colors */
+
     ds->data = screen->pixels;
     ds->linesize = screen->pitch;
     ds->depth = screen->format->BitsPerPixel;
-8<-----------------------------------------------------------------

regards Henrik

-- 
NOTE: Dear Outlook users: Please remove me from your address books.
      Read this article and you know why:
      http://newsforge.com/article.pl?sid=03/08/21/143258

                 reply	other threads:[~2005-09-26 18:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050926195806.6ef0fbc9.henca@users.SourceForge.net \
    --to=henca@users.sourceforge.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).