[GDIPLUS]
[reactos.git] / reactos / dll / win32 / gdiplus / imageattributes.c
index 8f49c67..1a7118d 100644 (file)
@@ -30,26 +30,31 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
 GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr,
     GpImageAttributes **cloneImageattr)
 {
+    GpStatus stat;
+
     TRACE("(%p, %p)\n", imageattr, cloneImageattr);
 
     if(!imageattr || !cloneImageattr)
         return InvalidParameter;
 
-    **cloneImageattr = *imageattr;
+    stat = GdipCreateImageAttributes(cloneImageattr);
 
-    return Ok;
+    if (stat == Ok)
+        **cloneImageattr = *imageattr;
+
+    return stat;
 }
 
 GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
 {
-    TRACE("(%p)\n", imageattr);
-
     if(!imageattr)
         return InvalidParameter;
 
     *imageattr = GdipAlloc(sizeof(GpImageAttributes));
     if(!*imageattr)    return OutOfMemory;
 
+    TRACE("<-- %p\n", *imageattr);
+
     return Ok;
 }
 
@@ -84,15 +89,32 @@ GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageat
     ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix,
     GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags)
 {
-    static int calls;
+    TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix,
+        grayMatrix, flags);
 
-    if(!imageattr || !colorMatrix || !grayMatrix)
+    if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray)
         return InvalidParameter;
 
-    if(!(calls++))
-        FIXME("not implemented\n");
+    if (enableFlag)
+    {
+        if (!colorMatrix)
+            return InvalidParameter;
 
-    return NotImplemented;
+        if (flags == ColorMatrixFlagsAltGray)
+        {
+            if (!grayMatrix)
+                return InvalidParameter;
+
+            imageattr->colormatrices[type].graymatrix = *grayMatrix;
+        }
+
+        imageattr->colormatrices[type].colormatrix = *colorMatrix;
+        imageattr->colormatrices[type].flags = flags;
+    }
+
+    imageattr->colormatrices[type].enabled = enableFlag;
+
+    return Ok;
 }
 
 GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr,
@@ -100,6 +122,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr,
 {
     static int calls;
 
+    TRACE("(%p,%u,%08x,%i)\n", imageAttr, wrap, argb, clamp);
+
     if(!imageAttr)
         return InvalidParameter;
 
@@ -114,6 +138,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *im
 {
     static int calls;
 
+    TRACE("(%p,%i)\n", imageAttr, enableFlag);
+
     if(!(calls++))
         FIXME("not implemented\n");
 
@@ -123,12 +149,15 @@ GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *im
 GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr,
     ColorAdjustType type, BOOL enableFlag, REAL gamma)
 {
-    static int calls;
+    TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
 
-    if(!(calls++))
-        FIXME("not implemented\n");
+    if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount)
+        return InvalidParameter;
 
-    return NotImplemented;
+    imageAttr->gamma_enabled[type] = enableFlag;
+    imageAttr->gamma[type] = gamma;
+
+    return Ok;
 }
 
 GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr,
@@ -136,6 +165,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr,
 {
     static int calls;
 
+    TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
+
     if(!(calls++))
         FIXME("not implemented\n");
 
@@ -147,6 +178,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *image
 {
     static int calls;
 
+    TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags);
+
     if(!(calls++))
         FIXME("not implemented\n");
 
@@ -159,6 +192,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannelColorProfile(GpImageAttri
 {
     static int calls;
 
+    TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename));
+
     if(!(calls++))
         FIXME("not implemented\n");
 
@@ -169,12 +204,23 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt
     ColorAdjustType type, BOOL enableFlag, UINT mapSize,
     GDIPCONST ColorMap *map)
 {
-    static int calls;
+    TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
 
-    if(!(calls++))
-        FIXME("not implemented\n");
+    if(!imageAttr || type >= ColorAdjustTypeCount)
+       return InvalidParameter;
 
-    return NotImplemented;
+    if (enableFlag)
+    {
+        if(!map || !mapSize)
+           return InvalidParameter;
+
+        imageAttr->colorremaptables[type].mapsize = mapSize;
+        imageAttr->colorremaptables[type].colormap = map;
+    }
+
+    imageAttr->colorremaptables[type].enabled = enableFlag;
+
+    return Ok;
 }
 
 GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr,
@@ -182,6 +228,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr
 {
     static int calls;
 
+    TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold);
+
     if(!(calls++))
         FIXME("not implemented\n");
 
@@ -193,6 +241,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAtt
 {
     static int calls;
 
+    TRACE("(%p,%u)\n", imageAttr, type);
+
     if(!(calls++))
         FIXME("not implemented\n");