Mercurial > projects > dwt-win
comparison dwt/graphics/Image.d @ 197:184ab53b7785
Changes and fixes for jface
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 10 Apr 2008 11:19:49 +0200 |
parents | 25f88bf5a6df |
children | ab60f3309436 |
comparison
equal
deleted
inserted
replaced
196:1e7701c27c03 | 197:184ab53b7785 |
---|---|
190 * </ul> | 190 * </ul> |
191 */ | 191 */ |
192 public this(Device device, int width, int height) { | 192 public this(Device device, int width, int height) { |
193 if (device is null) device = Device.getDevice(); | 193 if (device is null) device = Device.getDevice(); |
194 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 194 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
195 init(device, width, height); | 195 init_(device, width, height); |
196 if (device.tracking) device.new_Object(this); | 196 if (device.tracking) device.new_Object(this); |
197 } | 197 } |
198 | 198 |
199 /** | 199 /** |
200 * Constructs a new instance of this class based on the | 200 * Constructs a new instance of this class based on the |
267 System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length); | 267 System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length); |
268 } | 268 } |
269 break; | 269 break; |
270 case DWT.ICON: | 270 case DWT.ICON: |
271 static if (OS.IsWinCE) { | 271 static if (OS.IsWinCE) { |
272 init(device, srcImage.data); | 272 init_(device, srcImage.data); |
273 } else { | 273 } else { |
274 handle = OS.CopyImage(srcImage.handle, OS.IMAGE_ICON, rect.width, rect.height, 0); | 274 handle = OS.CopyImage(srcImage.handle, OS.IMAGE_ICON, rect.width, rect.height, 0); |
275 if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); | 275 if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); |
276 } | 276 } |
277 break; | 277 break; |
335 } | 335 } |
336 } | 336 } |
337 offset++; | 337 offset++; |
338 } | 338 } |
339 } | 339 } |
340 init (device, newData); | 340 init_ (device, newData); |
341 if (device.tracking) device.new_Object(this); | 341 if (device.tracking) device.new_Object(this); |
342 return; | 342 return; |
343 } | 343 } |
344 case DWT.IMAGE_GRAY: { | 344 case DWT.IMAGE_GRAY: { |
345 ImageData data = srcImage.getImageData(); | 345 ImageData data = srcImage.getImageData(); |
400 } | 400 } |
401 offset++; | 401 offset++; |
402 } | 402 } |
403 } | 403 } |
404 } | 404 } |
405 init (device, newData); | 405 init_ (device, newData); |
406 if (device.tracking) device.new_Object(this); | 406 if (device.tracking) device.new_Object(this); |
407 return; | 407 return; |
408 } | 408 } |
409 default: | 409 default: |
410 DWT.error(DWT.ERROR_INVALID_ARGUMENT); | 410 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
443 */ | 443 */ |
444 public this(Device device, Rectangle bounds) { | 444 public this(Device device, Rectangle bounds) { |
445 if (device is null) device = Device.getDevice(); | 445 if (device is null) device = Device.getDevice(); |
446 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 446 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
447 if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 447 if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
448 init(device, bounds.width, bounds.height); | 448 init_(device, bounds.width, bounds.height); |
449 if (device.tracking) device.new_Object(this); | 449 if (device.tracking) device.new_Object(this); |
450 } | 450 } |
451 | 451 |
452 /** | 452 /** |
453 * Constructs an instance of this class from the given | 453 * Constructs an instance of this class from the given |
468 * </ul> | 468 * </ul> |
469 */ | 469 */ |
470 public this(Device device, ImageData data) { | 470 public this(Device device, ImageData data) { |
471 if (device is null) device = Device.getDevice(); | 471 if (device is null) device = Device.getDevice(); |
472 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 472 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
473 init(device, data); | 473 init_(device, data); |
474 if (device.tracking) device.new_Object(this); | 474 if (device.tracking) device.new_Object(this); |
475 } | 475 } |
476 | 476 |
477 /** | 477 /** |
478 * Constructs an instance of this class, whose type is | 478 * Constructs an instance of this class, whose type is |
506 if (mask is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 506 if (mask is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
507 if (source.width !is mask.width || source.height !is mask.height) { | 507 if (source.width !is mask.width || source.height !is mask.height) { |
508 DWT.error(DWT.ERROR_INVALID_ARGUMENT); | 508 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
509 } | 509 } |
510 mask = ImageData.convertMask(mask); | 510 mask = ImageData.convertMask(mask); |
511 init(device, this, source, mask); | 511 init_(device, this, source, mask); |
512 if (device.tracking) device.new_Object(this); | 512 if (device.tracking) device.new_Object(this); |
513 } | 513 } |
514 | 514 |
515 /** | 515 /** |
516 * Constructs an instance of this class by loading its representation | 516 * Constructs an instance of this class by loading its representation |
561 * </ul> | 561 * </ul> |
562 */ | 562 */ |
563 public this (Device device, InputStream stream) { | 563 public this (Device device, InputStream stream) { |
564 if (device is null) device = Device.getDevice(); | 564 if (device is null) device = Device.getDevice(); |
565 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 565 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
566 init(device, new ImageData(stream)); | 566 init_(device, new ImageData(stream)); |
567 if (device.tracking) device.new_Object(this); | 567 if (device.tracking) device.new_Object(this); |
568 } | 568 } |
569 | 569 |
570 /** | 570 /** |
571 * Constructs an instance of this class by loading its representation | 571 * Constructs an instance of this class by loading its representation |
739 Gdip.Bitmap_UnlockBits(bitmap, lockedBitmapData); | 739 Gdip.Bitmap_UnlockBits(bitmap, lockedBitmapData); |
740 Gdip.BitmapData_delete(lockedBitmapData); | 740 Gdip.BitmapData_delete(lockedBitmapData); |
741 ImageData img = new ImageData(width, height, depth, paletteData, scanlinePad, data); | 741 ImageData img = new ImageData(width, height, depth, paletteData, scanlinePad, data); |
742 img.transparentPixel = transparentPixel; | 742 img.transparentPixel = transparentPixel; |
743 img.alphaData = alphaData; | 743 img.alphaData = alphaData; |
744 init(device, img); | 744 init_(device, img); |
745 } | 745 } |
746 } | 746 } |
747 } | 747 } |
748 } | 748 } |
749 } | 749 } |
752 if (this.handle is null) DWT.error(error); | 752 if (this.handle is null) DWT.error(error); |
753 return; | 753 return; |
754 } | 754 } |
755 } | 755 } |
756 } catch (DWTException e) {} | 756 } catch (DWTException e) {} |
757 init(device, new ImageData(filename)); | 757 init_(device, new ImageData(filename)); |
758 if(device.tracking) device.new_Object(this); | 758 if(device.tracking) device.new_Object(this); |
759 } | 759 } |
760 | 760 |
761 /** | 761 /** |
762 * Create a DIB from a DDB without using GetDIBits. Note that | 762 * Create a DIB from a DDB without using GetDIBits. Note that |
1577 */ | 1577 */ |
1578 override public hash_t toHash () { | 1578 override public hash_t toHash () { |
1579 return cast(hash_t)handle; | 1579 return cast(hash_t)handle; |
1580 } | 1580 } |
1581 | 1581 |
1582 void init(Device device, int width, int height) { | 1582 void init_(Device device, int width, int height) { |
1583 if (width <= 0 || height <= 0) { | 1583 if (width <= 0 || height <= 0) { |
1584 DWT.error (DWT.ERROR_INVALID_ARGUMENT); | 1584 DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
1585 } | 1585 } |
1586 this.device = device; | 1586 this.device = device; |
1587 type = DWT.BITMAP; | 1587 type = DWT.BITMAP; |
1658 * created. | 1658 * created. |
1659 * Note. These bitmaps must be freed - as they would have to be | 1659 * Note. These bitmaps must be freed - as they would have to be |
1660 * if the regular GetIconInfo had been used. | 1660 * if the regular GetIconInfo had been used. |
1661 */ | 1661 */ |
1662 static void GetIconInfo(Image image, ICONINFO* info) { | 1662 static void GetIconInfo(Image image, ICONINFO* info) { |
1663 int[] result = init(image.device, null, image.data); | 1663 int[] result = init_(image.device, null, image.data); |
1664 info.hbmColor = cast(HBITMAP)result[0]; | 1664 info.hbmColor = cast(HBITMAP)result[0]; |
1665 info.hbmMask = cast(HBITMAP)result[1]; | 1665 info.hbmMask = cast(HBITMAP)result[1]; |
1666 } | 1666 } |
1667 | 1667 |
1668 static int[] init(Device device, Image image, ImageData i) { | 1668 static int[] init_(Device device, Image image, ImageData i) { |
1669 if (image !is null) image.device = device; | 1669 if (image !is null) image.device = device; |
1670 | 1670 |
1671 /* | 1671 /* |
1672 * BUG in Windows 98: | 1672 * BUG in Windows 98: |
1673 * A monochrome DIBSection will display as solid black | 1673 * A monochrome DIBSection will display as solid black |
1894 } | 1894 } |
1895 } | 1895 } |
1896 return result; | 1896 return result; |
1897 } | 1897 } |
1898 | 1898 |
1899 static int[] init(Device device, Image image, ImageData source, ImageData mask) { | 1899 static int[] init_(Device device, Image image, ImageData source, ImageData mask) { |
1900 /* Create a temporary image and locate the black pixel */ | 1900 /* Create a temporary image and locate the black pixel */ |
1901 ImageData imageData; | 1901 ImageData imageData; |
1902 int blackIndex = 0; | 1902 int blackIndex = 0; |
1903 if (source.palette.isDirect) { | 1903 if (source.palette.isDirect) { |
1904 imageData = new ImageData(source.width, source.height, source.depth, source.palette); | 1904 imageData = new ImageData(source.width, source.height, source.depth, source.palette); |
1965 imageData.setPixels(0, y, source.width, imagePixels, 0); | 1965 imageData.setPixels(0, y, source.width, imagePixels, 0); |
1966 } | 1966 } |
1967 } | 1967 } |
1968 imageData.maskPad = mask.scanlinePad; | 1968 imageData.maskPad = mask.scanlinePad; |
1969 imageData.maskData = mask.data; | 1969 imageData.maskData = mask.data; |
1970 return init(device, image, imageData); | 1970 return init_(device, image, imageData); |
1971 } | 1971 } |
1972 void init(Device device, ImageData i) { | 1972 void init_(Device device, ImageData i) { |
1973 if (i is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 1973 if (i is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
1974 init(device, this, i); | 1974 init_(device, this, i); |
1975 } | 1975 } |
1976 | 1976 |
1977 /** | 1977 /** |
1978 * Invokes platform specific functionality to allocate a new GC handle. | 1978 * Invokes platform specific functionality to allocate a new GC handle. |
1979 * <p> | 1979 * <p> |