Photoshop 필터 작성 방법 - 스크립팅 플러그인

高洛峰
풀어 주다: 2017-02-22 09:41:25
원래의
2223명이 탐색했습니다.

첫 번째 기사에서는 UI가 없는 기본 필터 프레임워크를 구축하고 PS에서 메뉴에 로드할 수 있도록 PIPL 리소스를 소개했습니다. 두 번째 기사에서는 필터 매개변수와 해당 대화 상자 리소스를 소개하고 필터 호출 프로세스에서 대화 상자가 표시되는 타이밍에 대해 설명했습니다. 이 기사에서는 필터 지원 작업 기록 및 재생을 만들 것입니다. 즉, "용어 리소스"를 추가하여 필터 매개변수가 PS 스크립팅 시스템(스크립팅 인식)에 알려지고 기록 및 재생이 가능해집니다. .

Photoshop 4.0부터 새로운 패널과 해당 명령 및 콜백 기능이 도입되었습니다: 액션 패널(부동 창) 및 설명자 콜백 기능 세트. 액션 패널은 Photoshop 스크립팅 시스템이 사용자와 상호 작용하는 데 사용하는 인터페이스이자 핵심이기도 합니다. Photoshop 5.0은 작업 구조를 확장하여 설명적인 Photoshop 명령을 지원하는 자동화 플러그인을 활성화합니다. ("Photoshop API 가이드" 11장)

PS의 스크립팅 시스템에 대한 소스는 PS의 이벤트 지원과 Apple 시스템의 스크립팅 메커니즘을 기반으로 하며 두 운영 체제 플랫폼용으로 개발되었습니다. 여기서는 PS 스크립트 시스템에서 필터를 허용하는 방법을 소개합니다.

먼저 r 파일에 용어 리소스를 추가해야 합니다. 따라서 먼저 다음과 같이 정의된 HasTerminology 구조를 pipl 리소스에 추가합니다.

//这个属性指明滤镜是否提供了 '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"
로그인 후 복사


//정의 스크립팅 키
#define KEY_FILLCOLOR 'fiCo'
#define KEY_OPACITY 'opcA' > 'filR'

#defineplugInUniqueID "18EC4E8F-DB34-4aff-AF99-77C8013BD74F"
#define PlugInAETEComment "FillRed 예시 필터 Byhoodlum1980"
#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 &#39;aete&#39; 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 &#39;aete&#39; (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中文网!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!