scantools
1.0.4
Graphics manipulation with a view towards scanned documents
|
The namespace imageOperations gathers static methods for handling, analyzing and manipulating QImages. More...
Enumerations | |
enum | imageDataFilter { identity , PNG } |
Image Data Filters. More... | |
Functions | |
QImage | deAlpha (const QImage &image, QRgb background=0xFFFFFFFF) |
Removes alpha channel from image. More... | |
QVector< QRgb > | colors (const QImage &image) |
Finds the set of all colors used in a given image. More... | |
bool | isBlackAndWhite (const QImage &image) |
Determine whether an image is black-and-white only. More... | |
bool | isOpaque (const QImage &image) |
Check if the image is opaque. More... | |
QImage | optimizedFormat (const QImage &inputImage) |
Convert image to memory-saving format. More... | |
QImage | simplifyTransparentPixels (const QImage &image) |
Replaces all fully transparent pixels by pixels of color 0x00FFFFFF (="fully transparent white") More... | |
QByteArray | QImageToData (const QImage &image, imageDataFilter filter=identity) |
Returns the image raw data as a consecutive QByteArray. More... | |
QImage | DataToQImage (const QByteArray &data, int width, int height, QImage::Format format, imageDataFilter filter=identity) |
Reconstructs an image from raw data, as written by QImageToData. More... | |
The namespace imageOperations gathers static methods for handling, analyzing and manipulating QImages.
Image Data Filters.
Several image storage formats, including PDF, PNG and TIFF apply losless filter algorithms to the image data before compression. The purpose of these filters is to prepare the image data for optimum compression. The scantools library supports a number of these.
Enumerator | |
---|---|
identity | The image data is returned without modification. |
PNG | Filter defined in the PNG specification. This filter is used in PNG graphics and in PDF files. It combines five methods specified in the PNG Specification ('None', 'Sub', 'Up', 'Average', 'Paeth') and chooses one of these filters for each scanline according to the heurestics 'sum of absolute differences'.
|
Definition at line 146 of file imageOperations.h.
QVector<QRgb> imageOperations::colors | ( | const QImage & | image | ) |
Finds the set of all colors used in a given image.
This method returns a vector containing the colors that used in a given image. No color will appear twice in the vector returned. In particular, if 'image' uses a color index, the method returns a vector that contains only those colors that are actually used. If more than 256 colors are used, an empty vector is returned.
image | Image to be analyzed |
QImage imageOperations::DataToQImage | ( | const QByteArray & | data, |
int | width, | ||
int | height, | ||
QImage::Format | format, | ||
imageDataFilter | filter = identity |
||
) |
Reconstructs an image from raw data, as written by QImageToData.
Reconstructs a QImage from raw data, as written by QImageToData.
data | QByteArray holding the image data. The size of the array must match the size of the data exactly. |
width | Width of the original image |
height | Height of the original image |
format | Format of the original image |
filter | Filter that was used when the raw data was generated. |
QImage imageOperations::deAlpha | ( | const QImage & | image, |
QRgb | background = 0xFFFFFFFF |
||
) |
Removes alpha channel from image.
This method replaces transparent colors with a suitable opaque colors, effectively rendering the image over an opaque image with the given background color.
image | Image whose alpha channel will be removed |
background | Background color |
bool imageOperations::isBlackAndWhite | ( | const QImage & | image | ) |
Determine whether an image is black-and-white only.
This method determines whether the RGB-part of all pixel colors are 0x000000 of 0xFFFFFF.
image | Image to be analyzed |
bool imageOperations::isOpaque | ( | const QImage & | image | ) |
Check if the image is opaque.
image | Image to be analyzed |
QImage imageOperations::optimizedFormat | ( | const QImage & | inputImage | ) |
Convert image to memory-saving format.
This method analyzes the colors in a given image, determines the most memory-efficient format for storing the image and converts it to that format. The output image is guaranteed to be in one of the following formats.
inputImage | Input image. |
QByteArray imageOperations::QImageToData | ( | const QImage & | image, |
imageDataFilter | filter = identity |
||
) |
Returns the image raw data as a consecutive QByteArray.
QImage organises images in scanlines. For efficiency reasons, the size of a scanline can be larger than the number of bytes actually needed to store the pixel data. According to Qt documentation, there is no guarantee that the image data is stored in one connected memory block.
For images in one of the supported formats, this method returns the image data in one consecutive block, with the minimum number of bytes required. If desired, the method applys a lossless filter algorithm on the data, to prepare the image data for optimum compression. The supportes image formats are exactly those returned by optimizedFormat().
image | QImage whose data is returned. |
filter | The filter to be used. |
QImage imageOperations::simplifyTransparentPixels | ( | const QImage & | image | ) |
Replaces all fully transparent pixels by pixels of color 0x00FFFFFF (="fully transparent white")
image | Image to be optimized |