digiKam
Digikam::DImg Class Reference
+ Inheritance diagram for Digikam::DImg:

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

void addAsReferredImage (const HistoryImageId &id)
 
HistoryImageId addAsReferredImage (const QString &filePath, HistoryImageId::Type type=HistoryImageId::Intermediate)
 
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 (const DColor &color)
 
void bitBlendImageOnColor (const DColor &color, int x, int y, int w, int h)
 
void bitBlendImageOnColor (DColorComposer *const composer, const DColor &color, int x, int y, int w, int h, DColorComposer::MultiplicationFlags multiplicationFlags=DColorComposer::NoMultiplication)
 
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)
 
QByteArray createImageUniqueId ()
 
void crop (const QRect &rect)
 
void crop (int x, int y, int w, int h)
 
void detach ()
 
FORMAT detectedFormat () const
 
 DImg ()
 
 DImg (const DImg &image)
 
 DImg (const QByteArray &filePath, DImgLoaderObserver *const observer=nullptr, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
 DImg (const QImage &image)
 
 DImg (const QString &filePath, DImgLoaderObserver *const observer=nullptr, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
 DImg (uint width, uint height, bool sixteenBit, bool alpha=false, uchar *const data=nullptr, bool copyData=true)
 
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
 
DImageHistorygetItemHistory ()
 
const DImageHistorygetItemHistory () const
 
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 ()
 
QByteArray getUniqueHashV2 ()
 
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, bool loadMetadata, bool loadICCData, bool loadUniqueHash, bool loadHistory, DImgLoaderObserver *const observer=nullptr, const DRawDecoding &rawDecodingSettings=DRawDecoding())
 
bool load (const QString &filePath, 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)
 
quint64 numBytes () const
 
quint64 numPixels () const
 
DImgoperator= (const DImg &image)
 
bool operator== (const DImg &image) const
 
int orientation () const
 
int originalBitDepth () const
 
COLORMODEL originalColorModel () const
 
QString originalFilePath () const
 
QSize originalRatioSize () const
 
QSize originalSize () const
 
void prepareMetadataToSave (const QString &intendedDestPath, const QString &destMimeType, bool resetExifOrientationTag)
 
void prepareMetadataToSave (const QString &intendedDestPath, const QString &destMimeType, const QString &originalFileName=QString(), PrepareMetadataFlags flags=PrepareMetadataFlagsAll)
 
void prepareSubPixelAccess ()
 
 Private ()
 
QImage pureColorMask (ExposureSettingsContainer *const expoSettings) const
 
void putImageData (uchar *const data, bool copyData=true)
 
void putImageData (uint width, uint height, bool sixteenBit, bool alpha, uchar *const data, bool copyData=true)
 
DRawDecoding rawDecodingSettings () const
 
void removeAlphaChannel ()
 
void removeAlphaChannel (const DColor &destColor)
 
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, const QString &format, DImgLoaderObserver *const observer=nullptr)
 
bool save (const QString &filePath, FORMAT frm, 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 (const QSize &destSize, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) const
 
DImg smoothScale (int width, int height, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) const
 
DImg smoothScaleClipped (const QSize &destSize, const QRect &clip) const
 
DImg smoothScaleClipped (int width, int height, int clipx, int clipy, int clipwidth, int clipheight) const
 
DImg smoothScaleSection (const QRect &sourceRect, const QSize &destSize) const
 
DImg smoothScaleSection (int sx, int sy, int sw, int sh, int dw, int dh) const
 
uchar * stripImageData ()
 
void switchOriginToLastSaved ()
 
bool transform (int transformAction)
 
bool wasExifRotated ()
 
uint width () const
 
 ~DImg ()
 
 ~Private ()
 

Static Public Member Functions

static QString colorModelToString (COLORMODEL colorModel)
 
static FORMAT fileFormat (const QString &filePath)
 
static QString formatToMimeType (FORMAT frm)
 
static QByteArray getUniqueHash (const QString &filePath)
 
static QByteArray getUniqueHashV2 (const QString &filePath)
 
static bool isAnimatedImage (const QString &filePath)
 

Public Attributes

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

Friends

class DImgLoader
 

Member Enumeration Documentation

◆ ANGLE

Enumerator
ROT90 
ROT180 
ROT270 
ROTNONE 

◆ COLORMODEL

Enumerator
COLORMODELUNKNOWN 
RGB 
GRAYSCALE 
MONOCHROME 
INDEXED 
YCBCR 
CMYK 
CIELAB 
COLORMODELRAW 

◆ FLIP

Enumerator
HORIZONTAL 
VERTICAL 

◆ FORMAT

Enumerator
NONE 

NOTE: Order is important here: See filesaveoptionbox.cpp which use these values to fill a stack of widgets.

JPEG 
PNG 
TIFF 
JP2K 
PGF 
HEIF 
RAW 
QIMAGE 

QImage or ImageMagick.

◆ 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 meta engine 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 

Constructor & Destructor Documentation

◆ DImg() [1/6]

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.

Referenced by copy().

◆ DImg() [2/6]

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

Load image using QByteArray as file path

References load(), and rawDecodingSettings().

◆ DImg() [3/6]

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

Load image using QString as file path

References load(), and rawDecodingSettings().

◆ DImg() [4/6]

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.

◆ DImg() [5/6]

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.

References numPixels().

◆ DImg() [6/6]

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).

References alpha, data, height, putImageData(), sixteenBit, and width.

◆ ~DImg()

Digikam::DImg::~DImg ( )

◆ ~Private()

Digikam::DImg::~Private ( )
inline

Member Function Documentation

◆ addAsReferredImage() [1/2]

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

◆ addAsReferredImage() [2/2]

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.

References createHistoryImageId().

Referenced by imageSavedAs(), and Digikam::EditorCore::slotImageSaved().

◆ addCurrentUniqueImageId()

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.

Referenced by Digikam::EditorCore::ensureHasCurrentUuid(), and Digikam::EditorCore::provideCurrentUuid().

◆ addFilterAction()

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

◆ attribute()

◆ bitBlendImage()

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.

References bits(), bytesDepth(), height, isNull(), sixteenBit, and width.

Referenced by DigikamEditorInsertTextToolPlugin::InsertTextWidget::composeImage().

◆ bitBlendImageOnColor() [1/3]

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

References bitBlendImageOnColor(), height, and width.

◆ bitBlendImageOnColor() [2/3]

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

◆ bitBlendImageOnColor() [3/3]

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.

References bits(), bytesDepth(), Digikam::DColor::convertToEightBit(), Digikam::DColor::convertToSixteenBit(), height, isNull(), sixteenBit, and width.

Referenced by bitBlendImageOnColor(), and removeAlphaChannel().

◆ bitBltImage() [1/4]

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.

References height, and width.

Referenced by bitBltImage(), DigikamEditorInsertTextToolPlugin::InsertTextWidget::composeImage(), copy(), Digikam::LensDistortionPixelAccess::pixelAccessReposition(), and Digikam::EditorCore::putImgSelection().

◆ bitBltImage() [2/4]

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

References bitBltImage(), height, and width.

◆ bitBltImage() [3/4]

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

◆ bitBltImage() [4/4]

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 
)

◆ bits()

◆ bitsDepth()

int Digikam::DImg::bitsDepth ( ) const

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

Referenced by Digikam::DImgLoader::imageBitsDepth().

◆ bytesDepth()

◆ colorModelToString()

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

◆ convertDepth()

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.

References bits(), data, height, isNull(), Digikam::RandomNumberGenerator::number(), sixteenBit, and width.

Referenced by convertToEightBit(), convertToSixteenBit(), and copyQImage().

◆ convertToDepthOfImage()

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

◆ convertToEightBit()

◆ convertToPixmap() [1/2]

◆ convertToPixmap() [2/2]

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

◆ convertToSixteenBit()

void Digikam::DImg::convertToSixteenBit ( )

Wrapper methods for convertDepth

References convertDepth().

Referenced by Digikam::DImgBuiltinFilter::apply(), and convertToDepthOfImage().

◆ copy() [1/4]

◆ copy() [2/4]

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

Return a region of image

References copy().

◆ copy() [3/4]

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

References copy(), DImg(), and isNull().

◆ copy() [4/4]

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

References bitBltImage(), DImg(), and isNull().

◆ copyBits()

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

References bits(), data, and numBytes().

◆ copyImageData()

DImg Digikam::DImg::copyImageData ( ) const

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

References bits(), hasAlpha(), height, sixteenBit, and width.

Referenced by copyMetaData(), detach(), Digikam::DImgThreadedFilter::DImgThreadedFilter(), and Digikam::GreycstorationFilter::GreycstorationFilter().

◆ copyMetaData()

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.

References copyImageData(), and copyMetaData().

Referenced by copyMetaData(), detach(), and Digikam::EditorCore::Private::saveAs().

◆ copyQImage() [1/4]

◆ copyQImage() [2/4]

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

References copyQImage().

◆ copyQImage() [3/4]

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

References copyQImage(), and isNull().

◆ copyQImage() [4/4]

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

◆ createHistoryImageId()

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

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

References getMetadata(), and getUniqueHashV2().

Referenced by addAsReferredImage(), and Digikam::DImgLoader::readMetadata().

◆ createImageUniqueId()

QByteArray Digikam::DImg::createImageUniqueId ( )

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.

References getUniqueHashV2().

Referenced by Digikam::EditorCore::ensureHasCurrentUuid(), and prepareMetadataToSave().

◆ crop() [1/2]

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

Crop image to the specified region

Referenced by Digikam::DImgBuiltinFilter::apply().

◆ crop() [2/2]

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

◆ detach()

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.

References copyImageData(), copyMetaData(), Private(), and size().

Referenced by copy(), copyQImage(), Digikam::SharedLoadingTask::execute(), Digikam::PreviewLoadingTask::execute(), and Digikam::EditorCore::getImgSelection().

◆ detectedFormat()

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().

References attribute(), hasAttribute(), and NONE.

Referenced by Digikam::ItemScanner::detectImageFormat(), exifOrientation(), Digikam::FaceGroup::load(), Digikam::FocusPointGroup::load(), Digikam::EditorCore::slotImageLoaded(), and Digikam::FileActionMngrFileWorker::transform().

◆ embeddedText()

QString Digikam::DImg::embeddedText ( const QString &  key) const

◆ exifOrientation()

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

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

References attribute(), detectedFormat(), Digikam::LoadSaveThread::exifOrientation(), getMetadata(), and RAW.

Referenced by exifRotate(), reverseExifRotate(), and Digikam::EditorCore::slotImageLoaded().

◆ exifRotate()

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

◆ fileFormat()

◆ fileOriginData()

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.

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!

References attribute(), and Digikam::DImgStaticPriv::fileOriginAttributes().

◆ fill()

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

◆ flip()

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

◆ format()

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.

References attribute().

Referenced by fileFormat(), formatToMimeType(), Digikam::EditorCore::getImageFormat(), load(), save(), and Digikam::FileActionMngrFileWorker::transform().

◆ formatToMimeType()

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

References format(), JP2K, JPEG, NONE, PGF, PNG, and TIFF.

Referenced by save(), and Digikam::BatchTool::savefromDImg().

◆ getIccProfile()

◆ getItemHistory() [1/2]

DImageHistory & Digikam::DImg::getItemHistory ( )

◆ getItemHistory() [2/2]

◆ getMetadata()

◆ getOriginalImageHistory()

◆ getPixelColor()

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.

References bytesDepth(), and data.

Referenced by Digikam::ImageIface::colorInfoFromOriginal().

◆ getSubPixelColor()

◆ getSubPixelColorFast()

◆ getUniqueHash() [1/2]

QByteArray Digikam::DImg::getUniqueHash ( )

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.

References attribute(), getMetadata(), hasAttribute(), and setAttribute().

Referenced by Digikam::ItemScanner::uniqueHash().

◆ getUniqueHash() [2/2]

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

◆ getUniqueHashV2() [1/2]

QByteArray Digikam::DImg::getUniqueHashV2 ( )

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.

References attribute(), hasAttribute(), and setAttribute().

Referenced by createHistoryImageId(), createImageUniqueId(), and Digikam::ItemScanner::uniqueHash().

◆ getUniqueHashV2() [2/2]

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

◆ hasAlpha()

◆ hasAttribute()

◆ hasImageHistory()

bool Digikam::DImg::hasImageHistory ( ) const

◆ hasTransparentPixels()

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.

Referenced by prepareMetadataToSave(), and save().

◆ height()

uint Digikam::DImg::height ( ) const

◆ imageSavedAs()

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.

References addAsReferredImage(), and setAttribute().

Referenced by Digikam::EditorCore::setLastSaved().

◆ insertAsReferredImage()

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

◆ isAnimatedImage()

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

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

Referenced by Digikam::StackedView::setPreviewItem().

◆ isNull()

bool Digikam::DImg::isNull ( ) const

Referenced by Digikam::HaarIface::bestMatchesForImageWithThreshold(), bitBlendImage(), bitBlendImageOnColor(), bitBltImage(), Digikam::BWSepiaSettings::BWSepiaSettings(), Digikam::EditorWindow::colorManage(), DigikamEditorInsertTextToolPlugin::InsertTextWidget::composeImage(), convertDepth(), convertToPixmap(), copy(), copyQImage(), crop(), Digikam::CurvesSettings::CurvesSettings(), Digikam::FaceDetector::detectFaces(), Digikam::SharedLoadingTask::execute(), Digikam::PreviewLoadingTask::execute(), fill(), flip(), Digikam::UndoCache::getData(), Digikam::EditorCore::getImageFormat(), Digikam::EditorCore::getImg(), Digikam::EditorCore::getImgSelection(), getSubPixelColor(), getSubPixelColorFast(), Digikam::UMSCamera::getThumbnail(), Digikam::HaarIface::indexImage(), Digikam::EditorCore::isReadOnly(), Digikam::IccManager::isSRGB(), Digikam::DImgThreadedFilter::prepareDestImage(), Digikam::DetectorDistortion::prepareForDetection(), Digikam::OpenCVDNNFaceDetector::prepareForDetection(), prepareMetadataToSave(), pureColorMask(), Digikam::EditorCore::putIccProfile(), Digikam::EditorCore::Private::putImageData(), Digikam::EditorCore::putImgSelection(), removeAlphaChannel(), resize(), rotate(), Digikam::FingerprintsTask::run(), Digikam::ImageQualityTask::run(), save(), DigikamGenericMediaServerPlugin::DLNAMediaServerDelegate::ServeFile(), Digikam::ImageIface::setOriginal(), Digikam::ImageIface::setSelection(), Digikam::EditorCore::slotImageLoaded(), and Digikam::HistogramWidget::updateData().

◆ isReadOnly()

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.

References attribute().

Referenced by Digikam::EditorCore::isReadOnly().

◆ lastSavedFileOriginData()

◆ lastSavedFilePath()

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.

References attribute().

Referenced by Digikam::MetadataHub::write().

◆ load() [1/3]

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

◆ load() [2/3]

◆ load() [3/3]

◆ loadItemInfo()

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.

References load(), Digikam::DImgLoader::LoadICCData, Digikam::DImgLoader::LoadImageHistory, Digikam::DImgLoader::LoadItemInfo, Digikam::DImgLoader::LoadMetadata, and Digikam::DImgLoader::LoadUniqueHash.

Referenced by Digikam::ItemScanner::loadFromDisk(), and Digikam::ItemPropertiesSideBar::setImagePropertiesInformation().

◆ numBytes()

◆ numPixels()

quint64 Digikam::DImg::numPixels ( ) const

References height, and width.

Referenced by DImg(), and Digikam::NREstimate::startAnalyse().

◆ operator=()

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

Equivalent to the copy constructor

◆ operator==()

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.

◆ orientation()

int Digikam::DImg::orientation ( ) const

Returns current DMetadata::Orientation from DImg

References getMetadata().

Referenced by Digikam::ItemScanner::commitFaces(), reverseRotateAndFlip(), and rotateAndFlip().

◆ originalBitDepth()

int Digikam::DImg::originalBitDepth ( ) const

Returns the bit depth (in bits per channel, e.g. 8 or 16) of the original file.

References attribute().

Referenced by Digikam::ItemScanner::scanItemInformation(), and Digikam::ItemPropertiesSideBar::setImagePropertiesInformation().

◆ originalColorModel()

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.

References attribute(), COLORMODELUNKNOWN, and hasAttribute().

Referenced by Digikam::ItemScanner::scanItemInformation(), and Digikam::ItemPropertiesSideBar::setImagePropertiesInformation().

◆ originalFilePath()

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.

References attribute().

Referenced by Digikam::BlurDetector::BlurDetector(), Digikam::EditorCore::getImageFilePath(), prepareMetadataToSave(), and Digikam::MetadataHub::write().

◆ originalRatioSize()

QSize Digikam::DImg::originalRatioSize ( ) const

Returns the size of the original file in the same aspect ratio as size().

References height, originalSize(), size(), and width.

Referenced by Digikam::TagRegion::mapFromOriginalSize(), Digikam::TagRegion::mapToOriginalSize(), and Digikam::TagRegion::relativeToAbsolute().

◆ originalSize()

QSize Digikam::DImg::originalSize ( ) const

Returns the size of the original file.

References attribute(), hasAttribute(), and size().

Referenced by originalRatioSize(), and Digikam::GraphicsDImgItem::setImage().

◆ prepareMetadataToSave() [1/2]

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.

References originalFilePath(), PrepareMetadataFlagsAll, prepareMetadataToSave(), and ResetExifOrientationTag.

◆ prepareMetadataToSave() [2/2]

◆ prepareSubPixelAccess()

void Digikam::DImg::prepareSubPixelAccess ( )

◆ Private()

Digikam::DImg::Private ( )
inlineexplicit

Referenced by detach(), and reset().

◆ pureColorMask()

◆ putImageData() [1/2]

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).

References data, and numBytes().

◆ putImageData() [2/2]

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.

References alpha, data, height, sixteenBit, size(), and width.

Referenced by DImg(), Digikam::EditorCore::Private::putImageData(), and Digikam::UndoManager::putImageDataAndHistory().

◆ rawDecodingSettings()

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().

References attribute(), and hasAttribute().

Referenced by DImg(), Digikam::SharedLoadingTask::execute(), Digikam::PreviewLoadingTask::execute(), and load().

◆ removeAlphaChannel() [1/2]

void Digikam::DImg::removeAlphaChannel ( )

◆ removeAlphaChannel() [2/2]

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)

References bitBlendImageOnColor(), hasAlpha(), and isNull().

Referenced by save().

◆ removeAttribute()

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

◆ reset()

void Digikam::DImg::reset ( )

Reset metadata and image data to null image

References Private().

Referenced by Digikam::DImgThreadedFilter::prepareDestImage(), and Digikam::EditorCore::resetImage().

◆ resetMetaData()

void Digikam::DImg::resetMetaData ( )

Reset metadata, but do not change image data

◆ resize()

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

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

References isNull(), smoothScale(), and stripImageData().

Referenced by Digikam::DImgBuiltinFilter::apply(), and Digikam::ImageRegionWidget::getOriginalRegionImage().

◆ reverseExifRotate()

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

Reverses the previous function

References exifOrientation(), and reverseRotateAndFlip().

◆ reverseRotateAndFlip()

◆ rotate()

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

◆ rotateAndFlip()

◆ save() [1/2]

◆ save() [2/2]

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

◆ savedFormat()

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.

References attribute().

◆ scanLine()

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

◆ setAttribute()

◆ setEmbeddedText()

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

◆ setFileOriginData()

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

◆ setHistoryBranch()

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

◆ setHistoryBranchAfter()

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.

References setHistoryBranchForLastSteps(), and Digikam::DImageHistory::size().

Referenced by setHistoryBranch(), and Digikam::EditorCore::setHistoryIsBranch().

◆ setHistoryBranchForLastSteps()

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

◆ setIccProfile()

◆ setItemHistory()

◆ setMetadata()

◆ setPixelColor()

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

◆ sixteenBit()

bool Digikam::DImg::sixteenBit ( ) const

◆ size()

◆ smoothScale() [1/2]

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

◆ smoothScale() [2/2]

◆ smoothScaleClipped() [1/2]

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

References smoothScaleClipped().

◆ smoothScaleClipped() [2/2]

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!

References bits(), Digikam::DImgScale::dimgCalcScaleInfo(), Digikam::DImgScale::dimgScaleAARGB(), Digikam::DImgScale::dimgScaleAARGB16(), Digikam::DImgScale::dimgScaleAARGBA(), and Digikam::DImgScale::dimgScaleAARGBA16().

Referenced by Digikam::ImagePreviewItem::paint(), Digikam::ImageRegionItem::paint(), Digikam::GraphicsDImgItem::paint(), and smoothScaleClipped().

◆ smoothScaleSection() [1/2]

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

◆ smoothScaleSection() [2/2]

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

References bits(), Digikam::DImgScale::dimgCalcScaleInfo(), Digikam::DImgScale::dimgScaleAARGB(), Digikam::DImgScale::dimgScaleAARGB16(), Digikam::DImgScale::dimgScaleAARGBA(), and Digikam::DImgScale::dimgScaleAARGBA16().

◆ stripImageData()

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.

References data.

Referenced by crop(), Digikam::UndoManager::putImageDataAndHistory(), and resize().

◆ switchOriginToLastSaved()

void Digikam::DImg::switchOriginToLastSaved ( )

◆ transform()

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

◆ wasExifRotated()

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.

References attribute().

Referenced by Digikam::PreviewLoadingTask::execute(), exifRotate(), and Digikam::EditorCore::slotImageLoaded().

◆ width()

uint Digikam::DImg::width ( ) const

Friends And Related Function Documentation

◆ DImgLoader

friend class DImgLoader
friend

Member Data Documentation

◆ alpha

bool Digikam::DImg::alpha

Referenced by DImg(), fill(), and putImageData().

◆ attributes

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

◆ data

◆ embeddedText

QString Digikam::DImg::embeddedText

◆ height

◆ iccProfile

IccProfile Digikam::DImg::iccProfile

◆ imageHistory

DImageHistory Digikam::DImg::imageHistory

◆ lanczos_func

LANCZOS_DATA_TYPE* Digikam::DImg::lanczos_func

◆ metaData

MetaEngineData Digikam::DImg::metaData

◆ null

bool Digikam::DImg::null

◆ sixteenBit

◆ width


The documentation for this class was generated from the following files: