digiKam Developer Documentation: Digikam::ImageZoomSettings Class Reference

| digiKam Developer Documentation Professional Photo Management with the Power of Open Source

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Digikam::ImageZoomSettings Class Reference

## Public Types
enum | FitToSizeMode { AlwaysFit , OnlyScaleDown }

## Public Member Functions
| ImageZoomSettings (const QSize &imageSize, const QSize &originalSize=QSize())
void | fitToSize (const QSizeF &frameSize, FitToSizeMode=AlwaysFit)
| Sets the current zoom factor to the factor needed to fit the current (original) image size into the given view size.
double | fitToSizeZoomFactor (const QSizeF &frameSize, FitToSizeMode=AlwaysFit) const
| Returns the zoom factor that would be used by fitToSize() called with the given frameSize.
QSizeF | imageSize () const
| Returns the (available) image size.
bool | isFitToSize (const QSizeF &frameSize) const
QPointF | mapImageToZoom (const QPointF &imagePoint) const
| For a given point (in (0,0), imageSize()) returns the corresponding point in (0,0),zoomedSize().
QRectF | mapImageToZoom (const QRectF &imagePoint) const
| For a given rect contained in ((0,0), imageSize()) returns the corresponding rectangle in (0,0),zoomedSize().
QPointF | mapZoomToImage (const QPointF &zoomedPoint) const
| For a given point (in (0,0), zoomedSize()) returns the corresponding point in (0,0),imageSize().
QRectF | mapZoomToImage (const QRectF &imageRect) const
QSizeF | originalImageSize () const
| Return the original image size.
double | realZoomFactor () const
| Return the real zoom factor dependent on device pixel ratio.
void | setDisplayWidget (QWidget *const widget)
| Set the graphics view widget to track the device pixel ratio.
void | setImageSize (const QSize &size, const QSize &originalSize=QSize())
| Sets the size of the (available) image data.
void | setZoomFactor (double zoom)
| Sets the current zoom factor, relative to (original) size.
double | snappedZoomFactor (double newZoom, const QSizeF &frameSize) const
| When setting a new zoom factor (absolute value), the new value may be very close to a special value.
double | snappedZoomStep (double nextZoom, const QSizeF &frameSize) const
| When changing the zoom from current zoom to given nextZoom, sometimes a special value may be crossed, and this could then be used instead of nextZoom.
QRectF | sourceRect (const QRectF &imageRect) const
| For a given rectangle contained in ((0,0), zoomedSize()) returns the corresponding rectangle in (0,0),imageSize().
QSizeF | zoomedSize () const
| Return the size of the image when the current zoom factor is applied.
double | zoomFactor () const
| Return the currently set zoom factor.

## Static Public Member Functions
static bool | getImageSmoothScale ()
static void | setImageSmoothScale (bool enable)
| Static functions to define the smooth scaling of the image.

## Protected Attributes
QWidget * | m_displayWidget = nullptr
QSizeF | m_size
double | m_zoom = 1.0
double | m_zoomConst = 1.0

## Member Function Documentation

## ◆ fitToSize()

void Digikam::ImageZoomSettings::fitToSize | ( | const QSizeF & | frameSize,
|  | FitToSizeMode | mode = `AlwaysFit`
| ) |  |

Aspect ratio will be respected, that means the frameSize may not be completely filled in one dimension, and zoomedSize() can differ from frameSize in one dimension.

## ◆ originalImageSize()

QSizeF Digikam::ImageZoomSettings::originalImageSize | ( |  | ) | const

Can be identical to size().

## ◆ setImageSize()

void Digikam::ImageZoomSettings::setImageSize | ( | const QSize & | size,
|  | const QSize & | originalSize = `QSize()`
| ) |  |

Optionally, you can specify an original size, if the available image data is a scaled-down version. In this case, zoom factors will refer to the original size. The zoom factor is unchanged, you need to call fitToSize again.

## ◆ snappedZoomFactor()

double Digikam::ImageZoomSettings::snappedZoomFactor | ( | double | newZoom,
|  | const QSizeF & | frameSize
| ) |  | const

Returns this special value if this is the case, returns newZoom if not applicable.

## ◆ snappedZoomStep()

double Digikam::ImageZoomSettings::snappedZoomStep | ( | double | nextZoom,
|  | const QSizeF & | frameSize
| ) |  | const

Returns this special zoom, or nextZoom if not applicable.

## ◆ zoomedSize()

QSizeF Digikam::ImageZoomSettings::zoomedSize | ( |  | ) | const

This is the size the image should be displayed at.