


An introduction to the development of third-party filter plug-ins for Photoshop
Photoshop is an outstanding software in the field of digital image processing. At the same time, it also allows third parties to extend its functions in the form of plug-ins. Photoshop plug-ins can currently be divided into the following nine types: automation (batch processing) (appears under the 'Auto' submenu), color pickup, import, export (appears under the 'Import' 'Export' submenu), extension, Filters, File Format (appears under Open, Save As), Parsing (with Export function), Selection (appears under 'Select' menu). Here we take the most familiar filter as an example.
(1) Introduction to the general part of the plug-in:
We become the host by calling the main program of the plug-in. In most cases, it is Photoshop (hereinafter referred to as PS). A plug-in is actually a dynamic link library under the Windows system. (just with a different extension). PS uses LoadLibray to load plug-in modules. When the user takes the corresponding action, it will cause a series of PS calls to the plug-in module. All these calls call the same entry point. The entry point is such a function, defined as follows: (Since PS is compatible with windows and Macs, here we only give the definition on the windows system)
void ENTRYPOINT (
short selector,
use use using with using use using ’ through through ’ s ’ through use ’ s ’ s ’ through ‐ ‐ ‐‐‐ void* pluginParamBlock,
long* pluginData,
short* result); When selector=0, it has the same meaning for all types of plug-ins, that is, asking to display an About dialog box. Other values have different meanings depending on the plug-in type.
pluginParamBlock:
This is a pointer to a large structure, which is used to transfer information and data between the host and the plug-in. It has different structures for different types of plugins.
pluginData:
A pointer to int32 type. It is a value that PS saves across multiple calls to the plugin. One of its standard uses is that the plug-in can pass some global data pointers to this parameter to save,
result:
A pointer to int16, it must set the result every time the plug-in is called. Returning 0 indicates that no error occurred in the plugin code. When an error occurs, this value returns an error code. Regarding error codes, ps divides the error code ranges for different types of plug-ins and predefines some values in the SDK.
About dialog:
All plugins should respond to about calls. Plug-ins can display a custom dialog box. However, in order to maintain consistency, the following conventions should be adhered to:
(1) Display in the horizontal center of the main screen and vertically 1/3 of the height.
(2) There is no need to include an OK button, but respond to clicks at any location and the Enter key.
(2) Introduction to the filter plug-in
The function of the filter plug-in is to modify the selected area of the image. Filter behaviors range from adjusting saturation and brightness to filtering images and more. The extension of the filter under Windows is ".8BF".
The following figure shows the calling sequence between PS and filter plug-ins. It is very important. This is a picture in the SDK document. There is such a picture for each type of plug-in. What is shown here is the filter. The calling sequence of the plug-in.
Filters can be called using the filter menu, which is the top calling starting point. After calling it once, Photoshop will put the latest filter operation on the "Last Filter" submenu of the filter menu. Clicking this menu in the future will correspond to the "Last Filter Command" in the picture above. Below we will briefly introduce the process shown above. First, let’s look at the “template” of a filter’s entry point function:
EntryPoint Of Plugin :PlugInMain
Note that the above function is the most important function of our filter, because this function is provided for PS calls, we can see that this function is declared as a Dll export function. As can be seen from the calling sequence, this mechanism makes the function of this function very similar to the window procedure of the window. The window procedure is used to process messages based on MSG ID, and this function is mainly used to perform corresponding operations based on the selector. Therefore, they all contain a switch-case branch processing structure.
filterRecord
The second parameter used in the above function is a pointer to the AboutRecord structure when it is called about (that is, selector=0). When it is not called about, it is A pointer to the FilterRecord structure. The FilterRecord structure is a very large and complex structure. It is the key carrier for communication and data transfer between ps and filters. Its sizeof=452 bytes contains approximately more than 100 members. , there are a total of 7 pages in the document used to introduce the meaning of the members of this structure. The complete definition of FilterRecord is located in the header file:pifilter.h in sdk. Below I will explain some of its most basic and important members as they are mentioned.
(3) Introduction to the calling process.
(3.1) filterSelectorParameters call:
If the filter has some parameters that need to be set by the user, then it should save the parameters to a location. Then set the address to the third parameter data. PS will initialize this parameter to NULL. Whether this call occurs depends on the user's calling method. When a filter has just been called, the filter will appear in the filter's most recent command menu. The user can use this menu with the same parameters (no dialog box will be displayed at this time to request User sets new parameters) and calls again. This call does not occur when the user calls it with the last filter command. (See picture above). Therefore, parameters should be checked, verified, and initialized every time if incorrect parameters may create a risk of crashing the program.
Notice! : Since the same parameters can be used for images of different sizes, the parameters should not depend on the image size. For example, a parameter should not depend on the image width or height. It is usually more appropriate to use a percentage or scale factor as the parameter.
Therefore, your parameter data block should contain the following information:
1. A signature so that the filter can quickly confirm that this is the parameter data of it.
2. A version number so that the plug-in can be upgraded freely without changing the signature.
3. Byte order identification. (For cross-platform purposes) Indicates what endianness is currently in use.
Parameter block (parameter data block) and scripting system (script description system)
The script description system is used to cache our parameters and will be used in each call type. It is passed to the plugin so you can use it to store all your parameters. Once your Parameter block is validated, you should read the data from the passed parameters and then update your parameters. For example:
1. First call ValidateMyParameters to verify or initialize your global parameters.
2. Then call the ReadScriptingParameters method to read the parameters and write them into your global parameter data structure.
(3.2) filterSelectorPrepare call:
This call allows your plug-in module to adjust the memory allocation algorithm of ps. The "Last Filter" command will start from this call. PS sets maxSpace (which is a member of the FilterRecord structure (second parameter), new members that appear thereafter will not be specially explained) to the maximum number of bytes he can allocate for the plug-in.
ImageSize, planes and filterRect members:
These members are now defined (referring to sdk 6.0) and can be used to calculate your memory requirements. imageSize, image size. planes, number of channels.
filterRect: filter rectangle.
Here I would like to emphasize this filterRect, which is the Rect type defined by PS (similar to the RECT structure of the windows api). This concept is also the concept of "selection enclosing rectangle" mentioned and repeatedly emphasized in my research post on "Principles of Displacement Filters". At that time, I had not yet come into contact with PS SDK. Here we see that in Photoshop's code, it's called filterRect.
bufferSpace:
If the filter wants to allocate more than 32K of space, then this member should be set to the number of bytes you want to apply for. ps will try to release a space of this size before the next call (start call) to ensure that your next call is successful.
(3.3)filterSelectorStart call:
In this call, the parameter data block should be verified, and based on the parameters passed by ps, update your own parameters and display your UI if necessary. Then go into your data processing process.
AdvanceState callback: (used to request PS to update the corresponding data)
This is a very important callback function provided by PS to the filter. Its definition is as follows:
# typedef short OSErr;
typedef MACPASCAL OSErr (*AdvanceStateProc) (void);
His function is to require PS to immediately update the outdated data in FilterRecord. For example, we can set our new processing rectangle and then call this function, and then we can get the new data we need after this call. If you use this callback, then your core processing can all be done in the start call without using a continue call. When the processing is completed, you can set inRect=outRect=maskRect=NULL.If you do not use this callback, then you should set the first rectangular area and then use continue to call the loop processing.
For example, we can use the following loop in the start call to process the image until the entire image processing is completed.

Photoshop is very practical and creative in practical applications. 1) It provides basic editing, repairing and synthesis functions, suitable for beginners and professionals. 2) Advanced features such as content recognition fill and layer style can improve image effects. 3) Mastering shortcut keys and optimizing layer structure can improve work efficiency.

Advanced features of Adobe Photoshop include advanced selection tools, layer blending modes, and actions and scripts. 1) Advanced selection tools such as the Quick Selection Tool and the Color Range Selection Tool can accurately select image areas. 2) Layer blending mode such as "overlapping" mode can create unique visual effects. 3) Actions and scripts can automate repetition of tasks and improve work efficiency.

Photoshop's powerful functions in photo editing and enhancement include: 1. Use the "Repair Brush Tool" to remove acne, 2. Use the "Liquefaction Tool" to slim face, 3. Use the "Frequency Separation" technology to accurately retouch images. These functions are implemented through algorithms and image processing technology to optimize image processing effects.

Key features of Photoshop include layers and masks, adjustment tools, filters and effects. 1. Layers and masks allow independent editing of image parts. 2. Adjust tools such as brightness/contrast can modify image tone and brightness. 3. Filters and effects can quickly add visual effects. Mastering these features can help creative professionals achieve their creative vision.

Photoshop's applications in digital art include painting, illustration and image synthesis. 1) Painting: Using brushes, pencils and mixing tools, the artist can create realistic effects. 2) Illustration: With vector and shape tools, artists can accurately draw complex graphics and add effects. 3) Synthesis: Using mask and layer blending mode, artists can seamlessly blend different image elements.

Photoshop's advanced photo editing and synthesis technologies include: 1. Use layers, masks and adjustment layers for basic operations; 2. Use image pixel values to achieve photo editing effects; 3. Use multiple layers and masks for complex synthesis; 4. Use "liquefaction" tools to adjust facial features; 5. Use "frequency separation" technology to perform delicate photo editing, these technologies can improve image processing level and achieve professional-level effects.

The steps to using Photoshop for brand design include: 1. Use the Pen tool to draw basic shapes, 2. Add shadows and highlights through layer styles, 3. Adjust colors and details, 4. Use smart objects and actions to automatically generate different versions of the design. Photoshop helps designers create and optimize brand elements with the flexibility of layers and masks, ensuring consistency and professionalism of designs, from simple logos to complex branding guides.

Photoshop's subscription model is worth buying. 1) Users can access the latest version and use across devices at any time. 2) The subscription fee is low, and continuous updates and technical support are provided. 3) Advanced functions such as neural filters can be used for complex image processing. Despite the high long-term costs, its convenience and feature updates are valuable to professional users.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor