diff options
| author | Mike Wey | 2011-02-12 23:03:21 +0100 |
|---|---|---|
| committer | Mike Wey | 2011-02-12 23:03:21 +0100 |
| commit | 2fb8dd6619325608157819478edfe4b3b2a1dc0d (patch) | |
| tree | 17955b4f935a966b806ec77354b22b0fe4b3b6dc /dmagick/Color.d | |
| parent | b5fc681a9af594c3d872199393ae065d37e4faf7 (diff) | |
Sore a pointer to the PixelPacket so we can use color to change pixels in an image
Diffstat (limited to 'dmagick/Color.d')
| -rw-r--r-- | dmagick/Color.d | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/dmagick/Color.d b/dmagick/Color.d index f428f95..144b828 100644 --- a/dmagick/Color.d +++ b/dmagick/Color.d @@ -1,5 +1,5 @@ /** - * The image + * A container for the pixel values: red, green, blue and opacity. * * Copyright: Mike Wey 2011 * License: To be determined @@ -20,10 +20,12 @@ import dmagick.c.magickType; class Color { - PixelPacket pixelPacket; + PixelPacket* pixelPacket; this() { + pixelPacket = new PixelPacket; + pixelPacket.opacity = TransparentOpacity; } @@ -49,7 +51,7 @@ class Color ExceptionInfo* exception = AcquireExceptionInfo(); const(char)* name = toStringz(color); - QueryColorDatabase(name, &pixelPacket, exception); + QueryColorDatabase(name, pixelPacket, exception); DMagickException.throwException(exception); DestroyExceptionInfo(exception); @@ -57,12 +59,22 @@ class Color this(PixelPacket packet) { + this(); + + pixelPacket.red = packet.red; + pixelPacket.green = packet.green; + pixelPacket.blue = packet.blue; + pixelPacket.opacity = packet.opacity; + } + + this(PixelPacket* packet) + { pixelPacket = packet; } bool opEquals(Color color) { - return pixelPacket == color.pixelPacket; + return *pixelPacket == *(color.pixelPacket); } override string toString() @@ -74,6 +86,6 @@ class Color Color clone() { - return new Color(pixelPacket); + return new Color(*pixelPacket); } } |
