Into

Modules

Documentation

classPiiImageScaleOperation

#include <PiiImageScaleOperation.h>

Scale images to arbitrary sizes.

Inherits PiiDefaultOperation

Description

The operation supports linear and nearest neighbor interpolation.

Inputs

imageInput image. Any image type.

Outputs

imageScaled image. Same type as the input.

Properties

Interpolation mode.

Defines the size of output image.

Scaling mode.

double

The amount of scaling, i.e.

Public types

enum
{ NearestNeighborInterpolation, LinearInterpolation }

A copy of Pii::Interpolation.

enum
{ ZoomAccordingToFactor, ScaleToSize, ScaleToAspectRatioX, ScaleToAspectRatioY, ScaleDownToAspectRatio, ScaleUpToAspectRatio, ScaleToBox }

Scaling modes:

Constructors and destructor

Public member functions

double
void
( )
void
( )
void
( )
void
(
  • double scaleRatio
)

Protected member functions

virtual void

Executes one round of processing.

Property details

  • Interpolation interpolation

    [read, write]

    Interpolation mode.

    The default is LinearInterpolation. NearestNeighborInterpolation is faster, but less accurate.

  • QSize scaledSize

    [read, write]

    Defines the size of output image.

    Default is (100,100).

  • ScaleMode scaleMode

    [read, write]

    Scaling mode.

    Default is ZoomAccordingToFactor.

  • double scaleRatio

    [read, write]

    The amount of scaling, i.e.

    a "zoom factor". Default is 1.0. The scale ratio also works as the target aspect ratio, depending on scaleMode. The scale ratio is calculated as width/height. Thus, 2 means an image whose width is two times its height.

Enumeration details

  • enum Interpolation

    A copy of Pii::Interpolation.

    (Stupid moc.)

  • enum ScaleMode

    Scaling modes:

    • ZoomAccordingToFactor - zoom both dimensions according to the specified scale ratio (scaleRatio). Retain original aspect ratio.

    • ScaleToSize - scale to the specified size (scaledSize), ignoring original aspect ratio.

    • ScaleToAspectRatioX - scale to a specified aspect ratio (scaleRatio). Scale the image horizontally to obtain this aspect ratio.

    • ScaleToAspectRatioY - same as above, but scale vertically.

    • ScaleDownToAspectRatio - same as above, but scale the direction that results in a smaller output image.

    • ScaleUpToAspectRatio - same as above, but scale the direction that results in a larger output image.

    • ScaleToBox - fit to size retaining aspect ratio.

    Aspect ratio is always calculated as width/height.

Function details

  • PiiImageScaleOperation

    ()
  • Interpolation interpolation

    ()
  • QSize scaledSize

    ()
  • ScaleMode scaleMode

    ()
  • double scaleRatio

    ()
  • void setInterpolation

    ( )
  • void setScaledSize

    ( )
  • void setScaleMode

    ( )
  • void setScaleRatio

    (
    • double scaleRatio
    )
  • virtual void process

    ()
    [protected, virtual]

    Executes one round of processing.

    This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.

    Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().

    Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns Running.

    Exceptions
    PiiExecutionException

    whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.

    Reimplemented from PiiDefaultOperation.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.