{"id":423,"date":"2014-06-15T23:58:49","date_gmt":"2014-06-15T15:58:49","guid":{"rendered":"http:\/\/blog.mega-zone.org\/?p=423"},"modified":"2014-06-16T00:19:35","modified_gmt":"2014-06-15T16:19:35","slug":"photoshop%e4%b8%ad%e7%9a%84multiply-blend-mode","status":"publish","type":"post","link":"https:\/\/blog.mega-zone.org\/?p=423","title":{"rendered":"Photoshop\u4e2d\u7684Multiply Blend Mode"},"content":{"rendered":"<p>Multiply\u662fPS\u4e2d\u5e38\u7528\u7684\u4e00\u79cd\u6df7\u5408\u65b9\u5f0f\uff0c\u4e2d\u6587\u7248\u79f0\u4e3a\u201c\u6b63\u7247\u53e0\u5e95\u201d\u6a21\u5f0f\u3002<br \/>\n\u8bf4\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff0c\u5c31\u662f\u989c\u8272\u5206\u91cf\u76f8\u4e58\u3002\u4f46\u5b9e\u9645\u4e0a\u7b80\u5355\u7684\u76f8\u4e58\u5e76\u6ca1\u6709\u8003\u8651\u5230alpha channel\u3002<br \/>\n\u5982\u679c\u4e24\u4e2a\u56fe\u5c42\u90fd\u662fRGBA\u56db\u4e2a\u901a\u9053\uff0cMultiply\u7684\u7b97\u6cd5\u8fd8\u5f97\u52a0\u5165alpha\u3002<\/p>\n<p>\u4e3a\u4e86\u641e\u6e05\u695a\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u7422\u78e8\u4e86\u597d\u51e0\u4e2a\u5c0f\u65f6\u3002\u6700\u540e\u4ece\u989c\u8272\u542b\u4e49\u5165\u624b\uff0c\u914d\u5408\u4e00\u4e9b\u6d4b\u8bd5\u7ed3\u679c\uff0c\u7ec8\u4e8e\u63a8\u51fa\u4e86PS\u7684\u6df7\u5408\u516c\u5f0f\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nOutAlpha = A1 + A2 - A1*A2\r\nOutColor = (1.0 - (1.0 - C1)*A1) * (1.0 - (1.0 - C2)*A2)\r\n<\/pre>\n<p>\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2a\u516c\u5f0f\u5bf9\u4e8eA1\u548cA2\u662f\u5bf9\u79f0\u7684\uff0c\u6240\u4ee5\u88ab\u6df7\u5408\u7684\u4e24\u4e2a\u56fe\u5c42\u6ca1\u6709\u524d\u540e\u4e4b\u5206\u3002<\/p>\n<p>\u63a8\u7406\u8fc7\u7a0b\u5982\u4e0b\uff1aMultiply\u6df7\u5408\u53ef\u4ee5\u770b\u4f5c\u662f\u4e24\u5f20\u5e7b\u706f\u7247\u53e0\u5728\u4e00\u8d77\uff0c\u56e0\u4e3a\u53d8\u5f97\u66f4\u539a\u6240\u4ee5\u900f\u8fc7\u7684\u989c\u8272\u53d8\u5c11\uff0c\u4ece\u800c\u8fbe\u5230\u51cf\u8272\u6548\u679c\u3002\u5728\u8fd9\u91cc\u989c\u8272\u5206\u91cfColor\u662f\u5149\u53ef\u4ee5\u900f\u8fc7\u7684\u7a0b\u5ea6\uff0c1.0\u5373\u8868\u793a\u8be5\u989c\u8272\u5206\u91cf\u5168\u90e8\u53ef\u4ee5\u900f\u8fc7\u30021.0-Color\u8868\u793a\u88ab\u5438\u6536\u6389\u7684\u90e8\u5206\u3002\u5728PS\u7684\u6df7\u5408\u7b97\u6cd5\u4e2d\uff0cAlpha\u7528\u6765\u8c03\u8282\u5438\u6536\u7a0b\u5ea6\u3002\u56e0\u4e3aAlpha\u7ecf\u5e38\u7528\u4e8e\u8868\u793a\u900f\u660e\u5ea6\uff0c1.0\u8868\u793a\u5b8c\u5168\u4e0d\u900f\u660e\uff0c\u5373\u5438\u6536\u7a0b\u5ea6\u4e3a100%\u3002<\/p>\n<p>\u7ed3\u5408\u4ee5\u4e0a\u4e24\u4e2a\u5b9a\u4e49\uff1a<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n(1.0 - Color) * Alpha \/\/ \u8868\u793a\u88ab\u5438\u6536\u7684\u989c\u8272\r\n1.0 - (1.0 - Color) * Alpha \/\/ \u8868\u793a\u6700\u7ec8\u900f\u8fc7\u7684\u989c\u8272\r\n<\/pre>\n<p>\u628a\u4e24\u4e2a\u6700\u7ec8\u900f\u8fc7\u7684\u989c\u8272\u76f8\u4e58\uff0c\u5373\u5f97\u5230\u6211\u4eec\u9700\u8981\u7684\u6700\u7ec8\u51cf\u8272\u7ed3\u679c\u3002<\/p>\n<p>\u5728\u5ffd\u7565Alpha\u53ea\u6709RGB\u6df7\u5408\u7684\u60c5\u51b5\u4e0b\uff0cAlpha\u90fd\u53d61.0\uff0c\u5219\u516c\u5f0f\u53ef\u4ee5\u5316\u7b80\u4e3a\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">OutAlpha = 1.0\r\nOutColor = C1 * C2<\/pre>\n<p>\u7ed3\u679c\u4e3a\u989c\u8272\u5206\u91cf\u76f4\u63a5\u76f8\u4e58\uff0c\u4e5f\u5c31\u662f\u5230\u5904\u90fd\u53ef\u4ee5\u627e\u5230\u7684\u5bf9Multiply\u7684\u7b97\u6cd5\u7684\u63cf\u8ff0\u3002<\/p>\n<p>\u4ee5\u4e0b\u662fc#\u7248\u7684\u5b9e\u73b0\u2026\u2026<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nstatic byte Clamp(int result)\r\n{\r\n    if (result &lt; 0)\r\n        return (byte)0;\r\n    \r\n    return result &gt; 255 ? (byte)255 : (byte)result;\r\n}\r\n\r\nstatic byte MultiplyColor(int lhs, int rhs, int lhsAlpha, int rhsAlpha)\r\n{\r\n    if (lhsAlpha == 0)\r\n        return Clamp(rhs);\r\n    else if (rhsAlpha == 0)\r\n        return Clamp(lhs);\r\n\r\n    int lhsMultiply = (255 - (255 - lhs) * lhsAlpha \/ 255);\r\n    int rhsMultiply = (255 - (255 - rhs) * rhsAlpha \/ 255);\r\n    int result = rhsMultiply * lhsMultiply \/ 255;\r\n    return Clamp(result);\r\n}\r\n\r\n\/\/ same as Photoshop multiply blend mode\r\nstatic public void Multiply(Bitmap lhs, Bitmap rhs, Rectangle roi)\r\n{\r\n    BitmapData lhsData = SetImageToProcess(lhs, roi);\r\n    BitmapData rhsData = SetImageToProcess(rhs, roi);\r\n\r\n    int width = lhsData.Width;\r\n    int height = lhsData.Height;\r\n    int offset = lhsData.Stride;\r\n\r\n    unsafe\r\n    {\r\n        byte* lhsPtr = (byte*)lhsData.Scan0;\r\n        byte* rhsPtr = (byte*)rhsData.Scan0;\r\n\r\n        for (int y = 0; y &lt; height; ++y)\r\n        {\r\n            for (int x = 0; x &lt; width * 4; x+=4)\r\n            {\r\n                int lhsAlpha = lhsPtr&#x5B;x + 3];\r\n                int rhsAlpha = rhsPtr&#x5B;x + 3];\r\n\r\n                \/\/ multiply color with alpha factor\r\n                lhsPtr&#x5B;x + 0] = MultiplyColor(lhsPtr&#x5B;x + 0], rhsPtr&#x5B;x + 0], lhsAlpha, rhsAlpha);\r\n                lhsPtr&#x5B;x + 1] = MultiplyColor(lhsPtr&#x5B;x + 1], rhsPtr&#x5B;x + 1], lhsAlpha, rhsAlpha);\r\n                lhsPtr&#x5B;x + 2] = MultiplyColor(lhsPtr&#x5B;x + 2], rhsPtr&#x5B;x + 2], lhsAlpha, rhsAlpha);\r\n\r\n                \/\/ also blend the alpha channel\r\n                int retAlpha = (lhsAlpha + rhsAlpha - lhsAlpha * rhsAlpha \/ 255);\r\n                lhsPtr&#x5B;x + 3] = Clamp(retAlpha);\r\n            }\r\n            lhsPtr += offset;\r\n            rhsPtr += offset;\r\n        }\r\n    }\r\n    lhs.UnlockBits(lhsData);\r\n    rhs.UnlockBits(rhsData);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Multiply\u662fPS\u4e2d\u5e38\u7528\u7684\u4e00\u79cd\u6df7\u5408\u65b9\u5f0f\uff0c\u4e2d\u6587\u7248\u79f0\u4e3a\u201c\u6b63\u7247\u53e0\u5e95\u201d\u6a21\u5f0f\u3002 \u8bf4\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff0c\u5c31\u662f\u989c\u8272\u5206\u91cf\u76f8\u4e58\u3002\u4f46\u5b9e\u9645\u4e0a\u7b80\u5355\u7684\u76f8\u4e58\u5e76\u6ca1\u6709\u8003\u8651\u5230alpha channel\u3002 \u5982\u679c\u4e24\u4e2a\u56fe\u5c42\u90fd\u662fRGBA\u56db\u4e2a\u901a\u9053\uff0cMultiply\u7684\u7b97\u6cd5\u8fd8\u5f97\u52a0\u5165alpha\u3002 \u4e3a\u4e86\u641e\u6e05\u695a\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u7422\u78e8\u4e86\u597d\u51e0\u4e2a\u5c0f\u65f6\u3002\u6700\u540e\u4ece\u989c\u8272\u542b\u4e49\u5165\u624b\uff0c\u914d\u5408\u4e00\u4e9b\u6d4b\u8bd5\u7ed3\u679c\uff0c\u7ec8\u4e8e\u63a8\u51fa\u4e86PS\u7684\u6df7\u5408\u516c\u5f0f\uff1a OutAlpha = A1 + A2 &#8211; A1*A2 OutColor = (1.0 &#8211; (1.0 &#8211; C1)*A1) * (1.0 &#8211; (1.0 &#8211; C2)*A2) \u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2a\u516c\u5f0f\u5bf9\u4e8eA1\u548cA2\u662f\u5bf9\u79f0\u7684\uff0c\u6240\u4ee5\u88ab\u6df7\u5408\u7684\u4e24\u4e2a\u56fe\u5c42\u6ca1\u6709\u524d\u540e\u4e4b\u5206\u3002 \u63a8\u7406\u8fc7\u7a0b\u5982\u4e0b\uff1aMultiply\u6df7\u5408\u53ef\u4ee5\u770b\u4f5c\u662f\u4e24\u5f20\u5e7b\u706f\u7247\u53e0\u5728\u4e00\u8d77\uff0c\u56e0\u4e3a\u53d8\u5f97\u66f4\u539a\u6240\u4ee5\u900f\u8fc7\u7684\u989c\u8272\u53d8\u5c11\uff0c\u4ece\u800c\u8fbe\u5230\u51cf\u8272\u6548\u679c\u3002\u5728\u8fd9\u91cc\u989c\u8272\u5206\u91cfColor\u662f\u5149\u53ef\u4ee5\u900f\u8fc7\u7684\u7a0b\u5ea6\uff0c1.0\u5373\u8868\u793a\u8be5\u989c\u8272\u5206\u91cf\u5168\u90e8\u53ef\u4ee5\u900f\u8fc7\u30021.0-Color\u8868\u793a\u88ab\u5438\u6536\u6389\u7684\u90e8\u5206\u3002\u5728PS\u7684\u6df7\u5408\u7b97\u6cd5\u4e2d\uff0cAlpha\u7528\u6765\u8c03\u8282\u5438\u6536\u7a0b\u5ea6\u3002\u56e0\u4e3aAlpha\u7ecf\u5e38\u7528\u4e8e\u8868\u793a\u900f\u660e\u5ea6\uff0c1.0\u8868\u793a\u5b8c\u5168\u4e0d\u900f\u660e\uff0c\u5373\u5438\u6536\u7a0b\u5ea6\u4e3a100%\u3002 \u7ed3\u5408\u4ee5\u4e0a\u4e24\u4e2a\u5b9a\u4e49\uff1a (1.0 &#8211; Color) * Alpha \/\/ \u8868\u793a\u88ab\u5438\u6536\u7684\u989c\u8272 1.0 &#8211; (1.0 &#8211; Color) * Alpha \/\/ \u8868\u793a\u6700\u7ec8\u900f\u8fc7\u7684\u989c\u8272 \u628a\u4e24\u4e2a\u6700\u7ec8\u900f\u8fc7\u7684\u989c\u8272\u76f8\u4e58\uff0c\u5373\u5f97\u5230\u6211\u4eec\u9700\u8981\u7684\u6700\u7ec8\u51cf\u8272\u7ed3\u679c\u3002 \u5728\u5ffd\u7565Alpha\u53ea\u6709RGB\u6df7\u5408\u7684\u60c5\u51b5\u4e0b\uff0cAlpha\u90fd\u53d61.0\uff0c\u5219\u516c\u5f0f\u53ef\u4ee5\u5316\u7b80\u4e3a\uff1a OutAlpha = 1.0 OutColor = C1 * C2 \u7ed3\u679c\u4e3a\u989c\u8272\u5206\u91cf\u76f4\u63a5\u76f8\u4e58\uff0c\u4e5f\u5c31\u662f\u5230\u5904\u90fd\u53ef\u4ee5\u627e\u5230\u7684\u5bf9Multiply\u7684\u7b97\u6cd5\u7684\u63cf\u8ff0\u3002 &hellip; <a href=\"https:\/\/blog.mega-zone.org\/?p=423\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Photoshop\u4e2d\u7684Multiply Blend Mode&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[33],"_links":{"self":[{"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=\/wp\/v2\/posts\/423"}],"collection":[{"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=423"}],"version-history":[{"count":19,"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=\/wp\/v2\/posts\/423\/revisions"}],"predecessor-version":[{"id":439,"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=\/wp\/v2\/posts\/423\/revisions\/439"}],"wp:attachment":[{"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mega-zone.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}