• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • graphics API Reference
  • KDE Home
  • Contact Us
 

digikam

  • Digikam
  • DImg
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Digikam::DImg Class Reference

#include <dimg.h>

Inheritance diagram for Digikam::DImg:
Inheritance graph
[legend]

Public Types

enum  ANGLE { ROT90 = 0, ROT180, ROT270, ROTNONE }
 
enum  COLORMODEL {
  COLORMODELUNKNOWN = 0, RGB, GRAYSCALE, MONOCHROME,
  INDEXED, YCBCR, CMYK, CIELAB,
  COLORMODELRAW
}
 
enum  FLIP { HORIZONTAL = 0, VERTICAL }
 
enum  FORMAT {
  NONE = 0, JPEG, PNG, TIFF,
  JP2K, PGF, HEIF, RAW,
  QIMAGE
}
 
enum  PrepareMetadataFlag {
  RemoveOldMetadataPreviews = 1 << 0, CreateNewMetadataPreview = 1 << 1, ResetExifOrientationTag = 1 << 2, CreateNewImageHistoryUUID = 1 << 3,
  PrepareMetadataFlagsAll
}
 

Public Member Functions

 DImg ()
 
 DImg (const QByteArray &filePath, DImgLoaderObserver *const observer=nullptr, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
 DImg (const QString &filePath, DImgLoaderObserver *const observer=nullptr, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
 DImg (const DImg &image)
 
 DImg (const QImage &image)
 
 DImg (uint width, uint height, bool sixteenBit, bool alpha=false, uchar *const data=nullptr, bool copyData=true)
 
 ~DImg ()
 
 ~Private ()
 
HistoryImageId addAsReferredImage (const QString &filePath, HistoryImageId::Type type=HistoryImageId::Intermediate)
 
void addAsReferredImage (const HistoryImageId &id)
 
void addCurrentUniqueImageId (const QString &uuid)
 
void addFilterAction (const FilterAction &action)
 
QVariant attribute (const QString &key) const
 
void bitBlendImage (DColorComposer *const composer, const DImg *const src, int sx, int sy, int w, int h, int dx, int dy, DColorComposer::MultiplicationFlags multiplicationFlags=DColorComposer::NoMultiplication)
 
void bitBlendImageOnColor (DColorComposer *const composer, const DColor &color, int x, int y, int w, int h, DColorComposer::MultiplicationFlags multiplicationFlags=DColorComposer::NoMultiplication)
 
void bitBlendImageOnColor (const DColor &color, int x, int y, int w, int h)
 
void bitBlendImageOnColor (const DColor &color)
 
void bitBltImage (const DImg *const src, int dx, int dy)
 
void bitBltImage (const DImg *const src, int sx, int sy, int dx, int dy)
 
void bitBltImage (const DImg *const src, int sx, int sy, int w, int h, int dx, int dy)
 
void bitBltImage (const uchar *const src, int sx, int sy, int w, int h, int dx, int dy, uint swidth, uint sheight, int sdepth)
 
uchar * bits () const
 
int bitsDepth () const
 
int bytesDepth () const
 
void convertDepth (int depth)
 
void convertToDepthOfImage (const DImg *const otherImage)
 
void convertToEightBit ()
 
QPixmap convertToPixmap () const
 
QPixmap convertToPixmap (IccTransform &monitorICCtrans) const
 
void convertToSixteenBit ()
 
DImg copy () const
 
DImg copy (const QRect &rect) const
 
DImg copy (const QRectF &relativeRect) const
 
DImg copy (int x, int y, int w, int h) const
 
uchar * copyBits () const
 
DImg copyImageData () const
 
DImg copyMetaData () const
 
QImage copyQImage () const
 
QImage copyQImage (const QRect &rect) const
 
QImage copyQImage (const QRectF &relativeRect) const
 
QImage copyQImage (int x, int y, int w, int h) const
 
HistoryImageId createHistoryImageId (const QString &filePath, HistoryImageId::Type type) const
 
QByteArray createImageUniqueId () const
 
void crop (const QRect &rect)
 
void crop (int x, int y, int w, int h)
 
void detach ()
 
FORMAT detectedFormat () const
 
QString embeddedText (const QString &key) const
 
int exifOrientation (const QString &filePath)
 
bool exifRotate (const QString &filePath)
 
QVariant fileOriginData () const
 
void fill (const DColor &color)
 
void flip (FLIP direction)
 
QString format () const
 
IccProfile getIccProfile () const
 
const DImageHistory & getItemHistory () const
 
DImageHistory & getItemHistory ()
 
MetaEngineData getMetadata () const
 
DImageHistory getOriginalImageHistory () const
 
DColor getPixelColor (uint x, uint y) const
 
DColor getSubPixelColor (float x, float y) const
 
DColor getSubPixelColorFast (float x, float y) const
 
QByteArray getUniqueHash () const
 
QByteArray getUniqueHashV2 () const
 
bool hasAlpha () const
 
bool hasAttribute (const QString &key) const
 
bool hasImageHistory () const
 
bool hasTransparentPixels () const
 
uint height () const
 
void imageSavedAs (const QString &savePath)
 
void insertAsReferredImage (int afterHistoryStep, const HistoryImageId &otherImagesId)
 
bool isNull () const
 
bool isReadOnly () const
 
QVariant lastSavedFileOriginData () const
 
QString lastSavedFilePath () const
 
bool load (const QString &filePath, DImgLoaderObserver *const observer=nullptr, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
bool load (const QString &filePath, bool loadMetadata, bool loadICCData, bool loadUniqueHash, bool loadHistory, DImgLoaderObserver *const observer=nullptr, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
bool load (const QString &filePath, int loadFlags, DImgLoaderObserver *const observer, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
bool loadItemInfo (const QString &filePath, bool loadMetadata=true, bool loadICCData=true, bool loadUniqueHash=true, bool loadImageHistory=true)
 
uint numBytes () const
 
uint numPixels () const
 
DImg & operator= (const DImg &image)
 
bool operator== (const DImg &image) const
 
int originalBitDepth () const
 
COLORMODEL originalColorModel () const
 
QString originalFilePath () const
 
QSize originalSize () const
 
void prepareMetadataToSave (const QString &intendedDestPath, const QString &destMimeType, const QString &originalFileName=QString(), PrepareMetadataFlags flags=PrepareMetadataFlagsAll)
 
void prepareMetadataToSave (const QString &intendedDestPath, const QString &destMimeType, bool resetExifOrientationTag)
 
void prepareSubPixelAccess ()
 
 Private ()
 
QImage pureColorMask (ExposureSettingsContainer *const expoSettings) const
 
void putImageData (uint width, uint height, bool sixteenBit, bool alpha, uchar *const data, bool copyData=true)
 
void putImageData (uchar *const data, bool copyData=true)
 
DRawDecoding rawDecodingSettings () const
 
void removeAlphaChannel (const DColor &destColor)
 
void removeAlphaChannel ()
 
void removeAttribute (const QString &key)
 
void reset ()
 
void resetMetaData ()
 
void resize (int w, int h)
 
bool reverseExifRotate (const QString &filePath)
 
bool reverseRotateAndFlip (int orientation)
 
void rotate (ANGLE angle)
 
bool rotateAndFlip (int orientation)
 
bool save (const QString &filePath, FORMAT frm, DImgLoaderObserver *const observer=nullptr)
 
bool save (const QString &filePath, const QString &format, DImgLoaderObserver *const observer=nullptr)
 
QString savedFormat () const
 
uchar * scanLine (uint i) const
 
void setAttribute (const QString &key, const QVariant &value)
 
void setEmbeddedText (const QString &key, const QString &text)
 
void setFileOriginData (const QVariant &data)
 
void setHistoryBranch (bool isBranch=true)
 
void setHistoryBranchAfter (const DImageHistory &historyBeforeBranch, bool isBranch=true)
 
void setHistoryBranchForLastSteps (int numberOfLastHistorySteps, bool isBranch=true)
 
void setIccProfile (const IccProfile &profile)
 
void setItemHistory (const DImageHistory &history)
 
void setMetadata (const MetaEngineData &data)
 
void setPixelColor (uint x, uint y, const DColor &color)
 
bool sixteenBit () const
 
QSize size () const
 
DImg smoothScale (int width, int height, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) const
 
DImg smoothScale (const QSize &destSize, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) const
 
DImg smoothScaleClipped (int width, int height, int clipx, int clipy, int clipwidth, int clipheight) const
 
DImg smoothScaleClipped (const QSize &destSize, const QRect &clip) const
 
DImg smoothScaleSection (int sx, int sy, int sw, int sh, int dw, int dh) const
 
DImg smoothScaleSection (const QRect &sourceRect, const QSize &destSize) const
 
uchar * stripImageData ()
 
void switchOriginToLastSaved ()
 
bool transform (int transformAction)
 
bool wasExifRotated ()
 
uint width () const
 

Static Public Member Functions

static bool clipped (int &x, int &y, int &w, int &h, uint width, uint height)
 
static QString colorModelToString (COLORMODEL colorModel)
 
static FORMAT fileFormat (const QString &filePath)
 
static QStringList fileOriginAttributes ()
 
static QString formatToMimeType (FORMAT frm)
 
static QByteArray getUniqueHash (const QString &filePath)
 
static QByteArray getUniqueHashV2 (const QString &filePath)
 
static bool isAnimatedImage (const QString &filePath)
 
static DImg::FORMAT loaderNameToFormat (const QString &name)
 
static DPluginDImg * pluginForFormat (const QString &format)
 
static QList< DPluginDImg * > pluginsForFile (const QFileInfo &fileInfo, bool magic)
 

Public Attributes

bool alpha
 
QMap< QString, QVariant > attributes
 
unsigned char * data
 
QMap< QString, QString > embeddedText
 
unsigned int height
 
IccProfile iccProfile
 
DImageHistory imageHistory
 
LANCZOS_DATA_TYPE * lanczos_func
 
MetaEngineData metaData
 
bool null
 
bool sixteenBit
 
unsigned int width
 

Detailed Description

Definition at line 61 of file dimg.h.

Member Enumeration Documentation

enum Digikam::DImg::ANGLE
Enumerator
ROT90 
ROT180 
ROT270 
ROTNONE 

Definition at line 81 of file dimg.h.

enum Digikam::DImg::COLORMODEL
Enumerator
COLORMODELUNKNOWN 
RGB 
GRAYSCALE 
MONOCHROME 
INDEXED 
YCBCR 
CMYK 
CIELAB 
COLORMODELRAW 

Definition at line 95 of file dimg.h.

enum Digikam::DImg::FLIP
Enumerator
HORIZONTAL 
VERTICAL 

Definition at line 89 of file dimg.h.

enum Digikam::DImg::FORMAT
Enumerator
NONE 
JPEG 
PNG 
TIFF 
JP2K 
PGF 
HEIF 
RAW 
QIMAGE 

Definition at line 65 of file dimg.h.

enum Digikam::DImg::PrepareMetadataFlag

When saving, several changes to the image metadata are necessary before it can safely be written to the new file.

This method updates the stored DMetadata object in preparation to a subsequent call to save() with the same target file. 'intendedDestPath' is the finally intended file name. Do not give the temporary file name if you are going to save() to a temp file. 'destMimeType' is destination type mime. In some cases, metadata is updated depending on this value. 'originalFileName' is the original file's name, for simplistic history tracking in metadata. This is completely independent from the DImageHistory framework. For the 'flags' see below. Not all steps are optional and can be controlled with flags.

Enumerator
RemoveOldMetadataPreviews 

A small preview can be stored in the metadata.

Remove old preview entries

CreateNewMetadataPreview 

Create a new preview from current image data.

ResetExifOrientationTag 

Set the exif orientation tag to "normal" Applicable if the image data was rotated according to the tag.

CreateNewImageHistoryUUID 

Creates a new UUID for the image history.

Applicable if the file was changed.

PrepareMetadataFlagsAll 

Definition at line 380 of file dimg.h.

Constructor & Destructor Documentation

Digikam::DImg::DImg ( )

Create null image.

DImg is a framework to support 16bits color depth image.

it doesn't aim to be a complete imaging library; it uses QImage/ImageMagick for load/save files which are not supported natively by it. some of the features:

  • Native Image Loaders, for some imageformats which are of interest to us: JPEG (complete), TIFF (mostly complete), PNG (complete), JPEG2000 (complete), RAW (complete through libraw), PGF (complete). For the rest ImageMAgick codecs or qimageloader are used.
  • Metadata preservation: when a file is loaded, its metadata like XMP, IPTC, EXIF, JFIF are read and held in memory. now when you save back the file to the original file or to a different file, the metadata is automatically written. All is delegate to Exiv2 library.
  • Explicitly Shared Container format (see qt docs): this is necessary for performance reasons.
  • 8 bits and 16 bits support: if the file format is 16 bits, it will load up the image in 16bits format (TIFF/PNG/JPEG2000/RAW/PGF support) and all operations are done in 16 bits format, except when the rendering to screen is done, when its converted on the fly to a temporary 8 bits image and then rendered.
  • Basic image manipulation: rotate, flip, color modifications, crop, scale. This has been ported from Imlib2 with 16 bits scaling support and support for scaling of only a section of the image.
  • Rendering to Pixmap: using QImage/QPixmap. (see above for rendering of 16 bits images).
  • Pixel format: the pixel format is different from QImage pixel format. In QImage the pixel data is stored as unsigned ints and to access the individual colors you need to use bit-shifting to ensure endian correctness. in DImg, the pixel data is stored as unsigned char. the color layout is B,G,R,A (blue, green, red, alpha)

for 8 bits images: you can access individual color components like this:

uchar* const pixels = image.bits();

for (int i = 0 ; i < image.width() * image.height() ; ++i) { pixel[0] // blue pixel[1] // green pixel[2] // red pixel[3] // alpha

pixel += 4; // go to next pixel }

and for 16 bits images:

ushort* const pixels = (ushort*)image.bits();

for (int i = 0 ; i < image.width() * image.height() ; ++i) { pixel[0] // blue pixel[1] // green pixel[2] // red pixel[3] // alpha

pixel += 4; // go to next pixel }

The above is true for both big and little endian platforms. What this also means is that the pixel format is different from that of QImage for big endian machines. Functions are provided if you want to get a copy of the DImg as a QImage.

Definition at line 105 of file dimg.cpp.

Digikam::DImg::DImg ( const QByteArray &  filePath,
DImgLoaderObserver *const  observer = nullptr,
const DRawDecoding &  rawDecodingSettings = DRawDecoding() 
)
explicit

Load image using QByteArray as file path.

Definition at line 110 of file dimg.cpp.

Digikam::DImg::DImg ( const QString &  filePath,
DImgLoaderObserver *const  observer = nullptr,
const DRawDecoding &  rawDecodingSettings = DRawDecoding() 
)
explicit

Load image using QString as file path.

Definition at line 118 of file dimg.cpp.

Digikam::DImg::DImg ( const DImg &  image)

Copy image: Creates a shallow copy that refers to the same shared data.

The two images will be equal. Call detach() or copy() to create deep copies.

Definition at line 126 of file dimg.cpp.

Digikam::DImg::DImg ( const QImage &  image)
explicit

Copy image: Creates a copy of a QImage object.

If the QImage is null, a null DImg will be created.

Definition at line 149 of file dimg.cpp.

Digikam::DImg::DImg ( uint  width,
uint  height,
bool  sixteenBit,
bool  alpha = false,
uchar *const  data = nullptr,
bool  copyData = true 
)

Create image from data.

If data is 0, a new buffer will be allocated, otherwise the given data will be used: If copydata is true, the data will be copied to a newly allocated buffer. If copyData is false, this DImg object will take ownership of the data pointer. If there is an alpha channel, the data shall be in non-premultiplied form (unassociated alpha).

Definition at line 131 of file dimg.cpp.

Digikam::DImg::~DImg ( )

Definition at line 188 of file dimg.cpp.

Digikam::DImg::~Private ( )
inline

Definition at line 138 of file dimg_p.h.

Member Function Documentation

HistoryImageId Digikam::DImg::addAsReferredImage ( const QString &  filePath,
HistoryImageId::Type  type = HistoryImageId::Intermediate 
)

If you have saved this DImg to filePath, and want to continue using this DImg object to add further changes to the image history, you can call this method to add to the image history a reference to the just saved image.

First call updateMetadata(), then call save(), then call addAsReferredImage(). Do not call this directly after loading, before applying any changes: The history is correctly initialized when loading. If you need to insert the referred file to an entry which is not the last entry, which may happen if the added image was saved after this image's history was created, you can use insertAsReferredImage. The added id is returned.

Definition at line 318 of file dimg_metadata.cpp.

void Digikam::DImg::addAsReferredImage ( const HistoryImageId &  id)

Definition at line 327 of file dimg_metadata.cpp.

void Digikam::DImg::addCurrentUniqueImageId ( const QString &  uuid)

In the history, adjusts the UUID of the ImageHistoryId of the current file.

Call this if you have associated a UUID with this file which is not written to the metadata. If there is already a UUID present, read from metadata, it will not be replaced.

Definition at line 337 of file dimg_metadata.cpp.

void Digikam::DImg::addFilterAction ( const FilterAction &  action)

Definition at line 342 of file dimg_metadata.cpp.

QVariant Digikam::DImg::attribute ( const QString &  key) const

Definition at line 210 of file dimg_props.cpp.

void Digikam::DImg::bitBlendImage ( DColorComposer *const  composer,
const DImg *const  src,
int  sx,
int  sy,
int  w,
int  h,
int  dx,
int  dy,
DColorComposer::MultiplicationFlags  multiplicationFlags = DColorComposer::NoMultiplication 
)

Blend src image on this image (this is dest) with the specified composer and multiplication flags.

See documentation of DColorComposer for more info. For the other arguments, see documentation of bitBltImage above.

Definition at line 188 of file dimg_bitsops.cpp.

void Digikam::DImg::bitBlendImageOnColor ( DColorComposer *const  composer,
const DColor &  color,
int  x,
int  y,
int  w,
int  h,
DColorComposer::MultiplicationFlags  multiplicationFlags = DColorComposer::NoMultiplication 
)

For the specified region, blend this image on the given color with the specified composer and multiplication flags.

See documentation of DColorComposer for more info. Note that the result pixel is again written to this image, which is, for the blending, source.

Definition at line 261 of file dimg_bitsops.cpp.

void Digikam::DImg::bitBlendImageOnColor ( const DColor &  color,
int  x,
int  y,
int  w,
int  h 
)

Definition at line 251 of file dimg_bitsops.cpp.

void Digikam::DImg::bitBlendImageOnColor ( const DColor &  color)

Definition at line 246 of file dimg_bitsops.cpp.

void Digikam::DImg::bitBltImage ( const DImg *const  src,
int  dx,
int  dy 
)

Copy a region of pixels from a source image to this image.

Parameters: sx|sy Coordinates in the source image of the rectangle to be copied w h Width and height of the rectangle (Default, or when both are -1: whole source image) dx|dy Coordinates in this image of the rectangle in which the region will be copied (Default: 0|0) The bit depth of source and destination must be identical.

Definition at line 32 of file dimg_bitsops.cpp.

void Digikam::DImg::bitBltImage ( const DImg *const  src,
int  sx,
int  sy,
int  dx,
int  dy 
)

Definition at line 37 of file dimg_bitsops.cpp.

void Digikam::DImg::bitBltImage ( const DImg *const  src,
int  sx,
int  sy,
int  w,
int  h,
int  dx,
int  dy 
)

Definition at line 42 of file dimg_bitsops.cpp.

void Digikam::DImg::bitBltImage ( const uchar *const  src,
int  sx,
int  sy,
int  w,
int  h,
int  dx,
int  dy,
uint  swidth,
uint  sheight,
int  sdepth 
)

Definition at line 65 of file dimg_bitsops.cpp.

uchar * Digikam::DImg::bits ( ) const

Definition at line 51 of file dimg_props.cpp.

int Digikam::DImg::bitsDepth ( ) const

Return the number of bits depth of one color component for one pixel : 8 (non sixteenBit) or 16 (sixteen)

Definition at line 195 of file dimg_props.cpp.

int Digikam::DImg::bytesDepth ( ) const

Return the number of bytes depth of one pixel : 4 (non sixteenBit) or 8 (sixteen)

Definition at line 185 of file dimg_props.cpp.

static bool Digikam::DImg::clipped ( int &  x,
int &  y,
int &  w,
int &  h,
uint  width,
uint  height 
)
inlinestatic

x,y, w x h is a section of the image.

The image size is width x height. Clips the section to the bounds of the image. Returns if the (clipped) section is a valid rectangle.

Definition at line 253 of file dimg_p.h.

QString Digikam::DImg::colorModelToString ( COLORMODEL  colorModel)
static

Helper method to translate enum values to user presentable strings.

Definition at line 407 of file dimg_metadata.cpp.

void Digikam::DImg::convertDepth ( int  depth)

Convert depth of image.

Depth is bytesDepth * bitsDepth. If depth is 32, converts to 8 bits, if depth is 64, converts to 16 bits.

Definition at line 53 of file dimg_colors.cpp.

void Digikam::DImg::convertToDepthOfImage ( const DImg *const  otherImage)

Definition at line 41 of file dimg_colors.cpp.

void Digikam::DImg::convertToEightBit ( )

Definition at line 36 of file dimg_colors.cpp.

QPixmap Digikam::DImg::convertToPixmap ( ) const

Definition at line 61 of file dimg_qpixmap.cpp.

QPixmap Digikam::DImg::convertToPixmap ( IccTransform &  monitorICCtrans) const

Definition at line 107 of file dimg_qpixmap.cpp.

void Digikam::DImg::convertToSixteenBit ( )

Wrapper methods for convertDepth.

Definition at line 31 of file dimg_colors.cpp.

DImg Digikam::DImg::copy ( ) const

Return a deep copy of full image.

Definition at line 31 of file dimg_copy.cpp.

DImg Digikam::DImg::copy ( const QRect &  rect) const

Return a region of image.

Definition at line 59 of file dimg_copy.cpp.

DImg Digikam::DImg::copy ( const QRectF &  relativeRect) const

Definition at line 67 of file dimg_copy.cpp.

DImg Digikam::DImg::copy ( int  x,
int  y,
int  w,
int  h 
) const

Definition at line 81 of file dimg_copy.cpp.

uchar * Digikam::DImg::copyBits ( ) const

Definition at line 56 of file dimg_props.cpp.

DImg Digikam::DImg::copyImageData ( ) const

Return a deep copy of the image, but do not include metadata.

Definition at line 39 of file dimg_copy.cpp.

DImg Digikam::DImg::copyMetaData ( ) const

Return an image that contains a deep copy of this image's metadata and the information associated with the image data (width, height, hasAlpha, sixteenBit), but no image data, i.e.

isNull() is true.

Definition at line 46 of file dimg_copy.cpp.

QImage Digikam::DImg::copyQImage ( ) const

QImage wrapper methods.

Definition at line 31 of file dimg_qimage.cpp.

QImage Digikam::DImg::copyQImage ( const QRect &  rect) const

Definition at line 71 of file dimg_qimage.cpp.

QImage Digikam::DImg::copyQImage ( const QRectF &  relativeRect) const

Definition at line 76 of file dimg_qimage.cpp.

QImage Digikam::DImg::copyQImage ( int  x,
int  y,
int  w,
int  h 
) const

Definition at line 90 of file dimg_qimage.cpp.

HistoryImageId Digikam::DImg::createHistoryImageId ( const QString &  filePath,
HistoryImageId::Type  type 
) const

Create a HistoryImageId for this image already saved at the given file path.

Definition at line 290 of file dimg_metadata.cpp.

QByteArray Digikam::DImg::createImageUniqueId ( ) const

This method creates a new 256-bit UUID meant to be globally unique.

The UUID will be returned as a 64-byte hexadecimal string. At least 128bits of the UUID will be created by the platform random number generator. The rest may be created from a content-based hash similar to the uniqueHash, see above. This method only generates a new UUID for this image without in any way changing this image object or saving the UUID anywhere.

Definition at line 103 of file dimg_metadata.cpp.

void Digikam::DImg::crop ( const QRect &  rect)

Crop image to the specified region.

Definition at line 31 of file dimg_transform.cpp.

void Digikam::DImg::crop ( int  x,
int  y,
int  w,
int  h 
)

Definition at line 36 of file dimg_transform.cpp.

void Digikam::DImg::detach ( )

Detaches from shared data and makes sure that this image is the only one referring to the data.

If multiple images share common data, this image makes a copy of the data and detaches itself from the sharing mechanism. Nothing is done if there is just a single reference.

Definition at line 47 of file dimg_data.cpp.

DImg::FORMAT Digikam::DImg::detectedFormat ( ) const

Returns the file format in form of the FORMAT enum that was detected in the load() method.

Other than the format attribute which is written by the DImgLoader, this can include the QIMAGE or NONE values. Returns NONE for images that have not been loaded. For unknown image formats, a value of QIMAGE can be returned to indicate that the QImage-based loader will have been used. To find out if this has worked, check the return value you got from load().

Definition at line 121 of file dimg_props.cpp.

QString Digikam::DImg::embeddedText ( const QString &  key) const
int Digikam::DImg::exifOrientation ( const QString &  filePath)

Retrieves the Exif orientation, either from the LoadSaveThread info provider if available, or from the metadata.

Definition at line 456 of file dimg_metadata.cpp.

bool Digikam::DImg::exifRotate ( const QString &  filePath)

Definition at line 553 of file dimg_transform.cpp.

DImg::FORMAT Digikam::DImg::fileFormat ( const QString &  filePath)
static

Identify file format.

Definition at line 317 of file dimg_fileio.cpp.

static QStringList Digikam::DImg::fileOriginAttributes ( )
inlinestatic

Definition at line 232 of file dimg_p.h.

QVariant Digikam::DImg::fileOriginData ( ) const

When loaded from a file, some attributes like format and isReadOnly still depend on this originating file.

When saving in a different format to a different file, you may wish to switch these attributes to the new file.

  • fileOriginData() returns the current origin data, bundled in the returned QVariant.
  • setFileOriginData() takes such a variant and adjusts the properties
  • lastSavedFileOriginData() returns the origin data as if the image was loaded from the last saved image.
  • switchOriginToLastSaved is equivalent to setting origin data returned from lastSavedFileOriginData()

Example: an image loaded from a RAW and saved to PNG will be read-only and format RAW. After calling switchOriginToLastSaved, it will not be read-only, format will be PNG, and rawDecodingSettings will be null. detectedFormat() will not change. In the history, the last referred image that was added (as intermediate) is made the new Current image. NOTE: Set the saved image path with imageSavedAs() before!

Definition at line 261 of file dimg_props.cpp.

void Digikam::DImg::fill ( const DColor &  color)

Fill whole image with specified color.

The bit depth of the color must be identical to the depth of this image.

Definition at line 124 of file dimg_colors.cpp.

void Digikam::DImg::flip ( FLIP  direction)

Definition at line 282 of file dimg_transform.cpp.

QString Digikam::DImg::format ( ) const

Returns the format string as written by the image loader this image was originally loaded from.

Format strings used include JPEG, PNG, TIFF, PGF, JP2K, RAW, PPM. For images loaded with the platform QImage loader, the file suffix is used. Returns null if this DImg was not loaded from a file, but created in memory.

Definition at line 133 of file dimg_props.cpp.

QString Digikam::DImg::formatToMimeType ( FORMAT  frm)
static

Definition at line 209 of file dimg_fileio.cpp.

IccProfile Digikam::DImg::getIccProfile ( ) const

Definition at line 155 of file dimg_props.cpp.

const DImageHistory & Digikam::DImg::getItemHistory ( ) const

Definition at line 347 of file dimg_metadata.cpp.

DImageHistory & Digikam::DImg::getItemHistory ( )

Definition at line 352 of file dimg_metadata.cpp.

MetaEngineData Digikam::DImg::getMetadata ( ) const

Metadata manipulation methods.

Definition at line 165 of file dimg_props.cpp.

DImageHistory Digikam::DImg::getOriginalImageHistory ( ) const

Definition at line 374 of file dimg_metadata.cpp.

DColor Digikam::DImg::getPixelColor ( uint  x,
uint  y 
) const

Access a single pixel of the image.

These functions add some safety checks and then use the methods from DColor. In optimized code working directly on the data, better use the inline methods from DColor.

Definition at line 340 of file dimg_props.cpp.

DColor Digikam::DImg::getSubPixelColor ( float  x,
float  y 
) const

Definition at line 429 of file dimg_props.cpp.

DColor Digikam::DImg::getSubPixelColorFast ( float  x,
float  y 
) const

Definition at line 548 of file dimg_props.cpp.

QByteArray Digikam::DImg::getUniqueHash ( ) const

This methods return a 128-bit MD5 hex digest which is meant to uniquely identify the file.

The hash is calculated on parts of the file and the file metadata. It cannot be used to find similar images. It is not calculated from the image data. The hash will be returned as a 32-byte hexadecimal string.

If you already have a DImg object of the file, use the member method. The object does not need to have the full image data loaded, but it shall at least have been loaded with loadItemInfo with loadMetadata = true, or have the metadata set later with setComments, setExif, setIptc, setXmp. If the object does not have the metadata loaded, a non-null, but invalid hash will be returned! In this case, use the static method. If the image has been loaded with loadUniqueHash = true, the hash can be retrieved with the member method.

You do not need a DImg object of the file to retrieve the unique hash; Use the static method and pass just the file path.

Definition at line 31 of file dimg_metadata.cpp.

QByteArray Digikam::DImg::getUniqueHash ( const QString &  filePath)
static

Definition at line 62 of file dimg_metadata.cpp.

QByteArray Digikam::DImg::getUniqueHashV2 ( ) const

This methods return a 128-bit MD5 hex digest which is meant to uniquely identify the file.

The hash is calculated on parts of the file. It cannot be used to find similar images. It is not calculated from the image data. The hash will be returned as a 32-byte hexadecimal string.

If you already have a DImg object loaded from the file, use the member method. If the image has been loaded with loadUniqueHash = true, the hash will already be available.

You do not need a DImg object of the file to retrieve the unique hash; Use the static method and pass just the file path.

Definition at line 70 of file dimg_metadata.cpp.

QByteArray Digikam::DImg::getUniqueHashV2 ( const QString &  filePath)
static

Definition at line 98 of file dimg_metadata.cpp.

bool Digikam::DImg::hasAlpha ( ) const

Definition at line 74 of file dimg_props.cpp.

bool Digikam::DImg::hasAttribute ( const QString &  key) const

Definition at line 220 of file dimg_props.cpp.

bool Digikam::DImg::hasImageHistory ( ) const

Definition at line 362 of file dimg_metadata.cpp.

bool Digikam::DImg::hasTransparentPixels ( ) const

If the image has an alpha channel, check if there exist pixels which actually have non-opaque color, that is alpha < 1.0.

Note that all pixels are scanned to reach a return value of "false". If hasAlpha() is false, always returns false.

Definition at line 635 of file dimg_props.cpp.

uint Digikam::DImg::height ( ) const
void Digikam::DImg::imageSavedAs ( const QString &  savePath)

It is common that images are not directly saved to the destination path.

For this reason, save() does not call addAsReferredImage(), and the stored save path may be wrong. Call this method after save() with the final destination path. This path will be stored in the image history as well.

Definition at line 245 of file dimg_props.cpp.

void Digikam::DImg::insertAsReferredImage ( int  afterHistoryStep,
const HistoryImageId &  otherImagesId 
)

Definition at line 332 of file dimg_metadata.cpp.

bool Digikam::DImg::isAnimatedImage ( const QString &  filePath)
static

Return true if image file is an animation, as GIFa or NMG.

Definition at line 441 of file dimg_metadata.cpp.

bool Digikam::DImg::isNull ( ) const

Definition at line 31 of file dimg_props.cpp.

bool Digikam::DImg::isReadOnly ( ) const

Return true if the original image file format cannot be saved.

This is depending of DImgLoader::save() implementation. For example RAW file formats are supported by DImg using dcraw than cannot support writing operations.

Definition at line 84 of file dimg_props.cpp.

QVariant Digikam::DImg::lastSavedFileOriginData ( ) const

Definition at line 278 of file dimg_props.cpp.

QString Digikam::DImg::lastSavedFilePath ( ) const

Returns the file path to which this DImg was saved.

Returns the file path set with imageSavedAs(), if that was not called, save(), if that was not called, a null string.

Definition at line 256 of file dimg_props.cpp.

bool Digikam::DImg::load ( const QString &  filePath,
DImgLoaderObserver *const  observer = nullptr,
const DRawDecoding &  rawDecodingSettings = DRawDecoding() 
)

Definition at line 59 of file dimg_fileio.cpp.

bool Digikam::DImg::load ( const QString &  filePath,
bool  loadMetadata,
bool  loadICCData,
bool  loadUniqueHash,
bool  loadHistory,
DImgLoaderObserver *const  observer = nullptr,
const DRawDecoding &  rawDecodingSettings = DRawDecoding() 
)

Definition at line 66 of file dimg_fileio.cpp.

bool Digikam::DImg::load ( const QString &  filePath,
int  loadFlags,
DImgLoaderObserver *const  observer,
const DRawDecoding &  rawDecodingSettings = DRawDecoding() 
)

Definition at line 99 of file dimg_fileio.cpp.

static DImg::FORMAT Digikam::DImg::loaderNameToFormat ( const QString &  name)
inlinestatic

Definition at line 193 of file dimg_p.h.

bool Digikam::DImg::loadItemInfo ( const QString &  filePath,
bool  loadMetadata = true,
bool  loadICCData = true,
bool  loadUniqueHash = true,
bool  loadImageHistory = true 
)

Loads most parts of the meta information, but never the image data.

If loadMetadata is true, the metadata will be available with getComments, getExif, getIptc, getXmp . If loadICCData is true, the ICC profile will be available with getICCProfile.

Definition at line 32 of file dimg_fileio.cpp.

uint Digikam::DImg::numBytes ( ) const

Definition at line 175 of file dimg_props.cpp.

uint Digikam::DImg::numPixels ( ) const

Definition at line 180 of file dimg_props.cpp.

DImg & Digikam::DImg::operator= ( const DImg &  image)

Equivalent to the copy constructor.

Definition at line 31 of file dimg_data.cpp.

bool Digikam::DImg::operator== ( const DImg &  image) const

Returns whether two images are equal.

Two images are equal if and only if they refer to the same shared data. (Thus, DImg() == DImg() is not true, both instances refer two their own shared data. image == DImg(image) is true.) If two or more images refer to the same data, they have the same image data, bits() returns the same data, they have the same metadata, and a change to one image also affects the others. Call detach() to split one image from the group of equal images.

Definition at line 37 of file dimg_data.cpp.

int Digikam::DImg::originalBitDepth ( ) const

Returns the bit depth (in bits per channel, e.g.

8 or 16) of the original file.

Definition at line 101 of file dimg_props.cpp.

DImg::COLORMODEL Digikam::DImg::originalColorModel ( ) const

Returns the color model in which the image was stored in the file.

The color space of the loaded image data is always RGB.

Definition at line 89 of file dimg_props.cpp.

QString Digikam::DImg::originalFilePath ( ) const

Returns the file path from which this DImg was originally loaded.

Returns a null string if the DImg was not loaded from a file.

Definition at line 251 of file dimg_props.cpp.

QSize Digikam::DImg::originalSize ( ) const

Returns the size of the original file.

Definition at line 106 of file dimg_props.cpp.

static DPluginDImg* Digikam::DImg::pluginForFormat ( const QString &  format)
inlinestatic

Definition at line 167 of file dimg_p.h.

static QList<DPluginDImg*> Digikam::DImg::pluginsForFile ( const QFileInfo &  fileInfo,
bool  magic 
)
inlinestatic

Definition at line 144 of file dimg_p.h.

void Digikam::DImg::prepareMetadataToSave ( const QString &  intendedDestPath,
const QString &  destMimeType,
const QString &  originalFileName = QString(),
PrepareMetadataFlags  flags = PrepareMetadataFlagsAll 
)

Definition at line 126 of file dimg_metadata.cpp.

void Digikam::DImg::prepareMetadataToSave ( const QString &  intendedDestPath,
const QString &  destMimeType,
bool  resetExifOrientationTag 
)

For convenience: Including all flags, except for ResetExifOrientationTag which can be selected.

Uses originalFilePath() to fill the original file name.

Definition at line 112 of file dimg_metadata.cpp.

void Digikam::DImg::prepareSubPixelAccess ( )

Definition at line 353 of file dimg_props.cpp.

Digikam::DImg::Private ( )
inlineexplicit

Definition at line 127 of file dimg_p.h.

QImage Digikam::DImg::pureColorMask ( ExposureSettingsContainer *const  expoSettings) const

Return a mask image where pure white and pure black pixels are over-colored.

This way is used to identify over and under exposed pixels.

Definition at line 125 of file dimg_qpixmap.cpp.

void Digikam::DImg::putImageData ( uint  width,
uint  height,
bool  sixteenBit,
bool  alpha,
uchar *const  data,
bool  copyData = true 
)

Replaces image data of this object.

Metadata is unchanged. Parameters like constructor above.

Definition at line 68 of file dimg_data.cpp.

void Digikam::DImg::putImageData ( uchar *const  data,
bool  copyData = true 
)

Overloaded function, provided for convenience, behaves essentially like the function above if data is not 0.

Uses current width, height, sixteenBit, and alpha values. If data is 0, the current data is deleted and the image is set to null (But metadata unchanged).

Definition at line 107 of file dimg_data.cpp.

DRawDecoding Digikam::DImg::rawDecodingSettings ( ) const

Returns the DRawDecoding options that this DImg was loaded with.

If this is not a RAW image or no options were specified, returns DRawDecoding().

Definition at line 143 of file dimg_props.cpp.

void Digikam::DImg::removeAlphaChannel ( const DColor &  destColor)

If the image has an alpha channel and transparent pixels, it will be blended on the specified color and the alpha channel will be removed.

This is a no-op if hasTransparentPixels() is false, but this method can be expensive, therefore it is not checked inside removeAlphaChannel(). (the trivial hasAlpha() is checked)

Definition at line 173 of file dimg_colors.cpp.

void Digikam::DImg::removeAlphaChannel ( )

Definition at line 168 of file dimg_colors.cpp.

void Digikam::DImg::removeAttribute ( const QString &  key)

Definition at line 225 of file dimg_props.cpp.

void Digikam::DImg::reset ( )

Reset metadata and image data to null image.

Definition at line 42 of file dimg_data.cpp.

void Digikam::DImg::resetMetaData ( )

Reset metadata, but do not change image data.

Definition at line 125 of file dimg_data.cpp.

void Digikam::DImg::resize ( int  w,
int  h 
)

Set width and height of this image, smoothScale it to the given size.

Definition at line 55 of file dimg_transform.cpp.

bool Digikam::DImg::reverseExifRotate ( const QString &  filePath)

Reverses the previous function.

Definition at line 565 of file dimg_transform.cpp.

bool Digikam::DImg::reverseRotateAndFlip ( int  orientation)

Reverses the previous function.

Definition at line 469 of file dimg_transform.cpp.

void Digikam::DImg::rotate ( ANGLE  angle)

Definition at line 69 of file dimg_transform.cpp.

bool Digikam::DImg::rotateAndFlip ( int  orientation)

Rotates and/or flip the DImg according to the given DMetadata::Orientation, so that the current state is orientation and the resulting step is normal orientation.

Returns true if the image was actually rotated or flipped (e.g. if ORIENTATION_NORMAL is given, returns false, because no action is taken).

Definition at line 418 of file dimg_transform.cpp.

bool Digikam::DImg::save ( const QString &  filePath,
FORMAT  frm,
DImgLoaderObserver *const  observer = nullptr 
)

Definition at line 260 of file dimg_fileio.cpp.

bool Digikam::DImg::save ( const QString &  filePath,
const QString &  format,
DImgLoaderObserver *const  observer = nullptr 
)

Definition at line 270 of file dimg_fileio.cpp.

QString Digikam::DImg::savedFormat ( ) const

Returns the format string of the format that this image was last saved to.

An image can be loaded from a file - retrieve that format with fileFormat() and loadedFormat() - and can the multiple times be saved to different formats. Format strings used include JPG, PGF, PNG, TIFF and JP2K. If this file was not save, a null string is returned.

Definition at line 138 of file dimg_props.cpp.

uchar * Digikam::DImg::scanLine ( uint  i) const

Definition at line 63 of file dimg_props.cpp.

void Digikam::DImg::setAttribute ( const QString &  key,
const QVariant &  value 
)

Definition at line 205 of file dimg_props.cpp.

void Digikam::DImg::setEmbeddedText ( const QString &  key,
const QString &  text 
)

Definition at line 230 of file dimg_props.cpp.

void Digikam::DImg::setFileOriginData ( const QVariant &  data)

Definition at line 319 of file dimg_props.cpp.

void Digikam::DImg::setHistoryBranch ( bool  isBranch = true)

Definition at line 379 of file dimg_metadata.cpp.

void Digikam::DImg::setHistoryBranchAfter ( const DImageHistory &  historyBeforeBranch,
bool  isBranch = true 
)

Sets a step in the history to constitute the beginning of a branch.

Use setHistoryBranch() to take getOriginalImageHistory() and set the first added step as a branch. Use setHistoryBranchForLastSteps(n) to start the branch before the last n steps in the history. (Assume the history had 3 steps and you added 2, call setHistoryBranchForLastSteps(2)) Use setHistoryBranchAfter() if have a copy of the history before branching, the first added step on top of that history will be made a branch.

Definition at line 384 of file dimg_metadata.cpp.

void Digikam::DImg::setHistoryBranchForLastSteps ( int  numberOfLastHistorySteps,
bool  isBranch = true 
)

Definition at line 390 of file dimg_metadata.cpp.

void Digikam::DImg::setIccProfile ( const IccProfile &  profile)

Definition at line 160 of file dimg_props.cpp.

void Digikam::DImg::setItemHistory ( const DImageHistory &  history)

Definition at line 357 of file dimg_metadata.cpp.

void Digikam::DImg::setMetadata ( const MetaEngineData &  data)

Definition at line 170 of file dimg_props.cpp.

void Digikam::DImg::setPixelColor ( uint  x,
uint  y,
const DColor &  color 
)

Definition at line 618 of file dimg_props.cpp.

bool Digikam::DImg::sixteenBit ( ) const
QSize Digikam::DImg::size ( ) const

Definition at line 46 of file dimg_props.cpp.

DImg Digikam::DImg::smoothScale ( int  width,
int  height,
Qt::AspectRatioMode  aspectRatioMode = Qt::IgnoreAspectRatio 
) const

Return a version of this image scaled to the specified size with the specified mode.

See QSize documentation for information on available modes

Definition at line 179 of file dimg_scale.cpp.

DImg Digikam::DImg::smoothScale ( const QSize &  destSize,
Qt::AspectRatioMode  aspectRatioMode = Qt::IgnoreAspectRatio 
) const

Definition at line 166 of file dimg_scale.cpp.

DImg Digikam::DImg::smoothScaleClipped ( int  width,
int  height,
int  clipx,
int  clipy,
int  clipwidth,
int  clipheight 
) const

Executes the same scaling as smoothScale(width, height), but from the result of this call, returns only the section specified by clipx, clipy, clipwidth, clipheight.

This is thus equivalent to calling Dimg scaled = smoothScale(width, height); scaled.crop(clipx, clipy, clipwidth, clipheight); but potentially much faster. In smoothScaleSection, you specify the source region, here, the result region. It will often not be possible to find integer source coordinates for a result region!

Definition at line 190 of file dimg_scale.cpp.

DImg Digikam::DImg::smoothScaleClipped ( const QSize &  destSize,
const QRect &  clip 
) const

Definition at line 184 of file dimg_scale.cpp.

DImg Digikam::DImg::smoothScaleSection ( int  sx,
int  sy,
int  sw,
int  sh,
int  dw,
int  dh 
) const

Take the region specified by the rectangle sx|sy, width and height sw * sh, and scale it to an image with size dw * dh.

Definition at line 270 of file dimg_scale.cpp.

DImg Digikam::DImg::smoothScaleSection ( const QRect &  sourceRect,
const QSize &  destSize 
) const

Definition at line 264 of file dimg_scale.cpp.

uchar * Digikam::DImg::stripImageData ( )

Returns the data of this image.

Ownership of the buffer is passed to the caller, this image will be null afterwards.

Definition at line 132 of file dimg_data.cpp.

void Digikam::DImg::switchOriginToLastSaved ( )

Definition at line 335 of file dimg_props.cpp.

bool Digikam::DImg::transform ( int  transformAction)

Rotates and/or flip the DImg according to the given transform action, which is a MetaEngineRotation::TransformAction.

Returns true if the image was actually rotated or flipped.

Definition at line 520 of file dimg_transform.cpp.

bool Digikam::DImg::wasExifRotated ( )

Utility to make sure that an image is rotated according to Exif tag.

Detects if an image has previously already been rotated: You can call this method more than one time on the same image. Returns true if the image has actually been rotated or flipped. Returns false if a rotation was not needed.

Definition at line 547 of file dimg_transform.cpp.

uint Digikam::DImg::width ( ) const

Member Data Documentation

bool Digikam::DImg::alpha

Definition at line 275 of file dimg_p.h.

QMap<QString, QVariant> Digikam::DImg::attributes

Definition at line 285 of file dimg_p.h.

unsigned char* Digikam::DImg::data

Definition at line 281 of file dimg_p.h.

QString Digikam::DImg::embeddedText

Definition at line 286 of file dimg_p.h.

uint Digikam::DImg::height

Definition at line 279 of file dimg_p.h.

IccProfile Digikam::DImg::iccProfile

Definition at line 287 of file dimg_p.h.

DImageHistory Digikam::DImg::imageHistory

Definition at line 288 of file dimg_p.h.

LANCZOS_DATA_TYPE* Digikam::DImg::lanczos_func

Definition at line 282 of file dimg_p.h.

MetaEngineData Digikam::DImg::metaData

Definition at line 284 of file dimg_p.h.

bool Digikam::DImg::null

Definition at line 274 of file dimg_p.h.

bool Digikam::DImg::sixteenBit

Definition at line 276 of file dimg_p.h.

uint Digikam::DImg::width

Definition at line 278 of file dimg_p.h.


The documentation for this class was generated from the following files:
  • dimg.h
  • dimg_p.h
  • dimg.cpp
  • dimg_bitsops.cpp
  • dimg_colors.cpp
  • dimg_copy.cpp
  • dimg_data.cpp
  • dimg_fileio.cpp
  • dimg_metadata.cpp
  • dimg_props.cpp
  • dimg_qimage.cpp
  • dimg_qpixmap.cpp
  • dimg_scale.cpp
  • dimg_transform.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Fri Dec 6 2019 04:27:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

digikam

Skip menu "digikam"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages
-->

graphics API Reference

Skip menu "graphics API Reference"
  • digikam
  • KDiagram
  •     KChart
  •     KGantt
  • KPhotoAlbum
  •   AndroidRemoteControl
  • Krita
  •   libs
  •     KritaBasicFlakes
  •     brush
  •     KritaUndo2
  •     KritaFlake
  •     image
  •     KritaPlugin
  •     Krita
  •     KritaOdf
  •     KritaPigment
  •     KritaStore
  •     ui
  •     KritaWidgets
  •     KritaWidgetUtils
  •   plugins
  •     Assitants
  •     Extensions
  •     Filters
  •         KritaText
  •         KritaTextLayout
  •     Generators
  •     Formats
  •             src
  •     PaintOps
  •       libpaintop
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal