참고: adobe_photoshop_cs5_sdk_win/pluginsdk/documentation/html/pgwinplugins.html
Creating plug-in modules for Windows
위의 참고 주소와 같이 SDK에서 제공하는 정보입니다.
Create a Project Workspace
All Windows Photoshop plug-ins have three basic properties. They are shared libraries, they have a PiPL resource, and they have a program entrypoint or main function.
- Launch Microsoft Visual C++ 2005, or Visual Studio 2005.
- Choose from the menu "File" > "New" > "Project".
- Under Project Types, select "Win32"
- From the list of templates, choose "Win32 Project".
- In the "Name:" field, type "myfilter" (or the name of your plug-in).
- In the "Location:" field, type in the location for your project. Set the path similar to the following:
C:\Adobe Photoshop 10.0 SDK\samplecode\filter\myfilter\win.
- Do not check "Create Directory for Solution"
- Click "OK".
- The "Win32 Application Wizard" appears.
- Click "Next".
- Select Application Type: "DLL'
- Select Additional Options: "Empty Project".
- Click "Finish".
- The project appears in the Solutions Explorer.
Move the Project
When creating a new project, Visual C++ makes a new folder and puts the project there. In this case, we want the files up a level, directly in themyfilter\win
folder to be consistent with the Mac environment.
- Note:
- You can skip this step for your projects. Please make a note of your level change when using the relative paths later in this document.
- Close Visual C++, and navigate to location
C:\Adobe Photoshop 10.0 SDK\samplecode\filter\myfilter\win\myfilter
. We want it up a level. - Select all the files and copy them.
- Move them up a level (
..\samplecode\filter\myfilter\win
). - Delete the
win\myfilter
folder that the files where copied from.
Add the Main Source File
Now you have a blank project to work from. The first step is to add the main source file, which subsequently allows us to enter build settings for a C++ project. To do this, we copy the main source file from the dissolve filter.
- Launch Visual C++ by double clicking on the
myfilter.vcproj
file. - Choose from the menu, "File" > "Open".
- Navigate to the location of the main source file you want to copy. (
C:\Adobe Photoshop 10.0 SDK\samplecode\filter\invert\common
) - Select "File" > "Save Dissolve.cpp As"
- Navigate to the
..\samplecode\filter\myfilter\common
directory. - Save the file as "myfilter.cpp"
- Under the Solution Explorer navigation bar, right click on the "Source Files" folder.
- Select "Add" > "Existing Item".
- Navigate to the
..\samplecode\filter\myfilter\common
directory. - Select file "myfilter.cpp".
- Edit the file to replace occurances of "dissolve" with "myfilter".
- Save and close the "myfilter.cpp".
Add Other Necessary Source Files
Most projects that you copy from have additional source and header files you need to include in order for the project to build. The dissolve example does not have an include file of its own, but it does require several common source files (from ..\samplecode\common\sources
) that provide support utilites for the plug-in. We need to add these .cpp files to the project. Any common header files required by the plug-in are pulled in during the build step by providing an additional include directory.
- Under the Solution Explorer navigation bar, right click on the "Source Files" folder.
- Select "Add" > "Existing Item".
- Navigate to the
..\samplecode\common\sources
directory. - Double click on "FilterBigDocument.cpp".
- Repeat the previous set of steps to add "PIDLLInstance.cpp".
- Repeat the previous set of steps to add "PIUSuites.cpp".
- Repeat the previous set of steps to add "PIWinUI.cpp".
- Repeat the previous set of steps to add "PropertyUtils.cpp".
Add a Resource File
You must add a resource file (.rc), which holds an include to the PiPL resource file created in the next step.
- Choose from the menu "File" > "New" > "File".
- Under "Categories" select "Visual C++".
- Under "Templates" select "Resource Template File (.rct)".
- A "ResTempl1.rct" folder appears in the edit pane.
- Right click on the folder and select "Add Resource"
- When the "Add Resource" box appears, select "Dialog".
- Click "New" to add the dialog to the resource file.
- Close the resource editor.
- Choose from the menu "File" > "Save ResTempl1.rct".
- The "Save File As" dialog box pops up.
- Navigate to the location
..\samplecode\filter\myfilter\win
. - Choose "Save As Type" to be "Resouce Script (.rc)".
- Save the file as myfilter.rc.
- Open the resource file in the text editor.
- To do this, choose "File" > "Open".
- Navigate to the folder where the myfilter.rc file is located.
- Single click on the file.
- Click on the down arrow next to the "Open" button, choose "Open With".
- When the "Open With" box appears, select "Source Code (Text) Editor".
- Click "OK"
- A question dialog appears informing you that myfilter.rc is already open. Select "Yes", indicating you want to close the file.
- The myfilter.rc file opens in the edit pane in text mode.
- On approximately line 76, replace the line:
"\r\n"
with the line:"#include ""temp\\myfilter.pipl""\r\n"
- Scroll down to the end of the file to approximately line 93.
- Between line containing
"#ifndef APSTUDIO_INVOKED"
and the line containing"#endif"
insert the following text:#include "temp\\myfilter.pipl"
- Change all occurrences of "Dissolve" with your plug-in's name, "myfilter" for this example.
- Save "myfilter.rc".
- In the Solution Explorer navigation pane, right click on "Resource Files".
- Select "Add" > "Existing Item".
- Browse to and double click on the "myfilter.rc" file that you just created.
Add a PiPL Resource File
We now need to create the PiPL resource (.r) file for the plug-in. We do this by copying the PiPL resource file from the dissolve project. Once the file is built, we will add the custom build settings for the PiPL, described in the next step.
- Choose from the menu "File" > "Open" > "File".
- Navigate to the directory containing the PiPL resource file you want to copy. For this example, that is:
C:\Adobe Photoshop 10.0 SDK\samplecode\filter\dissolve\common
- Select "File" > "Save Dissolve.r As"
- Navigate to the
..\samplecode\filter\myfilter\common
directory. - Save the file as "myfilter.r"
- Edit the file to replace occurances of "dissolve" with "myfilter".
- Save and close "myfilter.r".
- In the Solution Explorer navigation pane, right click on "Resource Files".
- Select "Add" > "Existing Item".
- In the "Files of Type" box, select "All Files (*.*)".
- Browse to and double click on the "myfilter.r" file that you just created.
- When the box appears asking if you want to create custom build rules, click "No". (We will do this from the file's property page, instead.)
Enter Custom Build Settings for PiPL
Next we will enter the custom build rules for the PiPL resource file. You need to convert a Mac OS resource file into a Windows-compatible resource. You do this using the Visual C++ custom build step and the CNVTPIPL.EXE
found in the SDK.
- In the Solution Explorer navigation pane, right click on the "myfilter.r" file.
- Select "Properties".
- The Property Page dialog box for myfilter.r appears.
- In the "Configuration:" field, select "All Configurations", indicating this rule applies to all types of builds.
- Click on the "+" next to "Custom Build Step", then click on "General".
- Click on "Command Line", then on the ellipsis icon at the end of the line. There are three lines to enter into the custom build command line box. (NOTE: You need to change the paths if you placed your project in a different folder.)
- First, create a temporary .rr file, by entering the following as the first line in the box, and this must all be on a single line, not split on two lines as it is shown here:
cl /I..\..\..\Common\Includes /I..\..\..\..\PhotoshopAPI\Photoshop /I..\..\..\..\PhotoshopAPI\PICA_SP /I..\..\..\Common\Resources /EP /DWIN32=1 /Tc"$(InputPath)" > "$(IntDir)\$(InputName).rr"
- Next, enter the command to invoke CNVTPIPL.EXE:
..\..\..\resources\cnvtpipl.exe "$(IntDir)\$(InputName).rr" "$(IntDir)\$(InputName).pipl"
- Finally, enter the command to delete the temporary file.
del "$(IntDir)\$(InputName).rr"
- First, create a temporary .rr file, by entering the following as the first line in the box, and this must all be on a single line, not split on two lines as it is shown here:
- Click on "Outputs", and then on the down arrow at the end of the line.
- Enter the following into the box:
$(IntDir)\$(InputName).pipl
- Click "OK".
Enter Overall Build Settings for the Project
At this point the project is set up with all the appropriate files. You must now change the project settings to build a proper Photoshop plug-in. We do this by using the Property Page for the project, and modifying each of the sections of the build process.
- In the Solution Explorer navigation pane, right click on the "myfilter" project icon.
- Select Properties.
- Under "Configuration Properties, click on the "General" item.
- In the "Configuration:" field, select "All Configurations".
- In both the "Intermediate Directory" and "Output Directory" sections, type "temp".
- In the "Inherited Property Project Sheets" enter:
$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops
- Select "Apply". Your property page should look something like:
- Click on the "+' next to the "C/C++" item.
- Click on "General" under C++.
- Enter the following paths into "Additional Include Directories" (NOTE: If you did not put your plug-in into the SDK, these relative paths will not work. Make sure your paths point to these folders that are in the Photoshop SDK.)
..\..\..\Common, ..\..\..\Common\includes, ..\..\..\..\PhotoshopAPI, ..\..\..\..\PhotoshopAPI\ADM, ..\..\..\..\PhotoshopAPI\Photoshop, ..\..\..\..\PhotoshopAPI\General, ..\..\..\..\PhotoshopAPI\PICA_SP
- Set "Detect 64-bit portability issues" to "No".
- Click Apply. Your properties page should look something like:
- Enter the following paths into "Additional Include Directories" (NOTE: If you did not put your plug-in into the SDK, these relative paths will not work. Make sure your paths point to these folders that are in the Photoshop SDK.)
- Click on the "Preprocessor" item.
- Select "Preprocessor Definitions", then select the ellipsis at the end of the line to view the preprocessor options.
- Set the preprocessor defintions to the following list:
ISOLATION_AWARE_ENABLED WIN32 _DEBUG _WINDOWS _USRDLL Dissolve_EXPORTS
- The following preprocessor defintions should come from the inherited section:
_VC80_UPGRADE=0x0710 _WINDLL _MBCS
- If inherited items are different, or incomplete, then deselect the "Inherit from parent or project defaults" check box, and enter the three items above directly into the preprocessor definitions box.
- Click on the "Output Files" item.
- In the "Configurations:" field, select "Release".
- For "ASM List Location", "Object File Name", and "Database File Name", enter
.\..\..\..\Output\Objs\myfilter\Release//
- Click Apply.
- In the "Configurations:" field, select "Debug".
- For "ASM List Location", "Object File Name", and "Database File Name", enter
.\..\..\..\Output\Objs\myfilter\Debug//
- Click Apply.
- Click on the "Advanced" item.
- In the "Configurations:" field, select "All Configurations".
- In the "Compile As" field, select "Default".
- Click on the "-" next to the "C/C++" item, to close the list of C++ options.
- Click on "General" under C++.
- Click on the "+" next to the "Linker" item.
- Click on the "General" item.
- In the "Configurations:" field, select "Release".
- In the "Output File" field, enter:
..\..\..\Output\Win\Release\myfilter.8bf
Replacing "myfilter with the name of your plug-in. (.8bf is the extension for filter plug-in files.) - In the "Enable Incremental Linking field", select "Yes"
- Click Apply.
- In the "Configurations:" field, select "Debug".
- In the "Output File" field, enter:
..\..\..\Output\Win\Debug\myfilter.8bf
- In the "Enable Incremental Linking field", select "Yes"
- Click Apply.
- Click on the "Input" item.
- In the "Configurations:" field, select "All Configurations".
- In the "Additional Dependencies" field, enter
odbc32.lib odbccp32.lib version.lib
- Click Apply.
- Click OK.
- Click on the "General" item.
Building the Plug-in
Now you are ready to build the plug-in.
- Choose from the menu "Build" > "Build myfilter", or "Build" > "Build Solution".
- If the plug-in builds correctly, you will find the plug-in executable file in
..\..\..\Output\Win\Release\myfilter.8bf
or..\..\..\Output\Win\Debug\myfilter.8bf
- If the plug-in does not build correctly, check all the steps above and ensure you have followed them correctly. As a final check, you can verify all the project property pages of your new plug-in with the project property pages of the plug-in you copied from.
Installing plug-in modules
To install a plug-in module, copy the .8B* files into the directory referred to in the Photoshop INI file with the profile string PLUGINDIRECTORY
. See Finding the plug-in directory in Windows.
When Adobe Photoshop first executes, it searches the files in the PLUGINDIRECTORY
, looking for plug-in modules. When it finds a plug-in, it checks its version number. If the version is supported, it adds name of the plug-in to the appropriate menu or to the list of extensions to be executed.
Each kind of plug-in module has its own 4-byte resource type. For example, acquisition modules have the code 8BAM
.
The actual resource type must be specified as _8BAM
in your resource files to avoid a syntax error caused by the first character being a number.
For example, Adobe Photoshop searches for Import modules by examining the resources of all files in PLUGINDIRECTORY
with file extension .8B* for resource type
_8BAM
. For each 8BAM
, the integer value which uniquely identifies the resource, nameID
, must be consecutively numbered starting at 1.
'C++' 카테고리의 다른 글
GetProcessMemoryInfo function (0) | 2014.03.04 |
---|---|
VirtualQuery function (0) | 2014.03.04 |
MFC 표준 컨트롤에서 컨트롤 파생 (0) | 2014.02.14 |
MFC Custom Controls (0) | 2014.01.20 |
Adobe Photoshop SDK (0) | 2013.12.11 |