VKD*_*Dev 13 c++ android bitmap android-ndk
我想实现Hue /颜色/饱和度颜色叠加.我看到了宏:
#define ColorBlend_Saturation(T,A,B) ColorBlend_Hls(T,A,B,HueA,LuminationA,SaturationB)
Run Code Online (Sandbox Code Playgroud)
我试图在Adobe Photoshop中使用颜色重现它#332244并#557711获得结果颜色 - #431076.然而,应用这些宏后,我得到了颜色 - #320C59结果.
问题1:如何重现色情,饱和度和颜色的photoshop算法?
问题2:如何调整alpha通道?例如,在我的颜色和光学== 50,这应该在Photoshop - #3b195d
问题1:
\n\n\n\n\nPhotoshop\xe2\x80\x99 的色调、饱和度、颜色和亮度混合模式基于具有维度的颜色空间,HSL 和 HSV 文章将其称为色调、色度和亮度。请注意,这个空间与 HSL 和 HSV 都不同,三者之间仅共享色调维度;有关详细信息,请参阅该文章。
\n\n色相混合模式保留底层的亮度和色度,同时采用顶层的色相。
\n\n饱和度混合模式保留底层的亮度和色调,同时采用顶层的色度。
\n\n颜色混合模式保留底层的亮度,同时采用顶层的色调和色度。
\n\n \n
经过 3 个多小时的实验,我成功将 HSV -> RGB 转换器升级为工作饱和度混合器。其他混合模式应该类似。
\n\n这是代码:
\n\n#include <cmath>\n#include <iostream>\n\nusing namespace std;\n\nstruct HSVColor\n{\n float H,S,V;\n};\n\nstruct RGBColor\n{\n float R,G,B;\n RGBColor() = default;\n RGBColor(int r,int g, int b):\n R(r/255.0),\n G(g/255.0),\n B(b/255.0)\n {\n }\n};\n\nHSVColor RGBToHSV(const RGBColor& RGB)\n{\n float Max;\n float Min;\n float Chroma;\n HSVColor HSV;\n\n Min = min(min(RGB.R, RGB.G), RGB.B);\n Max = max(max(RGB.R, RGB.G), RGB.B);\n Chroma = Max - Min;\n\n //If Chroma is 0, then S is 0 by definition, and H is undefined but 0 by convention.\n if(Chroma != 0)\n {\n if(RGB.R == Max)\n {\n HSV.H = (RGB.G - RGB.B) / Chroma;\n\n if(HSV.H < 0.0)\n {\n HSV.H += 6.0;\n }\n }\n else if(RGB.G == Max)\n {\n HSV.H = ((RGB.B - RGB.R) / Chroma) + 2.0;\n }\n else //RGB.B == Max\n {\n HSV.H = ((RGB.R - RGB.G) / Chroma) + 4.0;\n }\n\n HSV.H *= 60.0;\n HSV.S = Chroma / Max;\n }\n\n HSV.V = Max;\n\n return HSV;\n}\n\nRGBColor Saturate(const HSVColor& HSV,const HSVColor& overlay)\n{\n float os = overlay.S;\n float ov = overlay.V;\n\n float Min;\n float Chroma;\n float Hdash;\n float X;\n RGBColor RGB{0,0,0};\n\n Chroma = os * ov; // Orginal was HSV.S * HSV.V\n Hdash = HSV.H / 60.0;\n X = Chroma * (1.0 - abs(fmod(Hdash , 2.0) - 1.0));\n\n if(Hdash < 1.0)\n {\n RGB.R = Chroma;\n RGB.G = X;\n }\n else if(Hdash < 2.0)\n {\n RGB.R = X;\n RGB.G = Chroma;\n }\n else if(Hdash < 3.0)\n {\n RGB.G = Chroma;\n RGB.B = X;\n }\n else if(Hdash < 4.0)\n {\n RGB.G= X;\n RGB.B = Chroma;\n }\n else if(Hdash < 5.0)\n {\n RGB.R = X;\n RGB.B = Chroma;\n }\n else if(Hdash <= 6.0)\n {\n RGB.R = Chroma;\n RGB.B = X;\n }\n\n Min = ov - Chroma; // Orginal was HSV.V - Chroma\n\n RGB.R += Min;\n RGB.G += Min;\n RGB.B += Min;\n\n return RGB;\n}\n\nint main(){\n RGBColor base{51, 34, 68};\n RGBColor overly{85, 119, 17};\n\n RGBColor r = Saturate(RGBToHSV(base),RGBToHSV(overly));\n\n cout << int(r.R*255) << endl;\n cout << int(r.G*255) << endl;\n cout << int(r.B*255) << endl;\n}\nRun Code Online (Sandbox Code Playgroud)\n\n原始 HSV <-> RGB 转换器代码位于: http: //wiki.beyondunreal.com/HSV-RGB_Conversion
\n\n问题2。
\n\n有了饱和度,这实际上很容易,在饱和度混合之后,在 RGB 颜色空间中使用正常的 alpha 混合。
\n\nRGBColor base;\nRGBColor overly; \nRGBColor saturated = Saturate(base,overly);\nRGBColor result = AlphaBlend(base,saturated,overly.alpha);\nRun Code Online (Sandbox Code Playgroud)\n\n注意:这可能不适用于其他混合模式。
\n| 归档时间: |
|
| 查看次数: |
817 次 |
| 最近记录: |