comparison dwt/graphics/Image.d @ 302:555d58850cd9

Omit array bounds checking on dynamic struct length.
author Frank Benoit <benoit@tionex.de>
date Fri, 29 Aug 2008 04:26:26 +0200
parents fd9c62a2998e
children eddc0e013cb8
comparison
equal deleted inserted replaced
301:244e3774d515 302:555d58850cd9
10 * Port to the D programming language: 10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de> 11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwt.graphics.Image; 13 module dwt.graphics.Image;
14 14
15 15 import tango.util.log.Trace;
16 import dwt.DWT; 16 import dwt.DWT;
17 import dwt.DWTError; 17 import dwt.DWTError;
18 import dwt.DWTException; 18 import dwt.DWTException;
19 import dwt.internal.gdip.Gdip; 19 import dwt.internal.gdip.Gdip;
20 import dwt.internal.win32.OS; 20 import dwt.internal.win32.OS;
710 //PORTING_COMMENT: moved down 710 //PORTING_COMMENT: moved down
711 //OS.HeapFree(hHeap, 0, palette); 711 //OS.HeapFree(hHeap, 0, palette);
712 RGB[] rgbs = new RGB[colorPalette.Count]; 712 RGB[] rgbs = new RGB[colorPalette.Count];
713 paletteData = new PaletteData(rgbs); 713 paletteData = new PaletteData(rgbs);
714 for (int i = 0; i < colorPalette.Count; i++) { 714 for (int i = 0; i < colorPalette.Count; i++) {
715 if (((palette.Entries[i] >> 24) & 0xFF) is 0 && (colorPalette.Flags & Gdip.PaletteFlagsHasAlpha) !is 0) { 715 // DWT: access palette.Entries without array bounds checking
716 if (((*(palette.Entries.ptr + i) >> 24) & 0xFF) is 0 && (colorPalette.Flags & Gdip.PaletteFlagsHasAlpha) !is 0) {
716 transparentPixel = i; 717 transparentPixel = i;
717 } 718 }
718 rgbs[i] = new RGB(((palette.Entries[i] & 0xFF0000) >> 16), ((palette.Entries[i] & 0xFF00) >> 8), ((palette.Entries[i] & 0xFF) >> 0)); 719 rgbs[i] = new RGB(((*(palette.Entries.ptr + i) & 0xFF0000) >> 16), ((*(palette.Entries.ptr + i) & 0xFF00) >> 8), ((*(palette.Entries.ptr + i) & 0xFF) >> 0));
719 } 720 }
720 OS.HeapFree(hHeap, 0, palette); 721 OS.HeapFree(hHeap, 0, palette);
721 break; 722 break;
722 case Gdip.PixelFormat16bppARGB1555: 723 case Gdip.PixelFormat16bppARGB1555:
723 case Gdip.PixelFormat16bppRGB555: paletteData = new PaletteData(0x7C00, 0x3E0, 0x1F); break; 724 case Gdip.PixelFormat16bppRGB555: paletteData = new PaletteData(0x7C00, 0x3E0, 0x1F); break;