It is very easy to make Photoshop-Plugins with Filtermeister but it is not so easy to learn how to handle the color information of images.
To make it a bit easier for beginners I want to share some sample programs including source code.
There is no copyright to the source code (GPL) so they can be used and modified for own applications.
The plugin Adjustment shows how different adjustments are made in programs like Photoshop. It has sliders for hue, saturation, lightness and contrast, and works in 8 and 16 bit RGB mode.
Download source code or plugin of Adjustment.
Blurring is an often needed process and simply to implement but gets a bit tough if it should also work on 16-bit images, process large images in tiles and handle the edge of the image correctly.
Box Blur is an example for a fast implementation and available in source code: source code of Box Blur.
Gaussian Blur is an example for the normaly used blur and also available in source code: source code of Gaussian Blur.
I also developed an Efficient Gaussian Blur Algorithm.
An implementation of color space convertion according to Bruce Lindbloom in FM.
It converts from and to RGB, CMY, CMYK, HSB, HSL, L*a*b* and LCH.
The source code also explains the origin of some constants, especialy of L*a*b*.
Download source code (with preprocessor directives) or plugin of Color Space.
Just another color counter.
A mixture of different color counting algorithm for 8 and 16 bit images by marking, sorting or hashing of the pixels. No one requires any additional memory at all.
Download V1.3 of the source code or plugin of the filter.
If you miss the very useful C preprocessor directives in FilterMeister this functionality can be added by the external preprocessor of sdcc available at sourceforge.
The program sdcpp.exe (40kB, the only file of the package needed)
converts well known C preprocessor directives into FM-code.
The command line options -C and -P are needed for only preprocessing the source and may be -o for the output file,
so a batch call to convert a *.c file for FM would be:
sdcpp -C -P %1 -o %~n1.ffp.
Most editors are able to define a macro for that purpose.
With sdcc every C preprocessor directive can be used in FM.
The most useful features are #define for constants or (simple)
functions and #if,#else,#endif, so it's possible to write one source
for different plugin versions (demo, light, pro),
by doing only compilations with different command line options
With #include it's also possible to split up a source into different function blocks.
And finally when FM is able to handle C preprocessor directives itself the same source can still be used only with one compilation step less.
Useful macro examples:
// convert 8-bit pixel to 16-bit:
#define Pixel8to16(x) ((257*(x)+1)>>1)
// convert 16-bit pixel to 8-bit:
#define Pixel16to8(x) ((255*(x)+16320)>>15)
#define MAX_COLOR (imageMode<Gray16Mode?255:32768)
The preprocessor version of the Color Space program above is a good example for the use of C preprocessor directives. Another but more complex example how macros ease programming is a reworked version of performance.ffp of the code library: performance.c.
Copyright © Alois Zingl, Vienna, Austria, Email: , last update March 2010.