


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.

Adobe Photoshop offers three packages: 1) a single application plan, suitable for users who only need Photoshop, with a low cost, including 20GB of cloud storage; 2) a full set of CreativeCloud plans, suitable for users who need multiple Adobe applications, with a high cost, including 100GB of cloud storage; 3) a preferential plan for students and teachers, suitable for academic users with limited budget, with a low cost, including 20GB of cloud storage.

Photoshop'sprimaryfunctionistoenableuserstomanipulate,enhance,andcreatedigitalimageswithprecisionandcontrol.Itsspecialfeaturesinclude:1)alayer-basededitingsystemforindependentelementmanipulation,2)anextensivelibraryoftoolsandfiltersforvarioustasks,an

Photoshop's cost includes direct costs, time and learning curve, resources and hardware investment. 1. Direct cost: Subscription system $20 to $50 per month, purchase hundreds of dollars at one time. 2. Time and Learning: It requires a lot of time and practice, and it is recommended to learn through online courses and tutorials. 3. Resources and hardware: High-performance computers and sufficient storage space are required to ensure hardware configuration to improve efficiency.

Photoshop's core features include layers, selection tools, and adjustment tools. 1. The layer allows independent editing of image parts and supports layer style. 2. Selection tools such as lasso, magic wand and quick selection tools provide precise editing. 3. Adjustment tools such as color level, curve and hue/saturation can adjust images non-destructively.

In Photoshop, the role of layer masks is to allow hidden or displayed portions of layers in a non-destructive manner. 1. The working principle of layer mask is to control the visibility of the layer through black, white and grayscale. 2. The basic usage includes image synthesis, such as synthesising the character image into a new background. 3. Advanced usage can be achieved by using gradient masks to achieve smooth image transition.

Photoshop's powerful features include smart objects and neural filters, while free alternatives such as GIMP, Krita and Photopea do well in specific fields such as GIMP's layer functionality, Krita's digital paintings and online editing of Photopea.

Color adjustment in Photoshop can be achieved through adjustment layers to make the image more professional. 1. Use color level, curve, hue/saturation and other tools to adjust the hue, saturation and brightness. 2. Apply LUT to create unique color effects. 3. Use adjustment layers to avoid image distortion and use the History panel to track adjustment steps.

Photoshop's applications in the real world include artistic creation, scientific research and commercial marketing. 1) In artistic creation, it is used for digital painting and illustration. 2) In scientific research, it is used for image processing and data visualization. 3) In commercial marketing, it is used for advertising design and brand image shaping. The versatility of this software makes it widely used in various fields.


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 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor
