Dali 3D User Interface Engine
Classes | Typedefs | Functions
Dali::Internal::Platform::anonymous_namespace{image-operations.cpp} Namespace Reference

Classes

struct  Pixel4Bytes
 4 byte pixel structure. More...
 
struct  Pixel3Bytes
 RGB888 pixel structure. More...
 
struct  Pixel2Bytes
 a Pixel composed of two independent byte components. More...
 

Typedefs

typedef unsigned char PixelBuffer
 
typedef uint16_t PixelRGB565
 RGB565 pixel typedefed from a short. More...
 

Functions

const uint8_t BORDER_FILL_VALUE (0x00)
 
const unsigned int MAXIMUM_TARGET_BITMAP_SIZE ((1u<< 16)-1)
 
struct
Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::Pixel4Bytes 
__attribute__ ((packed, aligned(4)))
 
struct
Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::Pixel3Bytes 
__attribute__ ((packed, aligned(1)))
 
struct
Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::Pixel2Bytes 
__attribute__ ((packed, aligned(2)))
 
unsigned int EvenDown (const unsigned int a)
 
void ValidateScalingParameters (const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int desiredWidth, const unsigned int desiredHeight)
 Log bad parameters. More...
 
void DebugAssertScanlineParameters (const uint8_t *const pixels, const unsigned int width)
 Do debug assertions common to all scanline halving functions. More...
 
void DebugAssertDualScanlineParameters (const uint8_t *const scanline1, const uint8_t *const scanline2, uint8_t *const outputScanline, const size_t widthInComponents)
 Assertions on params to functions averaging pairs of scanlines. More...
 
BoxDimensionTest DimensionTestForScalingMode (FittingMode::Type fittingMode)
 Converts a scaling mode to the definition of which dimensions matter when box filtering as a part of that mode. More...
 
ImageDimensions FitForShrinkToFit (ImageDimensions target, ImageDimensions source)
 Work out the dimensions for a uniform scaling of the input to map it into the target while effecting ShinkToFit scaling mode. More...
 
ImageDimensions FitForScaleToFill (ImageDimensions target, ImageDimensions source)
 Work out the dimensions for a uniform scaling of the input to map it into the target while effecting SCALE_TO_FILL scaling mode. More...
 
ImageDimensions FitForFitWidth (ImageDimensions target, ImageDimensions source)
 Work out the dimensions for a uniform scaling of the input to map it into the target while effecting FIT_WIDTH scaling mode. More...
 
ImageDimensions FitForFitHeight (ImageDimensions target, ImageDimensions source)
 Work out the dimensions for a uniform scaling of the input to map it into the target while effecting FIT_HEIGHT scaling mode. More...
 
ImageDimensions FitToScalingMode (ImageDimensions requestedSize, ImageDimensions sourceSize, FittingMode::Type fittingMode)
 Generate the rectangle to use as the target of a pixel sampling pass (e.g., nearest or linear). More...
 
void CalculateBordersFromFittingMode (ImageDimensions sourceSize, FittingMode::Type fittingMode, ImageDimensions &requestedSize, int &scanlinesToCrop, int &columnsToCrop)
 Calculate the number of lines on the X and Y axis that need to be either added or removed with repect to the specified fitting mode. More...
 
BitmapPtr MakeEmptyBitmap (Pixel::Format pixelFormat, unsigned int width, unsigned int height)
 Construct a bitmap with format and dimensions requested. More...
 
BitmapPtr MakeBitmap (const uint8_t *const pixels, Pixel::Format pixelFormat, unsigned int width, unsigned int height)
 Construct a bitmap object from a copy of the pixel array passed in. More...
 
ImageDimensions CalculateDesiredDimensions (unsigned int bitmapWidth, unsigned int bitmapHeight, unsigned int requestedWidth, unsigned int requestedHeight)
 Work out the desired width and height, accounting for zeros. More...
 
bool ContinueScaling (BoxDimensionTest test, unsigned int scaledWidth, unsigned int scaledHeight, unsigned int desiredWidth, unsigned int desiredHeight)
 Returns whether to keep box filtering based on whether downscaled dimensions will overshoot the desired ones aty the next step. More...
 
template<int BYTES_PER_PIXEL, void(*)(unsigned char *const pixels, const unsigned int width) HalveScanlineInPlace, void(*)(const unsigned char *const scanline1, const unsigned char *const __restrict__ scanline2, unsigned char *const outputScanline, const unsigned int width) AverageScanlines>
void DownscaleInPlacePow2Generic (unsigned char *const pixels, const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int desiredWidth, const unsigned int desiredHeight, BoxDimensionTest dimensionTest, unsigned &outWidth, unsigned &outHeight)
 A shared implementation of the overall iterative box filter downscaling algorithm. More...
 
template<typename PIXEL >
void PointSampleAddressablePixels (const uint8_t *inPixels, unsigned int inputWidth, unsigned int inputHeight, uint8_t *outPixels, unsigned int desiredWidth, unsigned int desiredHeight)
 Point sample an image to a new resolution (like GL_NEAREST). More...
 
uint8_t BilinearFilter1BPPByte (uint8_t tl, uint8_t tr, uint8_t bl, uint8_t br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
 Blend 4 pixels together using horizontal and vertical weights. More...
 
Pixel2Bytes BilinearFilter2Bytes (Pixel2Bytes tl, Pixel2Bytes tr, Pixel2Bytes bl, Pixel2Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
  More...
 
Pixel3Bytes BilinearFilterRGB888 (Pixel3Bytes tl, Pixel3Bytes tr, Pixel3Bytes bl, Pixel3Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
  More...
 
PixelRGB565 BilinearFilterRGB565 (PixelRGB565 tl, PixelRGB565 tr, PixelRGB565 bl, PixelRGB565 br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
  More...
 
Pixel4Bytes BilinearFilter4Bytes (Pixel4Bytes tl, Pixel4Bytes tr, Pixel4Bytes bl, Pixel4Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
  More...
 
template<typename PIXEL , PIXEL(*)(PIXEL tl, PIXEL tr, PIXEL bl, PIXEL br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical) BilinearFilter, bool DEBUG_ASSERT_ALIGNMENT>
void LinearSampleGeneric (const unsigned char *__restrict__ inPixels, ImageDimensions inputDimensions, unsigned char *__restrict__ outPixels, ImageDimensions desiredDimensions)
 Generic version of bilinear sampling image resize function. More...
 

Typedef Documentation

typedef unsigned char Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::PixelBuffer

Definition at line 48 of file image-operations.cpp.

typedef uint16_t Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::PixelRGB565

RGB565 pixel typedefed from a short.

Access fields by manual shifting and masking.

Definition at line 76 of file image-operations.cpp.

Function Documentation

struct Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::Pixel4Bytes Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::__attribute__ ( (packed, aligned(4))  )
struct Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::Pixel3Bytes Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::__attribute__ ( (packed, aligned(1))  )
struct Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::Pixel2Bytes Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::__attribute__ ( (packed, aligned(2))  )
uint8_t Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::BilinearFilter1BPPByte ( uint8_t  tl,
uint8_t  tr,
uint8_t  bl,
uint8_t  br,
unsigned int  fractBlendHorizontal,
unsigned int  fractBlendVertical 
)
inline

Blend 4 pixels together using horizontal and vertical weights.

Definition at line 1346 of file image-operations.cpp.

References Dali::Internal::Platform::BilinearFilter1Component().

Here is the call graph for this function:

Pixel2Bytes Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::BilinearFilter2Bytes ( Pixel2Bytes  tl,
Pixel2Bytes  tr,
Pixel2Bytes  bl,
Pixel2Bytes  br,
unsigned int  fractBlendHorizontal,
unsigned int  fractBlendVertical 
)
inline
Pixel4Bytes Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::BilinearFilter4Bytes ( Pixel4Bytes  tl,
Pixel4Bytes  tr,
Pixel4Bytes  bl,
Pixel4Bytes  br,
unsigned int  fractBlendHorizontal,
unsigned int  fractBlendVertical 
)
inline
PixelRGB565 Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::BilinearFilterRGB565 ( PixelRGB565  tl,
PixelRGB565  tr,
PixelRGB565  bl,
PixelRGB565  br,
unsigned int  fractBlendHorizontal,
unsigned int  fractBlendVertical 
)
inline

Definition at line 1371 of file image-operations.cpp.

References Dali::Internal::Platform::BilinearFilter1Component().

Here is the call graph for this function:

Pixel3Bytes Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::BilinearFilterRGB888 ( Pixel3Bytes  tl,
Pixel3Bytes  tr,
Pixel3Bytes  bl,
Pixel3Bytes  br,
unsigned int  fractBlendHorizontal,
unsigned int  fractBlendVertical 
)
inline
const uint8_t Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::BORDER_FILL_VALUE ( 0x00  )
void Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::CalculateBordersFromFittingMode ( ImageDimensions  sourceSize,
FittingMode::Type  fittingMode,
ImageDimensions &  requestedSize,
int &  scanlinesToCrop,
int &  columnsToCrop 
)

Calculate the number of lines on the X and Y axis that need to be either added or removed with repect to the specified fitting mode.

(e.g., nearest or linear).

Parameters
[in]sourceSizeThe size of the source image
[in]fittingModeThe fitting mode to use
in/out]requestedSize The target size that the image will be fitted to. If the source image is smaller than the requested size, the source is not scaled up. So we reduce the target size while keeping aspect by lowering resolution.
[out]scanlinesToCropThe number of scanlines to remove from the image (can be negative to represent Y borders required)
[out]columnsToCropThe number of columns to remove from the image (can be negative to represent X borders required)

Definition at line 326 of file image-operations.cpp.

References Dali::FittingMode::FIT_HEIGHT, Dali::FittingMode::FIT_WIDTH, Dali::Uint16Pair::GetHeight(), Dali::Uint16Pair::GetWidth(), Dali::FittingMode::SCALE_TO_FILL, Dali::Uint16Pair::SetHeight(), Dali::Uint16Pair::SetWidth(), and Dali::FittingMode::SHRINK_TO_FIT.

Referenced by Dali::Internal::Platform::CropAndPadForFittingMode().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageDimensions Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::CalculateDesiredDimensions ( unsigned int  bitmapWidth,
unsigned int  bitmapHeight,
unsigned int  requestedWidth,
unsigned int  requestedHeight 
)

Work out the desired width and height, accounting for zeros.

Parameters
[in]bitmapWidthWidth of image before processing.
[in]bitmapHeightHeight of image before processing.
[in]requestedWidthWidth of area to scale image into. Can be zero.
[in]requestedHeightHeight of area to scale image into. Can be zero.
Returns
Dimensions of area to scale image into after special rules are applied.

Definition at line 442 of file image-operations.cpp.

bool Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::ContinueScaling ( BoxDimensionTest  test,
unsigned int  scaledWidth,
unsigned int  scaledHeight,
unsigned int  desiredWidth,
unsigned int  desiredHeight 
)

Returns whether to keep box filtering based on whether downscaled dimensions will overshoot the desired ones aty the next step.

Parameters
testWhich combination of the two dimensions matter for terminating the filtering.
scaledWidthThe width of the current downscaled image.
scaledHeightThe height of the current downscaled image.
desiredWidthThe target width for the downscaling.
desiredHeightThe target height for the downscaling.

Definition at line 751 of file image-operations.cpp.

References Dali::Internal::Platform::BoxDimensionTestBoth, Dali::Internal::Platform::BoxDimensionTestEither, Dali::Internal::Platform::BoxDimensionTestX, and Dali::Internal::Platform::BoxDimensionTestY.

Referenced by DownscaleInPlacePow2Generic().

Here is the caller graph for this function:

void Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::DebugAssertDualScanlineParameters ( const uint8_t *const  scanline1,
const uint8_t *const  scanline2,
uint8_t *const  outputScanline,
const size_t  widthInComponents 
)
inline

Assertions on params to functions averaging pairs of scanlines.

Note
Inline as intended to boil away in release.

Definition at line 146 of file image-operations.cpp.

References DALI_ASSERT_DEBUG.

Referenced by Dali::Internal::Platform::AverageScanlines1(), Dali::Internal::Platform::AverageScanlines2(), Dali::Internal::Platform::AverageScanlines3(), Dali::Internal::Platform::AverageScanlinesRGB565(), and Dali::Internal::Platform::AverageScanlinesRGBA8888().

Here is the caller graph for this function:

void Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::DebugAssertScanlineParameters ( const uint8_t *const  pixels,
const unsigned int  width 
)
inline

Do debug assertions common to all scanline halving functions.

Note
Inline and in anon namespace so should boil away in release builds.

Definition at line 135 of file image-operations.cpp.

References DALI_ASSERT_DEBUG.

Referenced by Dali::Internal::Platform::HalveScanlineInPlace1Byte(), Dali::Internal::Platform::HalveScanlineInPlace2Bytes(), Dali::Internal::Platform::HalveScanlineInPlaceRGB565(), Dali::Internal::Platform::HalveScanlineInPlaceRGB888(), and Dali::Internal::Platform::HalveScanlineInPlaceRGBA8888().

Here is the caller graph for this function:

BoxDimensionTest Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::DimensionTestForScalingMode ( FittingMode::Type  fittingMode)
template<int BYTES_PER_PIXEL, void(*)(unsigned char *const pixels, const unsigned int width) HalveScanlineInPlace, void(*)(const unsigned char *const scanline1, const unsigned char *const __restrict__ scanline2, unsigned char *const outputScanline, const unsigned int width) AverageScanlines>
void Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::DownscaleInPlacePow2Generic ( unsigned char *const  pixels,
const unsigned int  inputWidth,
const unsigned int  inputHeight,
const unsigned int  desiredWidth,
const unsigned int  desiredHeight,
BoxDimensionTest  dimensionTest,
unsigned &  outWidth,
unsigned &  outHeight 
)

A shared implementation of the overall iterative box filter downscaling algorithm.

Specialise this for particular pixel formats by supplying the number of bytes per pixel and two functions: one for averaging pairs of neighbouring pixels on a single scanline, and a second for averaging pixels at corresponding positions on different scanlines.

Note
: we could finish off with one of two mutually exclusive passes, one squashing horizontally as far as possible, and the other vertically, if we knew a following cpu point or bilinear filter would restore the desired aspect ratio.

Definition at line 801 of file image-operations.cpp.

References ContinueScaling(), DALI_LOG_INFO, and ValidateScalingParameters().

Here is the call graph for this function:

unsigned int Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::EvenDown ( const unsigned int  a)
inline
ImageDimensions Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::FitForFitHeight ( ImageDimensions  target,
ImageDimensions  source 
)

Work out the dimensions for a uniform scaling of the input to map it into the target while effecting FIT_HEIGHT scaling mode.

Definition at line 266 of file image-operations.cpp.

References DALI_ASSERT_DEBUG, Dali::Uint16Pair::GetX(), and Dali::Uint16Pair::GetY().

Referenced by FitToScalingMode().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageDimensions Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::FitForFitWidth ( ImageDimensions  target,
ImageDimensions  source 
)

Work out the dimensions for a uniform scaling of the input to map it into the target while effecting FIT_WIDTH scaling mode.

Definition at line 249 of file image-operations.cpp.

References DALI_ASSERT_DEBUG, Dali::Uint16Pair::GetX(), and Dali::Uint16Pair::GetY().

Referenced by FitToScalingMode().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageDimensions Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::FitForScaleToFill ( ImageDimensions  target,
ImageDimensions  source 
)

Work out the dimensions for a uniform scaling of the input to map it into the target while effecting SCALE_TO_FILL scaling mode.

Note
An image scaled into the output dimensions will need either top and bottom or left and right to be cropped away unless the source was pre-cropped to match the destination aspect ratio.

Definition at line 228 of file image-operations.cpp.

References DALI_ASSERT_DEBUG, Dali::Uint16Pair::GetX(), and Dali::Uint16Pair::GetY().

Referenced by FitToScalingMode().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageDimensions Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::FitForShrinkToFit ( ImageDimensions  target,
ImageDimensions  source 
)

Work out the dimensions for a uniform scaling of the input to map it into the target while effecting ShinkToFit scaling mode.

Definition at line 205 of file image-operations.cpp.

References Dali::Uint16Pair::GetX(), and Dali::Uint16Pair::GetY().

Referenced by FitToScalingMode().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageDimensions Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::FitToScalingMode ( ImageDimensions  requestedSize,
ImageDimensions  sourceSize,
FittingMode::Type  fittingMode 
)

Generate the rectangle to use as the target of a pixel sampling pass (e.g., nearest or linear).

Definition at line 284 of file image-operations.cpp.

References Dali::FittingMode::FIT_HEIGHT, Dali::FittingMode::FIT_WIDTH, FitForFitHeight(), FitForFitWidth(), FitForScaleToFill(), FitForShrinkToFit(), Dali::FittingMode::SCALE_TO_FILL, and Dali::FittingMode::SHRINK_TO_FIT.

Referenced by Dali::Internal::Platform::DownscaleBitmap().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename PIXEL , PIXEL(*)(PIXEL tl, PIXEL tr, PIXEL bl, PIXEL br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical) BilinearFilter, bool DEBUG_ASSERT_ALIGNMENT>
void Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::LinearSampleGeneric ( const unsigned char *__restrict__  inPixels,
ImageDimensions  inputDimensions,
unsigned char *__restrict__  outPixels,
ImageDimensions  desiredDimensions 
)
inline

Generic version of bilinear sampling image resize function.

Note
Limited to one compilation unit and exposed through type-specific wrapper functions below.

Optimise - for 1 and 2 and 4 byte types to execute a single 2, 4, or 8 byte load per pair (caveat clamping) and let half of them be unaligned.

Definition at line 1400 of file image-operations.cpp.

References DALI_ASSERT_DEBUG, Dali::Uint16Pair::GetHeight(), and Dali::Uint16Pair::GetWidth().

Here is the call graph for this function:

BitmapPtr Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::MakeBitmap ( const uint8_t *const  pixels,
Pixel::Format  pixelFormat,
unsigned int  width,
unsigned int  height 
)

Construct a bitmap object from a copy of the pixel array passed in.

Definition at line 421 of file image-operations.cpp.

References DALI_ASSERT_DEBUG, Dali::Integration::Bitmap::GetBuffer(), Dali::Pixel::GetBytesPerPixel(), and MakeEmptyBitmap().

Referenced by Dali::Internal::Platform::DownscaleBitmap().

Here is the call graph for this function:

Here is the caller graph for this function:

BitmapPtr Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::MakeEmptyBitmap ( Pixel::Format  pixelFormat,
unsigned int  width,
unsigned int  height 
)
const unsigned int Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::MAXIMUM_TARGET_BITMAP_SIZE ( (1u<< 16)-  1)

Referenced by Dali::Internal::Platform::CropAndPadForFittingMode().

Here is the caller graph for this function:

template<typename PIXEL >
void Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::PointSampleAddressablePixels ( const uint8_t *  inPixels,
unsigned int  inputWidth,
unsigned int  inputHeight,
uint8_t *  outPixels,
unsigned int  desiredWidth,
unsigned int  desiredHeight 
)
inline

Point sample an image to a new resolution (like GL_NEAREST).

Template is used purely as a type-safe code generator in this one compilation unit. Generated code is inlined into type-specific wrapper functions below which are exported to rest of module.

Definition at line 1162 of file image-operations.cpp.

References DALI_ASSERT_DEBUG.

void Dali::Internal::Platform::anonymous_namespace{image-operations.cpp}::ValidateScalingParameters ( const unsigned int  inputWidth,
const unsigned int  inputHeight,
const unsigned int  desiredWidth,
const unsigned int  desiredHeight 
)

Log bad parameters.

Definition at line 110 of file image-operations.cpp.

References DALI_LOG_INFO.

Referenced by DownscaleInPlacePow2Generic().

Here is the caller graph for this function:

Dali Docs Home
Read more about Dali