FAQ

Getting Started

Where can I find example source code?

If you look inside your FilterMeister installation directory, you will find lots of examples in the Democodes folder. Depending on where you have installed FilterMeister, the folder might be something like: C:\Program Files\FilterMeister\sourcecode\democodes. There are also coding examples on many pages of this Wiki.

Dialog Questions

How do I hide the FilterMeister logo and default controls?

You can use the NONE keyword with each control in the following manner:

ctl[CTL_LOGO]: NONE

The example above removes the gnome image from the bottom right corner of the plug-in interface. You can use similar code to hide the other built-in controls, such as the CTL_OK and CTL_CANCEL buttons. As of FilterMeister 1.0 Beta 9d, the only control that you can't hide is the CTL_PREVIEW. In some older versions of FilterMeister, there are some other controls you can't hide, and you may need to use a program like [Resource Hacker] to edit the plug-in interface directly.

How do I resize the preview control?

As of FilterMeister 1.0 Beta 9d, you can do this using FilterMeister code, or using a control definition. To create a preview that is 100 DBUs wide, 200 DBUs high, and positioned 10 DBUs from the top left corner, you would use the following control definition:

ctl[CTL_PREVIEW]: MODIFY, Pos=(10,10), Size=(100,200)

or the following in your code:

setCtlPos(CTL_PREVIEW, 10, 10, 100, 200);

If you are stlll using an older version of FilterMeister, you will need to use [Resource Hacker] instead to resize the window. This is how you would do it:

Is there a way of changing the about image screen?

Yes, but not by using FilterMeister code. You can design the about screen as a Windows Bitmap (BMP) file - 256 color images sized to 342 x 195 pixels seems to work best. You must first compile your plug-in into an 8bf file, then load the 8bf file using [Resource Hacker], which is a free download.

Be sure to play around with Resource Hacker, there's a lot of nifty things you can do with it.

How do I prevent the user from resizing the filter dialog window?

Using [Resource Hacker], you need to change WS_THICKFRAME to DS_MODALFRAME in the main dialog resource (FILTERPARAM -> 1033). This works because Modal dialog windows cannot be resized. You have to do this in your compiled .8BF files - although you can modify FilterMeister itself, the changes won't apply to your compiled plug-ins.

How do I create a filter without a dialog?

Take a look at the FilterWithoutDialog.ffp source code in the sourcecode/codelibrary directory. The trick is to put doAction(CA_APPLY); at the very start of your OnFilterStart handler, so the effect is applied immediately.

Common Coding Errors

Why aren't X & Y the same as my image's width and height?

X and Y are the width & height of the "currently processed image" in the preview window. So if your preview window is zoomed out to 33%, you'll be working with an image 1/3rd the size. You can check the current zoom level with the scaleFactor constant, and you should take the scaleFactor into account in your algorithm if you want your image to look correct at all zoom levels. When you press the OK button, X & Y should always be the same as the image's original width & height. You can learn more about built-in constant values on the Constants page.

My plug-in works fine in FilterMeister, but the compiled plug-in hangs

Are you dividing by the scaleFactor or zoomFactor variables anywhere in your code? It's possible for these to take the value 0 in the compiled plug-in , so if you're dividing by them you may trigger a divide by zero error... or worse, you might get an infinitely large number. If you've got a for loop somewhere going from 0 to infinity, well, your plug-in is going to hang. The solution is to check if scaleFactor == 0 before you divide by scaleFactor. If scaleFactor is 0, use an alternate equation with 1 in place of scaleFactor.

My plug-in behaves strangely from time to time and I can't seem to find the cause.

Please check if you initialized important variables to zero. This can be done, e.g., by using instead of

int MyVariable;

the following line:

int MyVariable = 0;

If a variable wasn't initialized, it doesn't necessarily have a value of zero. It can have a random value and that may not be what your code expects.

Does FilterMeister support 16-bit bitdepth images?

The most needed functions like src, pget, pset, getArray and putArray support 16-bit values.

Why does the filter affect only half of my 16-bit image?

You are writing 8-bit values to the 16-bit image buffer. Make sure that you use values ranging from 0 to 32768 and not just 0 to 255. (Photoshop and the Photoshop SDK doesn't use the full range of a 16-bit integer, so the maximum value has to be 32768 instead.)

General Coding Questions

Can I use arrays in my code?

FilterMeister does not support standard C-language arrays. Instead, FilterMeister provides alternative functions like allocArray, putArray and getArray. Or you can dynamically allocate blocks of memory with the malloc function, just like you can in regular C.

Can I write my own user defined functions?

No, FilterMeister doesn't support functions. But you can create a block of code that you trigger as a custom event throughout your code using triggerEvent. You can also call functions in a Windows DLL (Dynamic Link Library) using loadLib, getLibFn, callLib and freeLib.

How do I make some code run only when the plug-in is first launched, not every time the filter runs?

As of recent FilterMeister versions (1.0 Beta 9d), you can use the FME_INIT event to run code the when the plug-in is launched. You need to add the 'initevent' Dialog parameter to your code for this to work. Here us some example code to make work:

%ffp
Dialog: initevent
OnCtl(n): {
  if (e==FME_INIT) {
    // Your code would go here
  }
  return false;
}