From 094960e38676ef82c8e7e69e2b4be16dac2d5aa3 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Tue, 31 Dec 2019 11:34:28 +0900 Subject: [PATCH] [SDK][INCLUDE] Implement Gdiplus::ImageAttributes (#2202) CORE-16585 --- sdk/include/psdk/gdiplusimageattributes.h | 171 +++++++++++++++------- 1 file changed, 115 insertions(+), 56 deletions(-) diff --git a/sdk/include/psdk/gdiplusimageattributes.h b/sdk/include/psdk/gdiplusimageattributes.h index 61e07d4b3d1..e68e1908558 100644 --- a/sdk/include/psdk/gdiplusimageattributes.h +++ b/sdk/include/psdk/gdiplusimageattributes.h @@ -22,166 +22,225 @@ class ImageAttributes : public GdiplusBase { public: - ImageAttributes(VOID) + ImageAttributes() : nativeImageAttr(NULL) { + lastStatus = DllExports::GdipCreateImageAttributes(&nativeImageAttr); } - Status ClearBrushRemapTable(VOID) + ~ImageAttributes() { - return NotImplemented; + DllExports::GdipDisposeImageAttributes(nativeImageAttr); } Status - ClearColorKey(ColorAdjustType type) + ClearBrushRemapTable() { - return NotImplemented; + return ClearRemapTable(ColorAdjustTypeBrush); } Status - ClearColorMatrices(ColorAdjustType type) + ClearColorKey(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesColorKeys(nativeImageAttr, type, FALSE, NULL, NULL)); } Status - ClearColorMatrix(ColorAdjustType type) + ClearColorMatrices(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesColorMatrix( + nativeImageAttr, type, FALSE, NULL, NULL, ColorMatrixFlagsDefault)); } Status - ClearGamma(ColorAdjustType type) + ClearColorMatrix(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesColorMatrix( + nativeImageAttr, type, FALSE, NULL, NULL, ColorMatrixFlagsDefault)); } Status - ClearNoOp(ColorAdjustType type) + ClearGamma(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesGamma(nativeImageAttr, type, FALSE, 0.0)); } Status - ClearOutputChannel(ColorAdjustType type) + ClearNoOp(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesNoOp(nativeImageAttr, type, FALSE)); } Status - ClearOutputChannelColorProfile(ColorAdjustType type) + ClearOutputChannel(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus( + DllExports::GdipSetImageAttributesOutputChannel(nativeImageAttr, type, FALSE, ColorChannelFlagsLast)); } Status - ClearRemapTable(ColorAdjustType type) + ClearOutputChannelColorProfile(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus( + DllExports::GdipSetImageAttributesOutputChannelColorProfile(nativeImageAttr, type, FALSE, NULL)); } Status - ClearThreshold(ColorAdjustType type) + ClearRemapTable(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; - } - - ImageAttributes *Clone(VOID) - { - return NULL; + return SetStatus(DllExports::GdipSetImageAttributesRemapTable(nativeImageAttr, type, FALSE, 0, NULL)); } Status - GetAdjustedPalette(ColorPalette *colorPalette, ColorPalette colorAdjustType) + ClearThreshold(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesThreshold(nativeImageAttr, type, FALSE, 0.0)); } - Status GetLastStatus(VOID) + ImageAttributes * + Clone() { - return NotImplemented; + GpImageAttributes *clone = NULL; + SetStatus(DllExports::GdipCloneImageAttributes(nativeImageAttr, &clone)); + if (lastStatus != Ok) + return NULL; + + ImageAttributes *newImageAttr = new ImageAttributes(clone, lastStatus); + if (newImageAttr == NULL) + SetStatus(DllExports::GdipDisposeImageAttributes(clone)); + + return newImageAttr; } Status - Reset(ColorAdjustType type) + GetAdjustedPalette(ColorPalette *colorPalette, ColorAdjustType colorAdjustType) { - return NotImplemented; + return SetStatus( + DllExports::GdipGetImageAttributesAdjustedPalette(nativeImageAttr, colorPalette, colorAdjustType)); + } + + Status + GetLastStatus() + { + return lastStatus; + } + + Status + Reset(ColorAdjustType type = ColorAdjustTypeDefault) + { + return SetStatus(DllExports::GdipResetImageAttributes(nativeImageAttr, type)); } Status SetBrushRemapTable(UINT mapSize, ColorMap *map) { - return NotImplemented; + return SetRemapTable(mapSize, map, ColorAdjustTypeBrush); } Status - SetColorKey(const Color &colorLow, const Color &colorHigh, ColorAdjustType type) + SetColorKey(const Color &colorLow, const Color &colorHigh, ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesColorKeys( + nativeImageAttr, type, TRUE, colorLow.GetValue(), colorHigh.GetValue())); } Status SetColorMatrices( const ColorMatrix *colorMatrix, const ColorMatrix *grayMatrix, - ColorMatrixFlags mode, - ColorAdjustType type) + ColorMatrixFlags mode = ColorMatrixFlagsDefault, + ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus( + DllExports::GdipSetImageAttributesColorMatrix(nativeImageAttr, type, TRUE, colorMatrix, grayMatrix, mode)); } Status - SetColorMatrix(const ColorMatrix *colorMatrix, ColorMatrixFlags mode, ColorAdjustType type) + SetColorMatrix( + const ColorMatrix *colorMatrix, + ColorMatrixFlags mode = ColorMatrixFlagsDefault, + ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus( + DllExports::GdipSetImageAttributesColorMatrix(nativeImageAttr, type, TRUE, colorMatrix, NULL, mode)); } Status - SetGamma(REAL gamma, ColorAdjustType type) + SetGamma(REAL gamma, ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesGamma(nativeImageAttr, type, TRUE, gamma)); } Status - SetNoOp(ColorAdjustType type) + SetNoOp(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesNoOp(nativeImageAttr, type, TRUE)); } Status - SetOutputChannel(ColorChannelFlags channelFlags, ColorAdjustType type) + SetOutputChannel(ColorChannelFlags channelFlags, ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesOutputChannel(nativeImageAttr, type, TRUE, channelFlags)); } Status - SetOutputChannelColorProfile(const WCHAR *colorProfileFilename, ColorAdjustType type) + SetOutputChannelColorProfile(const WCHAR *colorProfileFilename, ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile( + nativeImageAttr, type, TRUE, colorProfileFilename)); } Status - SetRemapTable(UINT mapSize, const ColorMap *map, ColorAdjustType type) + SetRemapTable(UINT mapSize, const ColorMap *map, ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesRemapTable(nativeImageAttr, type, TRUE, mapSize, map)); } Status - SetThreshold(REAL threshold, ColorAdjustType type) + SetThreshold(REAL threshold, ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesThreshold(nativeImageAttr, type, TRUE, threshold)); } Status - SetToIdentity(ColorAdjustType type) + SetToIdentity(ColorAdjustType type = ColorAdjustTypeDefault) { - return NotImplemented; + return SetStatus(DllExports::GdipSetImageAttributesToIdentity(nativeImageAttr, type)); } Status - SetWrapMode(WrapMode wrap, const Color &color, BOOL clamp) + SetWrapMode(WrapMode wrap, const Color &color = Color(), BOOL clamp = FALSE) { - return NotImplemented; + ARGB argb = color.GetValue(); + return SetStatus(DllExports::GdipSetImageAttributesWrapMode(nativeImageAttr, wrap, argb, clamp)); } + + protected: + GpImageAttributes *nativeImageAttr; + mutable Status lastStatus; + + ImageAttributes(GpImageAttributes *imageAttr, Status status) : nativeImageAttr(imageAttr), lastStatus(status) + { + } + + VOID + SetNativeImageAttr(GpImageAttributes *imageAttr) + { + nativeImageAttr = imageAttr; + } + + Status + SetStatus(Status status) const + { + if (status != Ok) + lastStatus = status; + return status; + } + + private: + // ImageAttributes is not copyable + ImageAttributes(const ImageAttributes &); + ImageAttributes & + operator=(const ImageAttributes &); }; #endif /* _GDIPLUSIMAGEATTRIBUTES_H */