Mercurial > projects > dwt-mac
diff dwt/graphics/ImageData.d @ 7:e831403a80a9
Add 'cast' to casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:30:35 +0200 |
parents | 1a8b3cb347e0 |
children | b9226997409c |
line wrap: on
line diff
--- a/dwt/graphics/ImageData.d Wed Aug 27 14:10:03 2008 +0200 +++ b/dwt/graphics/ImageData.d Wed Aug 27 14:30:35 2008 +0200 @@ -218,7 +218,7 @@ if (b is 0) continue; int inc = 0; for (int bit = 0x10000; (bit >>= b) !is 0;) inc |= bit; - for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = (byte)(v >> 8); + for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = cast(byte)(v >> 8); } } static final byte[] ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8]; @@ -627,7 +627,7 @@ if (alphaData is null) { int endIndex = startIndex + getWidth; for (int i = startIndex; i < endIndex; i++) { - alphas[i] = (byte)255; + alphas[i] = cast(byte)255; } return; } @@ -750,7 +750,7 @@ index = (y * bytesPerLine) + (x >> 1); if ((x & 0x1) is 1) { theByte = data[index] & 0xFF; - pixels[i] = (byte)(theByte & 0x0F); + pixels[i] = cast(byte)(theByte & 0x0F); i++; n--; srcX++; @@ -764,7 +764,7 @@ } while (n > 1) { theByte = data[index] & 0xFF; - pixels[i] = (byte)(theByte >> 4); + pixels[i] = cast(byte)(theByte >> 4); i++; n--; srcX++; @@ -773,7 +773,7 @@ index = srcY * bytesPerLine; srcX = 0; } else { - pixels[i] = (byte)(theByte & 0x0F); + pixels[i] = cast(byte)(theByte & 0x0F); i++; n--; srcX++; @@ -788,7 +788,7 @@ } if (n > 0) { theByte = data[index] & 0xFF; - pixels[i] = (byte)(theByte >> 4); + pixels[i] = cast(byte)(theByte >> 4); } return; case 2: @@ -798,7 +798,7 @@ while (n > 0) { offset = 3 - (srcX % 4); mask = 3 << (offset * 2); - pixels[i] = (byte)((theByte & mask) >> (offset * 2)); + pixels[i] = cast(byte)((theByte & mask) >> (offset * 2)); i++; n--; srcX++; @@ -992,7 +992,7 @@ while (n > 0) { offset = 3 - (srcX % 4); mask = 3 << (offset * 2); - pixels[i] = (byte)((theByte & mask) >> (offset * 2)); + pixels[i] = cast(byte)((theByte & mask) >> (offset * 2)); i++; n--; srcX++; @@ -1169,7 +1169,7 @@ DWT.error(DWT.ERROR_INVALID_ARGUMENT); if (alphaData is null) alphaData = new byte[width * height]; - alphaData[y * width + x] = (byte)alpha; + alphaData[y * width + x] = cast(byte)alpha; } /** @@ -1224,32 +1224,32 @@ switch (depth) { case 32: index = (y * bytesPerLine) + (x * 4); - data[index] = (byte)((pixelValue >> 24) & 0xFF); - data[index + 1] = (byte)((pixelValue >> 16) & 0xFF); - data[index + 2] = (byte)((pixelValue >> 8) & 0xFF); - data[index + 3] = (byte)(pixelValue & 0xFF); + data[index] = cast(byte)((pixelValue >> 24) & 0xFF); + data[index + 1] = cast(byte)((pixelValue >> 16) & 0xFF); + data[index + 2] = cast(byte)((pixelValue >> 8) & 0xFF); + data[index + 3] = cast(byte)(pixelValue & 0xFF); return; case 24: index = (y * bytesPerLine) + (x * 3); - data[index] = (byte)((pixelValue >> 16) & 0xFF); - data[index + 1] = (byte)((pixelValue >> 8) & 0xFF); - data[index + 2] = (byte)(pixelValue & 0xFF); + data[index] = cast(byte)((pixelValue >> 16) & 0xFF); + data[index + 1] = cast(byte)((pixelValue >> 8) & 0xFF); + data[index + 2] = cast(byte)(pixelValue & 0xFF); return; case 16: index = (y * bytesPerLine) + (x * 2); - data[index + 1] = (byte)((pixelValue >> 8) & 0xFF); - data[index] = (byte)(pixelValue & 0xFF); + data[index + 1] = cast(byte)((pixelValue >> 8) & 0xFF); + data[index] = cast(byte)(pixelValue & 0xFF); return; case 8: index = (y * bytesPerLine) + x ; - data[index] = (byte)(pixelValue & 0xFF); + data[index] = cast(byte)(pixelValue & 0xFF); return; case 4: index = (y * bytesPerLine) + (x >> 1); if ((x & 0x1) is 0) { - data[index] = (byte)((data[index] & 0x0F) | ((pixelValue & 0x0F) << 4)); + data[index] = cast(byte)((data[index] & 0x0F) | ((pixelValue & 0x0F) << 4)); } else { - data[index] = (byte)((data[index] & 0xF0) | (pixelValue & 0x0F)); + data[index] = cast(byte)((data[index] & 0xF0) | (pixelValue & 0x0F)); } return; case 2: @@ -1257,16 +1257,16 @@ theByte = data[index]; int offset = 3 - (x % 4); mask = 0xFF ^ (3 << (offset * 2)); - data[index] = (byte)((data[index] & mask) | (pixelValue << (offset * 2))); + data[index] = cast(byte)((data[index] & mask) | (pixelValue << (offset * 2))); return; case 1: index = (y * bytesPerLine) + (x >> 3); theByte = data[index]; mask = 1 << (7 - (x & 0x7)); if ((pixelValue & 0x1) is 1) { - data[index] = (byte)(theByte | mask); + data[index] = cast(byte)(theByte | mask); } else { - data[index] = (byte)(theByte & (mask ^ -1)); + data[index] = cast(byte)(theByte & (mask ^ -1)); } return; } @@ -1310,7 +1310,7 @@ case 8: index = (y * bytesPerLine) + x; for (int j = 0; j < putWidth; j++) { - data[index] = (byte)(pixels[i] & 0xFF); + data[index] = cast(byte)(pixels[i] & 0xFF); i++; srcX++; if (srcX >= width) { @@ -1328,9 +1328,9 @@ while (n > 0) { theByte = pixels[i] & 0x0F; if (high) { - data[index] = (byte)((data[index] & 0x0F) | (theByte << 4)); + data[index] = cast(byte)((data[index] & 0x0F) | (theByte << 4)); } else { - data[index] = (byte)((data[index] & 0xF0) | theByte); + data[index] = cast(byte)((data[index] & 0xF0) | theByte); } i++; n--; @@ -1347,12 +1347,12 @@ } return; case 2: - byte [] masks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F }; + byte [] masks = { cast(byte)0xFC, cast(byte)0xF3, cast(byte)0xCF, cast(byte)0x3F }; index = (y * bytesPerLine) + (x >> 2); int offset = 3 - (x % 4); while (n > 0) { theByte = pixels[i] & 0x3; - data[index] = (byte)((data[index] & masks[offset]) | (theByte << (offset * 2))); + data[index] = cast(byte)((data[index] & masks[offset]) | (theByte << (offset * 2))); i++; n--; srcX++; @@ -1376,9 +1376,9 @@ while (n > 0) { mask = 1 << (7 - (srcX & 0x7)); if ((pixels[i] & 0x1) is 1) { - data[index] = (byte)((data[index] & 0xFF) | mask); + data[index] = cast(byte)((data[index] & 0xFF) | mask); } else { - data[index] = (byte)((data[index] & 0xFF) & (mask ^ -1)); + data[index] = cast(byte)((data[index] & 0xFF) & (mask ^ -1)); } i++; n--; @@ -1436,10 +1436,10 @@ index = (y * bytesPerLine) + (x * 4); for (int j = 0; j < putWidth; j++) { pixel = pixels[i]; - data[index] = (byte)((pixel >> 24) & 0xFF); - data[index + 1] = (byte)((pixel >> 16) & 0xFF); - data[index + 2] = (byte)((pixel >> 8) & 0xFF); - data[index + 3] = (byte)(pixel & 0xFF); + data[index] = cast(byte)((pixel >> 24) & 0xFF); + data[index + 1] = cast(byte)((pixel >> 16) & 0xFF); + data[index + 2] = cast(byte)((pixel >> 8) & 0xFF); + data[index + 3] = cast(byte)(pixel & 0xFF); i++; srcX++; if (srcX >= width) { @@ -1455,9 +1455,9 @@ index = (y * bytesPerLine) + (x * 3); for (int j = 0; j < putWidth; j++) { pixel = pixels[i]; - data[index] = (byte)((pixel >> 16) & 0xFF); - data[index + 1] = (byte)((pixel >> 8) & 0xFF); - data[index + 2] = (byte)(pixel & 0xFF); + data[index] = cast(byte)((pixel >> 16) & 0xFF); + data[index + 1] = cast(byte)((pixel >> 8) & 0xFF); + data[index + 2] = cast(byte)(pixel & 0xFF); i++; srcX++; if (srcX >= width) { @@ -1473,8 +1473,8 @@ index = (y * bytesPerLine) + (x * 2); for (int j = 0; j < putWidth; j++) { pixel = pixels[i]; - data[index] = (byte)(pixel & 0xFF); - data[index + 1] = (byte)((pixel >> 8) & 0xFF); + data[index] = cast(byte)(pixel & 0xFF); + data[index + 1] = cast(byte)((pixel >> 8) & 0xFF); i++; srcX++; if (srcX >= width) { @@ -1489,7 +1489,7 @@ case 8: index = (y * bytesPerLine) + x; for (int j = 0; j < putWidth; j++) { - data[index] = (byte)(pixels[i] & 0xFF); + data[index] = cast(byte)(pixels[i] & 0xFF); i++; srcX++; if (srcX >= width) { @@ -1507,9 +1507,9 @@ while (n > 0) { theByte = pixels[i] & 0x0F; if (high) { - data[index] = (byte)((data[index] & 0x0F) | (theByte << 4)); + data[index] = cast(byte)((data[index] & 0x0F) | (theByte << 4)); } else { - data[index] = (byte)((data[index] & 0xF0) | theByte); + data[index] = cast(byte)((data[index] & 0xF0) | theByte); } i++; n--; @@ -1526,12 +1526,12 @@ } return; case 2: - byte [] masks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F }; + byte [] masks = { cast(byte)0xFC, cast(byte)0xF3, cast(byte)0xCF, cast(byte)0x3F }; index = (y * bytesPerLine) + (x >> 2); int offset = 3 - (x % 4); while (n > 0) { theByte = pixels[i] & 0x3; - data[index] = (byte)((data[index] & masks[offset]) | (theByte << (offset * 2))); + data[index] = cast(byte)((data[index] & masks[offset]) | (theByte << (offset * 2))); i++; n--; srcX++; @@ -1555,9 +1555,9 @@ while (n > 0) { mask = 1 << (7 - (srcX & 0x7)); if ((pixels[i] & 0x1) is 1) { - data[index] = (byte)((data[index] & 0xFF) | mask); + data[index] = cast(byte)((data[index] & 0xFF) | mask); } else { - data[index] = (byte)((data[index] & 0xFF) & (mask ^ -1)); + data[index] = cast(byte)((data[index] & 0xFF) & (mask ^ -1)); } i++; n--; @@ -1776,9 +1776,9 @@ /*** Prepare scaling data ***/ final int dwm1 = destWidth - 1; - final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0; + final int sfxi = (dwm1 !is 0) ? cast(int)(((cast(long)srcWidth << 16) - 1) / dwm1) : 0; final int dhm1 = destHeight - 1; - final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0; + final int sfyi = (dhm1 !is 0) ? cast(int)(((cast(long)srcHeight << 16) - 1) / dhm1) : 0; /*** Prepare source-related data ***/ final int sbpp, stype; @@ -2107,32 +2107,32 @@ (a >>> destAlphaPreShift << destAlphaShift); switch (dtype) { case TYPE_GENERIC_8: { - destData[dp] = (byte) data; + destData[dp] = cast(byte) data; } break; case TYPE_GENERIC_16_MSB: { - destData[dp] = (byte) (data >>> 8); - destData[dp + 1] = (byte) (data & 0xff); + destData[dp] = cast(byte) (data >>> 8); + destData[dp + 1] = cast(byte) (data & 0xff); } break; case TYPE_GENERIC_16_LSB: { - destData[dp] = (byte) (data & 0xff); - destData[dp + 1] = (byte) (data >>> 8); + destData[dp] = cast(byte) (data & 0xff); + destData[dp + 1] = cast(byte) (data >>> 8); } break; case TYPE_GENERIC_24: { - destData[dp] = (byte) (data >>> 16); - destData[dp + 1] = (byte) (data >>> 8); - destData[dp + 2] = (byte) (data & 0xff); + destData[dp] = cast(byte) (data >>> 16); + destData[dp + 1] = cast(byte) (data >>> 8); + destData[dp + 2] = cast(byte) (data & 0xff); } break; case TYPE_GENERIC_32_MSB: { - destData[dp] = (byte) (data >>> 24); - destData[dp + 1] = (byte) (data >>> 16); - destData[dp + 2] = (byte) (data >>> 8); - destData[dp + 3] = (byte) (data & 0xff); + destData[dp] = cast(byte) (data >>> 24); + destData[dp + 1] = cast(byte) (data >>> 16); + destData[dp + 2] = cast(byte) (data >>> 8); + destData[dp + 3] = cast(byte) (data & 0xff); } break; case TYPE_GENERIC_32_LSB: { - destData[dp] = (byte) (data & 0xff); - destData[dp + 1] = (byte) (data >>> 8); - destData[dp + 2] = (byte) (data >>> 16); - destData[dp + 3] = (byte) (data >>> 24); + destData[dp] = cast(byte) (data & 0xff); + destData[dp + 1] = cast(byte) (data >>> 8); + destData[dp + 2] = cast(byte) (data >>> 16); + destData[dp + 3] = cast(byte) (data >>> 24); } break; } } @@ -2198,9 +2198,9 @@ /*** Prepare scaling data ***/ final int dwm1 = destWidth - 1; - final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0; + final int sfxi = (dwm1 !is 0) ? cast(int)(((cast(long)srcWidth << 16) - 1) / dwm1) : 0; final int dhm1 = destHeight - 1; - final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0; + final int sfyi = (dhm1 !is 0) ? cast(int)(((cast(long)srcHeight << 16) - 1) / dhm1) : 0; /*** Prepare source-related data ***/ final int stype; @@ -2305,7 +2305,7 @@ } else { paletteMapping = new byte[1 << srcDepth]; int mask = (0xff << destDepth) >>> 8; - for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = (byte)(i & mask); + for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = cast(byte)(i & mask); } break; } @@ -2334,7 +2334,7 @@ minDistance = distance; } } - paletteMapping[i] = (byte)index; + paletteMapping[i] = cast(byte)index; if (minDistance !is 0) isExactPaletteMapping = false; } break; @@ -2358,8 +2358,8 @@ if ((sp & 1) !is 0) v = paletteMapping[srcData[sp >> 1] & 0x0f]; else v = (srcData[sp >> 1] >>> 4) & 0x0f; sp += (sfx >>> 16); - if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | v); - else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (v << 4)); + if ((dp & 1) !is 0) destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0xf0) | v); + else destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0x0f) | (v << 4)); } } break; @@ -2369,7 +2369,7 @@ final int index = paletteMapping[(srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03]; sp += (sfx >>> 16); final int shift = 6 - (dp & 3) * 2; - destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift)); + destData[dp >> 2] = cast(byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift)); } } break; @@ -2379,7 +2379,7 @@ final int index = paletteMapping[(srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01]; sp += (sfx >>> 16); final int shift = 7 - (dp & 7); - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); } } break; @@ -2389,7 +2389,7 @@ final int index = paletteMapping[(srcData[sp >> 3] >>> (sp & 7)) & 0x01]; sp += (sfx >>> 16); final int shift = dp & 7; - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); } } break; @@ -2464,23 +2464,23 @@ /*** WRITE NEXT PIXEL ***/ switch (dtype) { case TYPE_INDEX_8: - destData[dp] = (byte) index; + destData[dp] = cast(byte) index; break; case TYPE_INDEX_4: - if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | index); - else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (index << 4)); + if ((dp & 1) !is 0) destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0xf0) | index); + else destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0x0f) | (index << 4)); break; case TYPE_INDEX_2: { final int shift = 6 - (dp & 3) * 2; - destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift)); + destData[dp >> 2] = cast(byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift)); } break; case TYPE_INDEX_1_MSB: { final int shift = 7 - (dp & 7); - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); } break; case TYPE_INDEX_1_LSB: { final int shift = dp & 7; - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift)); } break; } } @@ -2644,23 +2644,23 @@ /*** WRITE NEXT PIXEL ***/ switch (dtype) { case TYPE_INDEX_8: - destData[dp] = (byte) lastindex; + destData[dp] = cast(byte) lastindex; break; case TYPE_INDEX_4: - if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex); - else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4)); + if ((dp & 1) !is 0) destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0xf0) | lastindex); + else destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4)); break; case TYPE_INDEX_2: { final int shift = 6 - (dp & 3) * 2; - destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift)); + destData[dp >> 2] = cast(byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift)); } break; case TYPE_INDEX_1_MSB: { final int shift = 7 - (dp & 7); - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); } break; case TYPE_INDEX_1_LSB: { final int shift = dp & 7; - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); } break; } } @@ -2728,9 +2728,9 @@ /*** Prepare scaling data ***/ final int dwm1 = destWidth - 1; - final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0; + final int sfxi = (dwm1 !is 0) ? cast(int)(((cast(long)srcWidth << 16) - 1) / dwm1) : 0; final int dhm1 = destHeight - 1; - final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0; + final int sfyi = (dhm1 !is 0) ? cast(int)(((cast(long)srcHeight << 16) - 1) / dhm1) : 0; /*** Prepare source-related data ***/ final int stype; @@ -2973,32 +2973,32 @@ (a >>> destAlphaPreShift << destAlphaShift); switch (dtype) { case TYPE_GENERIC_8: { - destData[dp] = (byte) data; + destData[dp] = cast(byte) data; } break; case TYPE_GENERIC_16_MSB: { - destData[dp] = (byte) (data >>> 8); - destData[dp + 1] = (byte) (data & 0xff); + destData[dp] = cast(byte) (data >>> 8); + destData[dp + 1] = cast(byte) (data & 0xff); } break; case TYPE_GENERIC_16_LSB: { - destData[dp] = (byte) (data & 0xff); - destData[dp + 1] = (byte) (data >>> 8); + destData[dp] = cast(byte) (data & 0xff); + destData[dp + 1] = cast(byte) (data >>> 8); } break; case TYPE_GENERIC_24: { - destData[dp] = (byte) (data >>> 16); - destData[dp + 1] = (byte) (data >>> 8); - destData[dp + 2] = (byte) (data & 0xff); + destData[dp] = cast(byte) (data >>> 16); + destData[dp + 1] = cast(byte) (data >>> 8); + destData[dp + 2] = cast(byte) (data & 0xff); } break; case TYPE_GENERIC_32_MSB: { - destData[dp] = (byte) (data >>> 24); - destData[dp + 1] = (byte) (data >>> 16); - destData[dp + 2] = (byte) (data >>> 8); - destData[dp + 3] = (byte) (data & 0xff); + destData[dp] = cast(byte) (data >>> 24); + destData[dp + 1] = cast(byte) (data >>> 16); + destData[dp + 2] = cast(byte) (data >>> 8); + destData[dp + 3] = cast(byte) (data & 0xff); } break; case TYPE_GENERIC_32_LSB: { - destData[dp] = (byte) (data & 0xff); - destData[dp + 1] = (byte) (data >>> 8); - destData[dp + 2] = (byte) (data >>> 16); - destData[dp + 3] = (byte) (data >>> 24); + destData[dp] = cast(byte) (data & 0xff); + destData[dp + 1] = cast(byte) (data >>> 8); + destData[dp + 2] = cast(byte) (data >>> 16); + destData[dp + 3] = cast(byte) (data >>> 24); } break; } } @@ -3066,9 +3066,9 @@ /*** Prepare scaling data ***/ final int dwm1 = destWidth - 1; - final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0; + final int sfxi = (dwm1 !is 0) ? cast(int)(((cast(long)srcWidth << 16) - 1) / dwm1) : 0; final int dhm1 = destHeight - 1; - final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0; + final int sfyi = (dhm1 !is 0) ? cast(int)(((cast(long)srcHeight << 16) - 1) / dhm1) : 0; /*** Prepare source-related data ***/ final int sbpp, stype; @@ -3351,23 +3351,23 @@ /*** WRITE NEXT PIXEL ***/ switch (dtype) { case TYPE_INDEX_8: - destData[dp] = (byte) lastindex; + destData[dp] = cast(byte) lastindex; break; case TYPE_INDEX_4: - if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex); - else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4)); + if ((dp & 1) !is 0) destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0xf0) | lastindex); + else destData[dp >> 1] = cast(byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4)); break; case TYPE_INDEX_2: { final int shift = 6 - (dp & 3) * 2; - destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift)); + destData[dp >> 2] = cast(byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift)); } break; case TYPE_INDEX_1_MSB: { final int shift = 7 - (dp & 7); - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); } break; case TYPE_INDEX_1_LSB: { final int shift = dp & 7; - destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); + destData[dp >> 3] = cast(byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift)); } break; } } @@ -3491,14 +3491,14 @@ ++dy, blend += blendi, dp += bytesPerLine) { for (int dx = 0; dx < bandWidth; ++dx) { bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) < - 0x1000000 ? (byte)0 : (byte)1; + 0x1000000 ? cast(byte)0 : cast(byte)1; } } } else { for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) { for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) { bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) < - 0x1000000 ? (byte)0 : (byte)1; + 0x1000000 ? cast(byte)0 : cast(byte)1; } } } @@ -3516,12 +3516,12 @@ final int inc = ((to << 16) - val) / steps + 1; if (vertical) { for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) { - bitmapData[dp] = (byte)(val >>> 16); + bitmapData[dp] = cast(byte)(val >>> 16); val += inc; } } else { for (int dx = 0; dx < bandWidth; ++dx, dp += 4) { - bitmapData[dp] = (byte)(val >>> 16); + bitmapData[dp] = cast(byte)(val >>> 16); val += inc; } } @@ -3542,7 +3542,7 @@ final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits; int temp = val + thresh; if (temp > 0xffffff) bitmapData[dptr] = -1; - else bitmapData[dptr] = (byte)((temp >>> 16) & mask); + else bitmapData[dptr] = cast(byte)((temp >>> 16) & mask); } val += inc; } @@ -3552,7 +3552,7 @@ final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits; int temp = val + thresh; if (temp > 0xffffff) bitmapData[dptr] = -1; - else bitmapData[dptr] = (byte)((temp >>> 16) & mask); + else bitmapData[dptr] = cast(byte)((temp >>> 16) & mask); } val += inc; }