diff dwt/graphics/ImageData.d @ 54:8f049b136add

first example working
author Frank Benoit <benoit@tionex.de>
date Fri, 11 Jan 2008 14:31:37 +0100
parents fc2b263b8a3f
children 93981635e709
line wrap: on
line diff
--- a/dwt/graphics/ImageData.d	Fri Jan 11 11:21:52 2008 +0100
+++ b/dwt/graphics/ImageData.d	Fri Jan 11 14:31:37 2008 +0100
@@ -215,19 +215,20 @@
 	/**
 	 * Arbitrary channel width data to 8-bit conversion table.
 	 */
-	static const byte[][] ANY_TO_EIGHT;
-	static this() {
-        ANY_TO_EIGHT = new byte[][](9);
-		for (int b = 0; b < 9; ++b) {
-			byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
-			if (b == 0) continue;
-			int inc = 0;
-			for (int bit = 0x10000; (bit >>= b) != 0;) inc |= bit;
-			for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = cast(byte)(v >> 8);
-		}
-        ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
+	static byte[][] ANY_TO_EIGHT;
+
+	synchronized static void static_this() {
+            ANY_TO_EIGHT = new byte[][](9);
+            for (int b = 0; b < 9; ++b) {
+                byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
+                if (b == 0) continue;
+                int inc = 0;
+                for (int bit = 0x10000; (bit >>= b) != 0;) inc |= bit;
+                for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = cast(byte)(v >> 8);
+            }
+            ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
 	}
-	static const byte[] ONE_TO_ONE_MAPPING;
+	static byte[] ONE_TO_ONE_MAPPING;
 
 	/**
 	 * Scaled 8x8 Bayer dither matrix.
@@ -422,7 +423,6 @@
 	byte[] alphaData, int alpha, int transparentPixel, int type,
 	int x, int y, int disposalMethod, int delayTime)
 {
-
 	if (palette == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
 	if (!(depth == 1 || depth == 2 || depth == 4 || depth == 8
 		|| depth == 16 || depth == 24 || depth == 32)) {