END_TEST;
}
+namespace
+{
/**
* @brief Build a square bitmap, downscale it and assert the resulting bitmap has the right dimensions.
*/
DALI_TEST_EQUALS(downScaled.GetPixelFormat(), format, location);
}
+/**
+ * @brief Test that resizing RGBA8888 images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensionsRGBA8888(uint32_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2RGBA8888(
+ reinterpret_cast<unsigned char*>(pixels),
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+
+/**
+ * @brief Test that resizing RGB565 images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensionsRGB565(uint16_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2RGB565(
+ reinterpret_cast<unsigned char*>(pixels),
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+
+/**
+ * @brief Test that resizing 2-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensions2ComponentPair(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2ComponentPair(
+ pixels,
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+
+/**
+ * @brief Test that resizing single-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensionsSingleComponent(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2SingleBytePerPixel(
+ pixels,
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+} // namespace
+
/**
* @brief Test the top-level function for reducing the dimension of a bitmap,
* feeding it each of the five pixel formats that are output by image loaders.
END_TEST;
}
-/**
- * @brief Test that resizing RGBA8888 images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensionsRGBA8888(uint32_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2RGBA8888(
- reinterpret_cast<unsigned char*>(pixels),
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-
-/**
- * @brief Test that resizing RGB565 images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensionsRGB565(uint16_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2RGB565(
- reinterpret_cast<unsigned char*>(pixels),
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-
-/**
- * @brief Test that resizing 2-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensions2ComponentPair(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2ComponentPair(
- pixels,
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-
-/**
- * @brief Test that resizing single-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensionsSingleComponent(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2SingleBytePerPixel(
- pixels,
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-
/**
* @brief Test downscaling of RGBA8888 images in raw image arrays.
*/
// If both dimensions have values requested, use them both:
if(requestedWidth != 0 && requestedHeight != 0)
{
- DALI_ASSERT_DEBUG( (bitmapWidth > 0 && bitmapHeight > 0) && "Bitmap dimensions are zero");
+ DALI_ASSERT_DEBUG((bitmapWidth > 0 && bitmapHeight > 0) && "Bitmap dimensions are zero");
if(fittingMode == FittingMode::VISUAL_FITTING)
{
uint32_t adjustedDesiredWidth, adjustedDesiredHeight;
- float aspectOfDesiredSize = (float)requestedHeight / (float)requestedWidth;
- float aspectOfImageSize = (float)bitmapHeight / (float)bitmapWidth;
- if (aspectOfImageSize > aspectOfDesiredSize)
+ float aspectOfDesiredSize = (float)requestedHeight / (float)requestedWidth;
+ float aspectOfImageSize = (float)bitmapHeight / (float)bitmapWidth;
+ if(aspectOfImageSize > aspectOfDesiredSize)
{
- adjustedDesiredWidth = requestedWidth;
+ adjustedDesiredWidth = requestedWidth;
adjustedDesiredHeight = (static_cast<uint64_t>(bitmapHeight) * requestedWidth + bitmapWidth / 2) / bitmapWidth; ///< round up
}
else
{
- adjustedDesiredWidth = (static_cast<uint64_t>(bitmapWidth) * requestedHeight + bitmapHeight / 2) / bitmapHeight; ///< round up
+ adjustedDesiredWidth = (static_cast<uint64_t>(bitmapWidth) * requestedHeight + bitmapHeight / 2) / bitmapHeight; ///< round up
adjustedDesiredHeight = requestedHeight;
}
- requestedWidth = adjustedDesiredWidth;
+ requestedWidth = adjustedDesiredWidth;
requestedHeight = adjustedDesiredHeight;
}
if(filteredWidth < shrunkWidth || filteredHeight < shrunkHeight)
{
if(samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR ||
+ samplingMode == SamplingMode::LANCZOS || samplingMode == SamplingMode::BOX_THEN_LANCZOS ||
samplingMode == SamplingMode::NEAREST || samplingMode == SamplingMode::BOX_THEN_NEAREST)
{
outputBitmap = Dali::Devel::PixelBuffer::New(filteredWidth, filteredHeight, pixelFormat);
{
LinearSample(bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), outStride, pixelFormat, outputBitmap.GetBuffer(), filteredDimensions);
}
+ else if(samplingMode == SamplingMode::LANCZOS || samplingMode == SamplingMode::BOX_THEN_LANCZOS)
+ {
+ // TODO : Need to support LanczosSample various pixel format.
+ // Until now, just use LinearSample instead.
+ if(pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::BGRA8888 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
+ {
+ LanczosSample(bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), outStride, pixelFormat, outputBitmap.GetBuffer(), filteredDimensions);
+ }
+ else
+ {
+ LinearSample(bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), outStride, pixelFormat, outputBitmap.GetBuffer(), filteredDimensions);
+ }
+ }
else
{
PointSample(bitmap.GetBuffer(), shrunkWidth, shrunkHeight, outStride, pixelFormat, outputBitmap.GetBuffer(), filteredWidth, filteredHeight);
outHeight = inputHeight;
outStride = inputStride;
// Perform power of 2 iterated 4:1 box filtering if the requested filter mode requires it:
- if(samplingMode == SamplingMode::BOX || samplingMode == SamplingMode::BOX_THEN_NEAREST || samplingMode == SamplingMode::BOX_THEN_LINEAR)
+ if(samplingMode == SamplingMode::BOX || samplingMode == SamplingMode::BOX_THEN_NEAREST || samplingMode == SamplingMode::BOX_THEN_LINEAR || samplingMode == SamplingMode::BOX_THEN_LANCZOS)
{
// Check the pixel format is one that is supported:
if(pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 || pixelFormat == Pixel::CHROMINANCE_U || pixelFormat == Pixel::CHROMINANCE_V)