• <label id="pxtpz"><meter id="pxtpz"></meter></label>
      1. <span id="pxtpz"><optgroup id="pxtpz"></optgroup></span>

        當前位置:雨林木風下載站 > 圖形圖像教程 > 詳細頁面

        如何編寫一個Photoshop濾鏡-- Scripting Plug-ins

        如何編寫一個Photoshop濾鏡-- Scripting Plug-ins

        更新時間:2025-09-20 文章作者:未知 信息來源:網絡 閱讀次數:

        Adobe Photoshop,簡稱“PS”,是由Adobe Systems開發和發行的圖像處理軟件。Photoshop主要處理以像素所構成的數字圖像。使用其眾多的編修與繪圖工具,可以有效地進行圖片...
        Adobe Photoshop,簡稱“PS”,是由Adobe Systems開發和發行的圖像處理軟件。Photoshop主要處理以像素所構成的數字圖像。使用其眾多的編修與繪圖工具,可以有效地進行圖片編輯工作。ps有很多功能,在圖像、圖形、文字、視頻、出版等各方面都有涉及。
        在第一篇文章中我們建立了一個沒有UI的基本濾鏡框架,并且引入PIPL資源使之能被PS加載到菜單。在第二篇文章中我們又引入了濾鏡參數和相應的對話框資源,并且講解了對話框在濾鏡調用流程中的顯示時機。這一篇文章我們將使濾鏡支持動作記錄和回放,也就是通過添加“術語資源”,使我們的濾鏡參數被PS的腳本系統所獲知(scripting-aware),并能夠記錄和回放。

        從Photoshop 4.0開始引入了一個新的面板以及相應的命令和回調函數:動作面板(浮動窗口),以及Descriptor 回調函數集。動作面板是Photoshop腳本系統用于和用戶交互的接口,也是其核心所在。Photoshop 5.0擴展了動作結構,使自動化插件能夠支持可描述的Photoshop命令。(《Photoshop API Guide》第11章)

        關于PS的 Scripting System,其來源是 PS 對蘋果系統的事件和腳本機制的繼承和支持,PS 的開發同時針對兩種操作系統平臺。這里我們介紹如何使我們的濾鏡被PS腳本系統接納。

        首先我們需要在 r文件中增加術語資源(terminology resource)。因此首先在 pipl 資源中增加一個 HasTerminology 結構,其定義如下:

        //這個屬性指明濾鏡是否提供了 'aete'資源。
        
        typedef struct HasTerminology
        
        {
        
        int32 classID; // classID from 'aete'
        
        int32 eventID; // eventID from 'aete' or NULL if none
        
        int16 aeteResNum; // number of 'aete' resource
        
        CString uniqueID; // unique ID string (UUID or your own ?/?). If present,
        
        ignores AppleScript and keeps local to Photoshop.
        
        } HasTerminology;

        這個結構將被增加到 r文件的 pipl資源內。下面我們在pipl資源后面添加了 aete 資源。

        在此前我們在一個通用的頭文件中添加一些aete資源需要的定義:

        //定義 Scripting Keys
        #define KEY_FILLCOLOR        'fiCo'
        #define KEY_OPACITY            'opcA'
        
        #define plugInSuiteID        'filR'
        #define plugInClassID        'filR'
        #define    plugInEventID        'filR'
        #define    plugInUniqueID        "18EC4E8F-DB34-4aff-AF99-77C8013BD74F"
        #define plugInAETEComment    "FillRed example filter By hoodlum1980"
        #define vendorName            "hoodlum1980"


        //定義 Scripting Keys
        #define KEY_FILLCOLOR 'fiCo'
        #define KEY_OPACITY 'opcA'

        #define plugInSuiteID 'filR'
        #define plugInClassID 'filR'
        #define plugInEventID 'filR'
        #define plugInUniqueID "18EC4E8F-DB34-4aff-AF99-77C8013BD74F"
        #define plugInAETEComment "FillRed example filter By hoodlum1980"
        #define vendorName "hoodlum1980"

        上面我們把我們的濾鏡,濾鏡的參數都定義為了鍵,關于鍵定義,需要符合以下原則:

        (a)它必須由4個字符組成。不夠4個字符可以結尾用空格補足。

        (b)用戶定義的鍵名應該以小寫字母開頭,同時至少含有一個大寫字母。(因為全大寫,全小寫鍵名屬于Apple定義)。

        濾鏡的唯一標識符采用VC工具生成的GUID即可。

        然后我們對r文件增加aete 資源,aete 資源模板如下:

        resource 'aete' (0)
        
        { // aete version and language specifiers
        
        { /* suite descriptor */
        
        { /* filter/selection/color picker descriptor */
        
        { /* any parameters */
        
        / * additional parameters */
        
        }
        
        },
        
        { /* import/export/format descriptors */
        
        { /* properties. First property defines inheritance. */
        
        /* any properties */
        
        },
        
        { /* elements. Not supported for plug-ins. */
        
        },
        
        /* class descriptions for other classes used as parameters or properties */
        
        },
        
        { /* comparison ops. Not currently supported. */
        
        },
        
        { /* any enumerations */
        
        {
        
        /* additional values for enumeration */
        
        },
        
        /* any additional enumerations */
        
        /* variant types are a special enumeration: */
        
        {
        
        /* additional types for variant */
        
        },
        
        /* any additional variants */
        
        /* class and reference types are a special enumeration: */
        
        {
        
        },
        
        /* any additional class or reference types */
        
        }
        
        }
        
        }

        請注意的是這是一個針對PS插件的aete資源模板,也就是說它不僅僅針對濾鏡,也包括其他種類的PS插件。關于其具體含義這里我們不做詳細討論,可以參考相關PS SDK文檔。

        【注意】即使有的節不需要,也必須提供一個空的花括號占位,而不能有缺失。

        下面我們給出添加了aete資源后的 FillRed.r 文件,內容如下:

        // ADOBE SYSTEMS INCORPORATED
        // Copyright  1993 - 2002 Adobe Systems Incorporated
        // All Rights Reserved
        //
        // NOTICE:  Adobe permits you to use, modify, and distribute this 
        // file in accordance with the terms of the Adobe license agreement
        // accompanying it.  If you have received this file from a source
        // other than Adobe, then your use, modification, or distribution
        // of it requires the prior written permission of Adobe.
        //-------------------------------------------------------------------------------
        #define plugInName            "FillRed Filter"
        #define    plugInCopyrightYear "2009"
        #define plugInDescription \
            "FillRed Filter.\n\t - http:\\www.cnblogs.com\hoodlum1980"
        
        #include "E:\Codes\Adobe Photoshop CS2 SDK\samplecode\common\includes\PIDefines.h"
        
        #ifdef __PIMac__
            #include "Types.r"
            #include "SysTypes.r"
            #include "PIGeneral.r"
            #include "PIUtilities.r"
            #include "DialogUtilities.r"
            #include "CommonDefine.h"        /* 包含了術語定義 */
        #elif defined(__PIWin__)
            #define Rez
            #include "PIGeneral.h"
            #include "E:\Codes\Adobe Photoshop CS2 SDK\samplecode\common\resources\PIUtilities.r"
            #include "E:\Codes\Adobe Photoshop CS2 SDK\samplecode\common\resources\WinDialogUtils.r"
            #include "CommonDefine.h"        /* 包含了術語定義 */
        #endif
        
        #include "PITerminology.h"
        #include "PIActions.h"                /* 包含對 NO_REPLY 的定義 */
        
        resource 'PiPL' ( 16000, "FillRed", purgeable )
        {
            {
                Kind { Filter },
                Name { plugInName },
                Category { "Demo By hoodlum1980" },
                Version { (latestFilterVersion << 16) | latestFilterSubVersion },
                #ifdef __PIWin__
                    CodeWin32X86 { "PluginMain" },
                #else
                    CodeMachOPowerPC { 0, 0, "PluginMain" },
                #endif
        
                SupportedModes
                {
                    noBitmap, doesSupportGrayScale,
                    noIndexedColor, doesSupportRGBColor,
                    doesSupportCMYKColor, doesSupportHSLColor,
                    doesSupportHSBColor, doesSupportMultichannel,
                    doesSupportDuotone, doesSupportLABColor
                },
                
                HasTerminology
                {
                    plugInClassID,
                    plugInEventID,
                    16000,                /* int16 aeteResNum;  number of 'aete' resource */
                    plugInUniqueID
                },
                    
                EnableInfo
                {
                    "in (PSHOP_ImageMode, RGBMode,"
                    "CMYKMode, HSLMode, HSBMode, "
                    "DuotoneMode, LabMode)"
                },
        
                PlugInMaxSize { 2000000, 2000000 },
        
                FilterCaseInfo {
                    {    /* array: 7 elements */
                        /* Flat data, no selection */
                        inStraightData,
                        outStraightData,
                        doNotWriteOutsideSelection,
                        doesNotFilterLayerMasks,
                        doesNotWorkWithBlankData,
                        copySourceToDestination,
                        /* Flat data with selection */
                        inStraightData,
                        outStraightData,
                        doNotWriteOutsideSelection,
                        doesNotFilterLayerMasks,
                        doesNotWorkWithBlankData,
                        copySourceToDestination,
                        /* Floating selection */
                        inStraightData,
                        outStraightData,
                        doNotWriteOutsideSelection,
                        doesNotFilterLayerMasks,
                        doesNotWorkWithBlankData,
                        copySourceToDestination,
                        /* Editable transparency, no selection */
                        inStraightData,
                        outStraightData,
                        doNotWriteOutsideSelection,
                        doesNotFilterLayerMasks,
                        doesNotWorkWithBlankData,
                        copySourceToDestination,
                        /* Editable transparency, with selection */
                        inStraightData,
                        outStraightData,
                        doNotWriteOutsideSelection,
                        doesNotFilterLayerMasks,
                        doesNotWorkWithBlankData,
                        copySourceToDestination,
                        /* Preserved transparency, no selection */
                        inStraightData,
                        outStraightData,
                        doNotWriteOutsideSelection,
                        doesNotFilterLayerMasks,
                        doesNotWorkWithBlankData,
                        copySourceToDestination,
                        /* Preserved transparency, with selection */
                        inStraightData,
                        outStraightData,
                        doNotWriteOutsideSelection,
                        doesNotFilterLayerMasks,
                        doesNotWorkWithBlankData,
                        copySourceToDestination
                    }
                }
            }
        };
        
        
        resource 'aete' (16000, "FillRed dictionary", purgeable)
        {
            1, 0, english, roman,                                    /* aete version and language specifiers */
            {
                vendorName,                                            /* vendor suite name */
                "FillRed Demo By hoodlum1980",                        /* optional description */
                plugInSuiteID,                                        /* suite ID */
                1,                                                    /* suite code, must be 1 */
                1,                                                    /* suite level, must be 1 */
                {                                                    /* structure for filters */
                    plugInName,                                        /* unique filter name */
                    plugInAETEComment,                                /* optional description */
                    plugInClassID,                                    /* class ID, must be unique or Suite ID */
                    plugInEventID,                                    /* event ID, must be unique to class ID */
                    
                    NO_REPLY,                                        /* never a reply */
                    IMAGE_DIRECT_PARAMETER,                            /* direct parameter, used by Photoshop */
                    {                                                /* parameters here, if any */
                        "FillColor",                                /* parameter name */
                        KEY_FILLCOLOR,                                /* parameter key ID */
                        typeInteger,                                /* parameter type ID */
                        "Fill color in RGB",                        /* optional description */
                        flagsSingleParameter,                        /* parameter flags */
                        
                        "Opacity",                                    /* optional parameter */
                        KEY_OPACITY,                                /* key ID */
                        typeInteger,                                /* type */
                        "opacity in RGB",                            /* optional desc */
                        flagsSingleParameter                        /* parameter flags */
                    }
                },
                {                                                    /* non-filter plug-in class here */
                },
                {                                                    /* comparison ops (not supported) */
                },
                {                                                    /* any enumerations */
                }
            }
        };

        在上面的文件中,我們可以看到我們的濾鏡含有的兩個主要參數:填充顏色 和 不透明度。位于 IMAGE_DIRECT_PARAMETER 結構中,typeInteger 指明它們是整數類型。flagsSingleParameter指明它們是基本類型(具有單一值)。此外,還可以把參數定義為枚舉類型,同時把枚舉的值域定義放在最后一節中,這里我們對此不做介紹了。

        怎樣編寫一個Photoshop濾鏡-- Scripting Plug-ins

        濾鏡被重新編譯后,我們在PS中對它錄制一個動作,命名為“測試 FillRed”,錄制完成后,可以看到在動作面板上的左側,出現了對話框選項的CheckBox,我們可以設置播放時是否彈出對話框。我們把FillRed濾鏡命令的下拉列表展開可以看到濾鏡參數:

        FillColor: 10

        Opacity:90

        請注意參數的名字就是來自于上面的aete資源中的定義的濾鏡參數名字屬性,這就是我們需要給它定義一個可讀的參數名的原因。需要注意的是,由于我們把對話框上三個參數合成為了一個參數,這就使得上面的參數顯示是三個參數的合成值(10進制)。因此這里為了看清楚,我就只設置了 R 和 O1,其他參數都為0,這樣我們在動作面板看到的參數值就和濾鏡的對話框上的參數值是一致的。否則我們看到的將是三個參數合成后的值。

        更多怎樣編寫一個Photoshop濾鏡-- Scripting Plug-ins相關文章請關注PHP中文網!


        Photoshop默認保存的文件格式,可以保留所有有圖層、色版、通道、蒙版、路徑、未柵格化文字以及圖層樣式等。

        溫馨提示:喜歡本站的話,請收藏一下本站!

        本類教程下載

        系統下載排行

        主站蜘蛛池模板: 精品无码国产污污污免费网站国产| 亚洲中文字幕无码中文| 豆国产96在线|亚洲| 和日本免费不卡在线v| 亚洲一区二区三区无码国产| 久久免费的精品国产V∧| 婷婷亚洲久悠悠色悠在线播放| 中文字幕免费观看视频| 亚洲欧洲国产精品香蕉网| 国产又黄又爽胸又大免费视频| 亚洲人成影院在线观看| 在线免费观看h片| 久久九九亚洲精品| 免费人成毛片动漫在线播放| 亚洲va无码va在线va天堂| 午夜精品射精入后重之免费观看 | 一级成人a免费视频| 亚洲国产高清精品线久久| 一个人免费观看日本www视频| 国产亚洲精品不卡在线| 男女作爱在线播放免费网站| 亚洲男人天堂av| 免费大片黄在线观看yw| 亚洲色大情网站www| 免费一看一级毛片人| 国产精品一区二区三区免费| 亚洲AV午夜成人片| 青青在线久青草免费观看| 综合偷自拍亚洲乱中文字幕| 在线a亚洲v天堂网2019无码| 99免费在线观看视频| 亚洲色精品VR一区区三区| 亚洲欧洲国产成人综合在线观看 | 国产成人精品免费视频网页大全| 亚洲欧洲综合在线| 日韩一区二区免费视频| 51午夜精品免费视频| 亚洲综合在线成人一区| 国产免费av片在线播放| A级毛片高清免费视频在线播放| 亚洲精品国产福利片|