1From: Benjamin Deering
2Subject: orrery crashing X
3Date: Thursday, September 2, 2010 - 5:25 pm
4Link: http://kerneltrap.org/mailarchive/openmoko-community/2010/9/3/13218
5
6diff -uNr orrery.orig//orrery.c orrery/orrery.c
7--- orrery.orig//orrery.c	2009-11-30 06:59:44.000000000 +0100
8+++ orrery/orrery.c	2010-11-15 22:33:17.000000000 +0100
9@@ -1238,12 +1238,44 @@
10     }
11     currentEntry = currentEntry->forwardPointer;
12   }
13-  if (nDarkGreyPoints > 0)
14-    gdk_draw_points(pixmap, darkGreyGC, darkGreyPoints, nDarkGreyPoints);
15-  if (nGreyPoints > 0)
16-    gdk_draw_points(pixmap, greyGC, greyPoints, nGreyPoints);
17-  if (nWhitePoints > 0)
18-    gdk_draw_points(pixmap, whiteGC, whitePoints, nWhitePoints);
19+  GdkPixbuf* starDrawingBuf = gdk_pixbuf_get_from_drawable( NULL,
20+                                                            pixmap,
21+                                                            gdk_colormap_get_system()
22+                                                            , 0, 0, 0, 0, displayWidth, displayHeight);
23+  g_assert (gdk_pixbuf_get_bits_per_sample (starDrawingBuf) == 8);
24+  guchar* p;
25+  int rowstride = gdk_pixbuf_get_rowstride (starDrawingBuf);
26+  guchar* pixels = gdk_pixbuf_get_pixels (starDrawingBuf);
27+  int n_channels = gdk_pixbuf_get_n_channels (starDrawingBuf);
28+  GdkGCValues starGCval;
29+  GdkColor starColor;
30+  int pointNum;
31+  gdk_gc_get_values(darkGreyGC, &starGCval);
32+  gdk_colormap_query_color( gdk_gc_get_colormap(darkGreyGC),starGCval.foreground.pixel, &starColor );
33+  for( pointNum = 0; pointNum < nDarkGreyPoints; pointNum++) {
34+    p = pixels + darkGreyPoints[pointNum].y * rowstride + darkGreyPoints[pointNum].x * n_channels;
35+    p[0] = starColor.red & 0xff;
36+    p[1] = starColor.green & 0xff;
37+    p[2] = starColor.blue & 0xff;
38+  }
39+  gdk_gc_get_values(greyGC, &starGCval);
40+  gdk_colormap_query_color( gdk_gc_get_colormap(greyGC), starGCval.foreground.pixel, &starColor );
41+  for( pointNum = 0; pointNum < nGreyPoints; pointNum++) {
42+    p = pixels + greyPoints[pointNum].y * rowstride + greyPoints[pointNum].x * n_channels;
43+    p[0] = starColor.red & 0xff;
44+    p[1] = starColor.green & 0xff;
45+    p[2] = starColor.blue & 0xff;
46+  }
47+  gdk_gc_get_values(whiteGC, &starGCval);
48+  gdk_colormap_query_color( gdk_gc_get_colormap(whiteGC), starGCval.foreground.pixel, &starColor );
49+  for( pointNum = 0; pointNum < nWhitePoints; pointNum++) {
50+    p = pixels + whitePoints[pointNum].y * rowstride + whitePoints[pointNum].x * n_channels;
51+    p[0] = starColor.red & 0xff;
52+    p[1] = starColor.green & 0xff;
53+    p[2] = starColor.blue & 0xff;
54+  }
55+  gdk_draw_pixbuf ( pixmap , NULL , starDrawingBuf,
56+            0, 0, 0, 0, displayWidth, displayHeight, GDK_RGB_DITHER_NORMAL, 0, 0 ) ;
57 }
58
59 void makeTimeString(char *string)
60