comparison dwt/internal/image/WinICOFileFormat.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
comparison
equal deleted inserted replaced
6:b903c16b6f48 7:e831403a80a9
21 public final class WinICOFileFormat : FileFormat { 21 public final class WinICOFileFormat : FileFormat {
22 22
23 byte[] bitInvertData(byte[] data, int startIndex, int endIndex) { 23 byte[] bitInvertData(byte[] data, int startIndex, int endIndex) {
24 // Destructively bit invert data in the given byte array. 24 // Destructively bit invert data in the given byte array.
25 for (int i = startIndex; i < endIndex; i++) { 25 for (int i = startIndex; i < endIndex; i++) {
26 data[i] = (byte)(255 - data[i - startIndex]); 26 data[i] = cast(byte)(255 - data[i - startIndex]);
27 } 27 }
28 return data; 28 return data;
29 } 29 }
30 30
31 static final byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) { 31 static final byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) {
206 int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8); 206 int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
207 if (height is infoHeight && bitCount is 1) height /= 2; 207 if (height is infoHeight && bitCount is 1) height /= 2;
208 if (!((width is infoWidth) && (height * 2 is infoHeight) && 208 if (!((width is infoWidth) && (height * 2 is infoHeight) &&
209 (bitCount is 1 || bitCount is 4 || bitCount is 8 || bitCount is 24 || bitCount is 32))) 209 (bitCount is 1 || bitCount is 4 || bitCount is 8 || bitCount is 24 || bitCount is 32)))
210 DWT.error(DWT.ERROR_INVALID_IMAGE); 210 DWT.error(DWT.ERROR_INVALID_IMAGE);
211 infoHeader[8] = (byte)(height & 0xFF); 211 infoHeader[8] = cast(byte)(height & 0xFF);
212 infoHeader[9] = (byte)((height >> 8) & 0xFF); 212 infoHeader[9] = cast(byte)((height >> 8) & 0xFF);
213 infoHeader[10] = (byte)((height >> 16) & 0xFF); 213 infoHeader[10] = cast(byte)((height >> 16) & 0xFF);
214 infoHeader[11] = (byte)((height >> 24) & 0xFF); 214 infoHeader[11] = cast(byte)((height >> 24) & 0xFF);
215 return infoHeader; 215 return infoHeader;
216 } 216 }
217 /** 217 /**
218 * Unload a single icon 218 * Unload a single icon
219 */ 219 */
223 try { 223 try {
224 outputStream.writeInt(WinBMPFileFormat.BMPHeaderFixedSize); 224 outputStream.writeInt(WinBMPFileFormat.BMPHeaderFixedSize);
225 outputStream.writeInt(icon.width); 225 outputStream.writeInt(icon.width);
226 outputStream.writeInt(icon.height * 2); 226 outputStream.writeInt(icon.height * 2);
227 outputStream.writeShort(1); 227 outputStream.writeShort(1);
228 outputStream.writeShort((short)icon.depth); 228 outputStream.writeShort(cast(short)icon.depth);
229 outputStream.writeInt(0); 229 outputStream.writeInt(0);
230 outputStream.writeInt(sizeImage); 230 outputStream.writeInt(sizeImage);
231 outputStream.writeInt(0); 231 outputStream.writeInt(0);
232 outputStream.writeInt(0); 232 outputStream.writeInt(0);
233 outputStream.writeInt(icon.palette.colors !is null ? icon.palette.colors.length : 0); 233 outputStream.writeInt(icon.palette.colors !is null ? icon.palette.colors.length : 0);