Mercurial > projects > dwt-linux
comparison dwt/graphics/ImageData.d @ 240:ce446666f5a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 12 May 2008 19:13:01 +0200 |
parents | 380bad9f6852 |
children | 5a30aa9820f3 |
comparison
equal
deleted
inserted
replaced
239:06a1f6829310 | 240:ce446666f5a2 |
---|---|
287 * @param scanlinePad the padding of each line, in bytes | 287 * @param scanlinePad the padding of each line, in bytes |
288 * @param data the data of the image | 288 * @param data the data of the image |
289 * | 289 * |
290 * @exception IllegalArgumentException <ul> | 290 * @exception IllegalArgumentException <ul> |
291 * <li>ERROR_INVALID_ARGUMENT - if the width or height is negative, or if the depth is not | 291 * <li>ERROR_INVALID_ARGUMENT - if the width or height is negative, or if the depth is not |
292 * one of 1, 2, 4, 8, 16, 24 or 32</li> | 292 * one of 1, 2, 4, 8, 16, 24 or 32, or the data array is too small to contain the image data</li> |
293 * <li>ERROR_NULL_ARGUMENT - if the palette or data is null</li> | 293 * <li>ERROR_NULL_ARGUMENT - if the palette or data is null</li> |
294 * <li>ERROR_CANNOT_BE_ZERO - if the scanlinePad is zero</li> | 294 * <li>ERROR_CANNOT_BE_ZERO - if the scanlinePad is zero</li> |
295 * </ul> | 295 * </ul> |
296 */ | 296 */ |
297 public this(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data) { | 297 public this(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data) { |
442 } | 442 } |
443 if (scanlinePad is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); | 443 if (scanlinePad is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); |
444 | 444 |
445 int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1)) | 445 int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1)) |
446 / scanlinePad * scanlinePad; | 446 / scanlinePad * scanlinePad; |
447 | |
448 /* | |
449 * When the image is being loaded from a PNG, we need to use the theoretical minimum | |
450 * number of bytes per line to check whether there is enough data, because the actual | |
451 * number of bytes per line is calculated based on the given depth, which may be larger | |
452 * than the actual depth of the PNG. | |
453 */ | |
454 int minBytesPerLine = type is DWT.IMAGE_PNG ? ((((width + 7) / 8) + 3) / 4) * 4 : bytesPerLine; | |
455 if (data !is null && data.length < minBytesPerLine * height) { | |
456 DWT.error(DWT.ERROR_INVALID_ARGUMENT); | |
457 } | |
447 setAllFields( | 458 setAllFields( |
448 width, | 459 width, |
449 height, | 460 height, |
450 depth, | 461 depth, |
451 scanlinePad, | 462 scanlinePad, |