Home

QtImageFilterFactory Class Reference

The QtImageFilterFactory class is used to create and manage QtImageFilter objects. More...

 #include <QtImageFilterFactory>

Public Types

Static Public Members

Related Non-Members


Detailed Description

The QtImageFilterFactory class is used to create and manage QtImageFilter objects.

QtImageFilterFactory is part of the QtImageFilters solution, and is used to create instances of the registered image filters. The framework supports many popular image filters by default, among these are gaussian blurring, embossing (see image below), sharpening, defocus, punch/pinch and convolution filters.

The documentation for the createImageFilter() function provides a complete list of all the supported image filters.

Developers can extend the framework with their own custom image filters by deriving from the QtImageFilter class. A list of the currently registered filters, including custom filters, can be retrieved using the imageFilterList() function.

When creating a custom image filter, it must be registered using the registerImageFilter() function before instances can be created using the createImageFilter() function. For example:

     qtRegisterImageFilter<MirrorFilter>(QLatin1String("MirrorFilter"));

     QStringList filters = QtImageFilterFactory::imageFilterList();
     for (int i = 0; i < filters.count(); ++i) {
         m_imageFilters += QtImageFilterFactory::createImageFilter(filters[i]);

The registerImageFilter() function requires an ImageFilterFactoryFunction pointer and the name of the image filter. ImageFilterFactoryFunction is a type definition for a function that can create and return a QtImageFilter object of a given filter type.

Due to compiler limitations, the template version of the registerImageFilter() function is not available on all platforms (the related qtRegisterImageFilter() function is provided as a work-around for the MSVC 6 compiler).

See also QtImageFilter.


Member Type Documentation

typedef QtImageFilterFactory::ImageFilterFactoryFunction

This is a type definition for a pointer to a function with the following signature:

 QtImageFilter *myFilterFactoryFunc(void);

See also registerImageFilter().


Member Function Documentation

QtImageFilter * QtImageFilterFactory::createImageFilter ( const QString & name )   [static]

Creates an instance of the image filter specified by the given name. Returns true if the image filter was successfully initialized; otherwise false.

The given filter must be registered using the registerImageFilter() function. The following image filters are registered by default:

Filter NameFilter OperationSupported Options
ConvolutionFilterCreates a custom convolutionfilterConvolutionKernelMatrix, FilterChannels, FilterBorderPolicy, ConvolutionDivisor, ConvolutionBias
GaussianBlurCreates a gaussian blur filter.Radius, FilterChannels, FilterBorderPolicy
DefocusBlurs the image.FilterChannels, FilterBorderPolicy
HighlightFilterChannels, FilterBorderPolicy
SharpenSharpens the imageFilterChannels, FilterBorderPolicy
SharpenMoreSharpens the imageFilterChannels, FilterBorderPolicy
SharpenEvenMoreSharpens the imageFilterChannels, FilterBorderPolicy
EdgeDetectEdge detection filter
BigEdgeEdge detection filter (gives thicker edges)FilterChannels, FilterBorderPolicy
EmbossEmbosses the image (does not preserve color information)FilterChannels, FilterBorderPolicy
EmbossColorEmbosses the image (tries to preserve color information)FilterChannels, FilterBorderPolicy
NegativeNegates a color channel.FilterChannels, FilterBorderPolicy
RemoveChannelRemoves a color/alpha channelFilterChannels, FilterBorderPolicy
PunchDistorts an image using a pinch/punch effectCenter, Radius, Force. Force should be in the interval [-1.0, 1.0]

See also registerImageFilter().

QStringList QtImageFilterFactory::imageFilterList ()   [static]

Returns a list of the currently registered image filters.

See also registerImageFilter().

void QtImageFilterFactory::registerImageFilter ( const QString & name, ImageFilterFactoryFunction function )   [static]

Registers an image filter factory function, where the given name is associated with the specified factory function returning a image filter object of the specified type.

See also imageFilterList() and createImageFilter().

void QtImageFilterFactory::registerImageFilter ( const QString & name )   [static]

This is a template function, registering the image filter with the given name together with a factory function that returns a new instance of an image filter of type T. For example:

 registerImageFilter<MirrorFilter>(QLatin1String("MirrorFilter"));

Warning: Due to compiler limitations, this function is not available on all platforms. In particular it is not available with MSVC 6; use qtRegisterImageFilter() instead to support that compiler version.

See also createImageFilter().


Related Non-Members

void qtRegisterImageFilter ( const QString & name, T * dummy = 0 )

This function is equivalent to the template version of the QtImageFilterFactory::registerImageFilter() function.It registers the image filter with the given name together with a factory function that returns a new instance of the image filter.

It is provided as a work-around for the MSVC 6 compiler, which doesn't support member template functions. Note that there is no need to pass any value for the dummy parameter; it is only there because of an MSVC 6 limitation.

See also QtImageFilterFactory::registerImageFilter().


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions