Mercurial > projects > dwt-mac
diff dwt/internal/image/GIFFileFormat.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/GIFFileFormat.d Wed Aug 27 14:10:03 2008 +0200 +++ b/dwt/internal/image/GIFFileFormat.d Wed Aug 27 14:30:35 2008 +0200 @@ -35,8 +35,8 @@ static final int GIF_EXTENSION_BLOCK_ID = 0x21; static final int GIF_IMAGE_BLOCK_ID = 0x2C; static final int GIF_TRAILER_ID = 0x3B; - static final byte [] GIF89a = new byte[] { (byte)'G', (byte)'I', (byte)'F', (byte)'8', (byte)'9', (byte)'a' }; - static final byte [] NETSCAPE2_0 = new byte[] { (byte)'N', (byte)'E', (byte)'T', (byte)'S', (byte)'C', (byte)'A', (byte)'P', (byte)'E', (byte)'2', (byte)'.', (byte)'0' }; + static final byte [] GIF89a = new byte[] { cast(byte)'G', cast(byte)'I', cast(byte)'F', cast(byte)'8', cast(byte)'9', cast(byte)'a' }; + static final byte [] NETSCAPE2_0 = new byte[] { cast(byte)'N', cast(byte)'E', cast(byte)'T', cast(byte)'S', cast(byte)'C', cast(byte)'A', cast(byte)'P', cast(byte)'E', cast(byte)'2', cast(byte)'.', cast(byte)'0' }; /** * Answer a palette containing numGrays @@ -46,7 +46,7 @@ int n = numGrays - 1; RGB[] colors = new RGB[numGrays]; for (int i = 0; i < numGrays; i++) { - int intensity = (byte)((i * 3) * 256 / n); + int intensity = cast(byte)((i * 3) * 256 / n); colors[i] = new RGB(intensity, intensity, intensity); } return new PaletteData(colors); @@ -121,7 +121,7 @@ id = inputStream.read(); if (id > 0) { /* We read the terminator earlier. */ - inputStream.unread(new byte[] {(byte)id}); + inputStream.unread(new byte[] {cast(byte)id}); } } catch (IOException e) { DWT.error(DWT.ERROR_IO, e); @@ -164,7 +164,7 @@ } if (id is GIF_IMAGE_BLOCK_ID || id is GIF_TRAILER_ID) { try { - inputStream.unread(new byte[] {(byte)id}); + inputStream.unread(new byte[] {cast(byte)id}); } catch (IOException e) { DWT.error(DWT.ERROR_IO, e); } @@ -483,8 +483,8 @@ /* Step 3: Write the GIF89a Header and Logical Screen Descriptor. */ outputStream.write(GIF89a); int bitField = globalTable*128 + (depth-1)*16 + depth-1; - outputStream.writeShort((short)logicalScreenWidth); - outputStream.writeShort((short)logicalScreenHeight); + outputStream.writeShort(cast(short)logicalScreenWidth); + outputStream.writeShort(cast(short)logicalScreenHeight); outputStream.write(bitField); outputStream.write(backgroundPixel); outputStream.write(0); // Aspect ratio is 1:1 @@ -507,7 +507,7 @@ outputStream.write(NETSCAPE2_0); outputStream.write(3); // Three bytes follow outputStream.write(1); // Extension type - outputStream.writeShort((short) repeatCount); + outputStream.writeShort(cast(short) repeatCount); outputStream.write(0); // Block terminator } catch (IOException e) { DWT.error(DWT.ERROR_IO, e); @@ -529,15 +529,15 @@ try { outputStream.write(GIF_IMAGE_BLOCK_ID); byte[] block = new byte[9]; - block[0] = (byte)(x & 0xFF); - block[1] = (byte)((x >> 8) & 0xFF); - block[2] = (byte)(y & 0xFF); - block[3] = (byte)((y >> 8) & 0xFF); - block[4] = (byte)(width & 0xFF); - block[5] = (byte)((width >> 8) & 0xFF); - block[6] = (byte)(height & 0xFF); - block[7] = (byte)((height >> 8) & 0xFF); - block[8] = (byte)(globalTable is 0 ? (depth-1) | 0x80 : 0x00); + block[0] = cast(byte)(x & 0xFF); + block[1] = cast(byte)((x >> 8) & 0xFF); + block[2] = cast(byte)(y & 0xFF); + block[3] = cast(byte)((y >> 8) & 0xFF); + block[4] = cast(byte)(width & 0xFF); + block[5] = cast(byte)((width >> 8) & 0xFF); + block[6] = cast(byte)(height & 0xFF); + block[7] = cast(byte)((height >> 8) & 0xFF); + block[8] = cast(byte)(globalTable is 0 ? (depth-1) | 0x80 : 0x00); outputStream.write(block); } catch (IOException e) { DWT.error(DWT.ERROR_IO, e); @@ -579,17 +579,17 @@ gcBlock[2] = 0; gcBlock[3] = 0; if (image.transparentPixel !is -1) { - gcBlock[0] = (byte)0x01; - gcBlock[3] = (byte)image.transparentPixel; + gcBlock[0] = cast(byte)0x01; + gcBlock[3] = cast(byte)image.transparentPixel; } if (image.disposalMethod !is 0) { - gcBlock[0] |= (byte)((image.disposalMethod & 0x07) << 2); + gcBlock[0] |= cast(byte)((image.disposalMethod & 0x07) << 2); } if (image.delayTime !is 0) { - gcBlock[1] = (byte)(image.delayTime & 0xFF); - gcBlock[2] = (byte)((image.delayTime >> 8) & 0xFF); + gcBlock[1] = cast(byte)(image.delayTime & 0xFF); + gcBlock[2] = cast(byte)((image.delayTime >> 8) & 0xFF); } - outputStream.write((byte)gcBlock.length); + outputStream.write(cast(byte)gcBlock.length); outputStream.write(gcBlock); outputStream.write(0); // Block terminator } catch (IOException e) { @@ -605,9 +605,9 @@ int offset = 0; for (int i = 0; i < palette.colors.length; i++) { RGB color = palette.colors[i]; - bytes[offset] = (byte)color.red; - bytes[offset + 1] = (byte)color.green; - bytes[offset + 2] = (byte)color.blue; + bytes[offset] = cast(byte)color.red; + bytes[offset + 1] = cast(byte)color.green; + bytes[offset + 2] = cast(byte)color.blue; offset += 3; } try {