Raster Image Filters¶
All editing/modifications on raster frames in Q2Pix are done through filters.
Conceptually, filters can be considered as self-contained programs that take as input a raster image frame along with a set of parameters, and produce as output a new raster frame. Filters may modify the frame’s metadata and pixels.
They fall into two basic categories:
- Metadata filters modify the metadata, e.g.
ResolutionandXMP.
- Pixel filters modify the pixels:
- Geometry filters change the pixel map’s geometry, e.g.
CropandFlip.- Effect filters apply an effect on the input pixels, e.g.
BrightnessandGaussianBlur.
Editing a raster frame in Q2Pix is done by pushing filters into the frame’s edit stack. The final frame is obtained after applying all filters in the edit stack, in sequence: the first filter takes as input the original frame and outputs a new one which in turn is fed as input to the next filter in the stack, and so on until the filter at the top of the stack produces the current frame. These edits are non-destructive, and can be un-done, in reverse sequence, each time popping the top filter out of the edit stack.
Note
Q2Pix does not itself implement pixel filters, but rather uses platform-specific facilities provided by the system frameworks: CoreImage filters on macOS, and Direct2D effects on Windows.
In both cases, the application of multiple filters is optimized by the OS: CI filters and D2D effects do not directly produce pixel maps, but rather act as recipes for producing the output image. The recipes of all individual pixel filters in the edit stack are combined into a compound recipe that produces the final pixel map when the frame is either displayed or exported/saved to a file.
Filters are identified by their name and each accepts a specific set of parameters in the form of a 4D/JSON object.
Pushing a filter to a raster frame is done by passing the filter name and associated parameters to
RasterFrame_PushFilter. To un-do the last filter applied to the frame, call
RasterFrame_PopFilter.
The Q2PixLib component includes high-level methods that hide the details:
RasterFrame_SetOrientationmodifies the orientation attribute in the frame’s metadata. Other methods implemented on top ofRasterFrame_SetOrientationare:
RasterFrame_RotOrientationRightrotates the frame orientation by 90º clockwise.RasterFrame_RotOrientationRightrotates the frame orientation by 90º counter-clockwise.RasterFrame_FlipOrientationHorzflips the frame orientation horizontally.RasterFrame_FlipOrientationVertflips the frame orientation vertically.
RasterFrame_SetDPISizemodifies the frame’s resolution (DPI).
RasterFrame_SetXMPDatamodifies the frame’s XMP metadata.
RasterFrame_Cropcrops the frame’s pixels.
RasterFrame_Scalescales the frame’s pixel map.
RasterFrame_AdjustSizepresents a dialog where the user can set the pixel size and resolution, and modifies the frame by applying theScaleand/orResolutionfilters as needed.
Additionally, there are methods that present 4D dialogs where the user can select an effect and associated parameters:
ImgArea_ApplyEffectImgDlog_GetEffect
The raster filters supported by Q2Pix and their respective parameters are listed in the Raster Filter Reference section of the manual.