diff dwt/internal/image/PngHuffmanTable.d @ 34:5123b17c98ef

Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sun, 14 Sep 2008 01:45:57 +0200
parents b903c16b6f48
children
line wrap: on
line diff
--- a/dwt/internal/image/PngHuffmanTable.d	Fri Sep 12 13:53:21 2008 +0200
+++ b/dwt/internal/image/PngHuffmanTable.d	Sun Sep 14 01:45:57 2008 +0200
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,21 +7,22 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
-module dwt.internal.image;
+module dwt.internal.image.PngHuffmanTable;
 
-import java.io.IOException;
+import dwt.internal.image.PngDecodingDataStream;
 
 public class PngHuffmanTable {
     CodeLengthInfo[] codeLengthInfo;
     int[] codeValues;
-    
-    static final int MAX_CODE_LENGTH = 15;
-    static final int BAD_CODE = 0xFFFFFFF;
-    static final int incs[] = {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1};
+
+    static const int MAX_CODE_LENGTH = 15;
+    static const int BAD_CODE = 0xFFFFFFF;
+    static const int incs[] = [1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1];
 
 this (int[] lengths) {
-    super();
     initialize(lengths);
     generateTable(lengths);
 }
@@ -31,7 +32,7 @@
     for (int i = 0; i < codeValues.length; i++) {
         codeValues[i] = i;
     }
-    
+
     // minCodesByLength[n] : The smallest Huffman code of length n + 1.
     // maxCodesByLength[n] : The largest Huffman code of length n + 1.
     // indexesByLength[n] : Index into the values array. First value with a code of length n + 1.
@@ -44,7 +45,7 @@
         codeLengthInfo[i].max = -1;
     }
 }
-    
+
 private void generateTable(int[] lengths) {
     // Sort the values using shellsort. Primary key is code size. Secondary key is value.
     int codeValuesTemp;
@@ -79,7 +80,7 @@
             code++;
         }
     }
-    
+
     int last = 0;
     for (int i = 0; i < lengths.length; i++) {
         if (last !is lengths[i]) {
@@ -113,8 +114,8 @@
     // so now we can look up the value for the Huffman code in the table.
     int index = codeLengthInfo[codelength].baseIndex + offset;
     return codeValues[index];
-}   
-    
+}
+
 static class CodeLengthInfo {
     int length;
     int max;