diff dwt/internal/image/JPEGFileFormat.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 380af2bdd8e5
children 5123b17c98ef
line wrap: on
line diff
--- a/dwt/internal/image/JPEGFileFormat.d	Wed Aug 27 14:10:03 2008 +0200
+++ b/dwt/internal/image/JPEGFileFormat.d	Wed Aug 27 14:30:35 2008 +0200
@@ -242,7 +242,7 @@
                     sum += dataCbComp[srcIndex + ih] & 0xFF;
                 }
             }
-            imageComponents[ID_CB][destRowIndex + xPos] = (byte)(sum / vhFactor);
+            imageComponents[ID_CB][destRowIndex + xPos] = cast(byte)(sum / vhFactor);
         }
     }
     frameComponent = frameComponents[componentIds[ID_CR]];
@@ -256,7 +256,7 @@
                     sum += dataCrComp[srcIndex + ih] & 0xFF;
                 }
             }
-            imageComponents[ID_CR][destRowIndex + xPos] = (byte)(sum / vhFactor);
+            imageComponents[ID_CR][destRowIndex + xPos] = cast(byte)(sum / vhFactor);
         }
     }
     for (int iComp = 0; iComp < nComponents; iComp++) {
@@ -274,7 +274,7 @@
                 int dstOfs = ((yPos + 1) * componentWidth - delta);
                 int dataValue = imageComponent[(dstOfs > 0) ? dstOfs - 1 : 0] & 0xFF;
                 for (int i = 0; i < delta; i++) {
-                    imageComponent[dstOfs + i] = (byte)dataValue;
+                    imageComponent[dstOfs + i] = cast(byte)dataValue;
                 }
             }
         }
@@ -301,13 +301,13 @@
         int g = color.green;
         int b = color.blue;
         int n = RYTable[r] + GYTable[g] + BYTable[b];
-        yComp[i] = (byte)(n >> 16);
+        yComp[i] = cast(byte)(n >> 16);
         if ((n < 0) && ((n & 0xFFFF) !is 0)) yComp[i]--;
         n = RCbTable[r] + GCbTable[g] + BCbTable[b];
-        cbComp[i] = (byte)(n >> 16);
+        cbComp[i] = cast(byte)(n >> 16);
         if ((n < 0) && ((n & 0xFFFF) !is 0)) cbComp[i]--;
         n = RCrTable[r] + GCrTable[g] + BCrTable[b];
-        crComp[i] = (byte)(n >> 16);
+        crComp[i] = cast(byte)(n >> 16);
         if ((n < 0) && ((n & 0xFFFF) !is 0)) crComp[i]--;
     }
     int bSize = srcWidth * srcHeight;
@@ -348,13 +348,13 @@
         int g = color.green;
         int b = color.blue;
         int n = RYTable[r] + GYTable[g] + BYTable[b];
-        yComp[i] = (byte)(n >> 16);
+        yComp[i] = cast(byte)(n >> 16);
         if ((n < 0) && ((n & 0xFFFF) !is 0)) yComp[i]--;
         n = RCbTable[r] + GCbTable[g] + BCbTable[b];
-        cbComp[i] = (byte)(n >> 16);
+        cbComp[i] = cast(byte)(n >> 16);
         if ((n < 0) && ((n & 0xFFFF) !is 0)) cbComp[i]--;
         n = RCrTable[r] + GCrTable[g] + BCrTable[b];
-        crComp[i] = (byte)(n >> 16);
+        crComp[i] = cast(byte)(n >> 16);
         if ((n < 0) && ((n & 0xFFFF) !is 0)) crComp[i]--;
     }
     int dstWidth = image.width;
@@ -428,9 +428,9 @@
                 g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
                 int b = pixel & blueMask;
                 b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;                
-                dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
-                dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
-                dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
+                dataYComp[dstDataIndex] = cast(byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
+                dataCbComp[dstDataIndex] = cast(byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
+                dataCrComp[dstDataIndex] = cast(byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
             }
         }
     } else {
@@ -444,9 +444,9 @@
                 int r = rgb.red;
                 int g = rgb.green;
                 int b = rgb.blue;
-                dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
-                dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
-                dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
+                dataYComp[dstDataIndex] = cast(byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
+                dataCbComp[dstDataIndex] = cast(byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
+                dataCrComp[dstDataIndex] = cast(byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
             }
         }
     }
@@ -470,7 +470,7 @@
             if (j >= imageWidth) {
                 y = 0;
             }
-            data[destIndex] = (byte)y;
+            data[destIndex] = cast(byte)y;
             srcIndex++;
             destIndex++;
         }
@@ -537,9 +537,9 @@
             } else {
                 if (b > 255) b = 255;
             }
-            rgbData[destIndex] = (byte)b;
-            rgbData[destIndex + 1] = (byte)g;
-            rgbData[destIndex + 2] = (byte)r;
+            rgbData[destIndex] = cast(byte)b;
+            rgbData[destIndex + 1] = cast(byte)g;
+            rgbData[destIndex + 2] = cast(byte)r;
             destIndex += 3;
             srcIndex++;
         }
@@ -830,15 +830,15 @@
     };
     int code = (huffCode & power2m1[nBits - 1]) << (24 - nBits - currentBitCount);
     byte[] codeBuffer = new byte[4];
-    codeBuffer[0] = (byte)(code & 0xFF);
-    codeBuffer[1] = (byte)((code >> 8) & 0xFF);
-    codeBuffer[2] = (byte)((code >> 16) & 0xFF);
-    codeBuffer[3] = (byte)((code >> 24) & 0xFF);
+    codeBuffer[0] = cast(byte)(code & 0xFF);
+    codeBuffer[1] = cast(byte)((code >> 8) & 0xFF);
+    codeBuffer[2] = cast(byte)((code >> 16) & 0xFF);
+    codeBuffer[3] = cast(byte)((code >> 24) & 0xFF);
     int abs = nBits - (8 - currentBitCount);
     if (abs < 0) abs = -abs;
     if ((abs >> 3) > 0) {
         currentByte += codeBuffer[2];
-        emitByte((byte)currentByte);
+        emitByte(cast(byte)currentByte);
         emitByte(codeBuffer[1]);
         currentByte = codeBuffer[0];
         currentBitCount += nBits - 16;
@@ -846,7 +846,7 @@
         currentBitCount += nBits;
         if (currentBitCount >= 8) {
             currentByte += codeBuffer[2];
-            emitByte((byte)currentByte);
+            emitByte(cast(byte)currentByte);
             currentByte = codeBuffer[1];
             currentBitCount -= 8;
         } else {
@@ -861,7 +861,7 @@
     dataBuffer[bufferCurrentPosition] = byteValue;
     bufferCurrentPosition++;
     if (byteValue is -1) {
-        emitByte((byte)0);
+        emitByte(cast(byte)0);
     }
 }
 void encodeACCoefficients(int[] dataUnit, int iComp) {
@@ -947,7 +947,7 @@
         }
     }
     if (currentBitCount !is 0) {
-        emitByte((byte)currentByte);
+        emitByte(cast(byte)currentByte);
     }
     resetOutputBuffer();
 }
@@ -1702,9 +1702,9 @@
     try {
         while (true) {
             if (byteStream.read(byteArray, 0, 1) !is 1) return null;
-            if (byteArray[0] is (byte) 0xFF) {
+            if (byteArray[0] is cast(byte) 0xFF) {
                 if (byteStream.read(byteArray, 1, 1) !is 1) return null;
-                if (byteArray[1] !is (byte) 0xFF && byteArray[1] !is 0) {
+                if (byteArray[1] !is cast(byte) 0xFF && byteArray[1] !is 0) {
                     byteStream.unread(byteArray);
                     return new JPEGSegment(byteArray);
                 }
@@ -1756,7 +1756,7 @@
             } else {
                 if (x > 255) x = 255;
             }
-            compImage[destIndex + col] = (byte)x;
+            compImage[destIndex + col] = cast(byte)x;
             srcIndex++;
         }
         destIndex += compWidth;
@@ -1767,7 +1767,7 @@
     if (!new JPEGStartOfImage().writeToStream(outputStream)) {
         DWT.error(DWT.ERROR_IO);
     }
-    JPEGAppn appn = new JPEGAppn(new byte[] {(byte)0xFF, (byte)0xE0, 0, 0x10, 0x4A, 0x46, 0x49, 0x46, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0});
+    JPEGAppn appn = new JPEGAppn(new byte[] {cast(byte)0xFF, cast(byte)0xE0, 0, 0x10, 0x4A, 0x46, 0x49, 0x46, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0});
     if (!appn.writeToStream(outputStream)) {
         DWT.error(DWT.ERROR_IO);
     }