From 2fb8dd6619325608157819478edfe4b3b2a1dc0d Mon Sep 17 00:00:00 2001 From: Mike Wey Date: Sat, 12 Feb 2011 23:03:21 +0100 Subject: Sore a pointer to the PixelPacket so we can use color to change pixels in an image --- dmagick/Color.d | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'dmagick') 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,20 +51,30 @@ class Color ExceptionInfo* exception = AcquireExceptionInfo(); const(char)* name = toStringz(color); - QueryColorDatabase(name, &pixelPacket, exception); + QueryColorDatabase(name, pixelPacket, exception); DMagickException.throwException(exception); DestroyExceptionInfo(exception); } 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); } } -- cgit v1.2.3