// If no dimensions have been requested, default to the source ones:
if( requestedWidth == 0 && requestedHeight == 0 )
{
- return ImageDimensions( std::min( bitmapWidth, maxSize ), std::min( bitmapHeight, maxSize ) );
+ if( bitmapWidth <= maxSize && bitmapHeight <= maxSize )
+ {
+ return ImageDimensions( bitmapWidth, bitmapHeight );
+ }
+ else
+ {
+ // Calculate the size from the max texture size and the source image aspect ratio
+ if( bitmapWidth > bitmapHeight )
+ {
+ return ImageDimensions( maxSize, bitmapHeight * maxSize / static_cast< float >( bitmapWidth ) + 0.5f );
+ }
+ else
+ {
+ return ImageDimensions( bitmapWidth * maxSize / static_cast< float >( bitmapHeight ) + 0.5f, maxSize );
+ }
+ }
}
// If both dimensions have values requested, use them both:
if( requestedWidth != 0 && requestedHeight != 0 )
{
- return ImageDimensions( std::min( requestedWidth, maxSize ), std::min( requestedHeight, maxSize ) );
+ if( requestedWidth <= maxSize && requestedWidth <= maxSize )
+ {
+ return ImageDimensions( requestedWidth, requestedHeight );
+ }
+ else
+ {
+ // Calculate the size from the max texture size and the source image aspect ratio
+ if( requestedWidth > requestedHeight )
+ {
+ return ImageDimensions( maxSize, requestedHeight * maxSize / static_cast< float >( requestedWidth ) + 0.5f );
+ }
+ else
+ {
+ return ImageDimensions( requestedWidth * maxSize / static_cast< float >( requestedHeight ) + 0.5f, maxSize );
+ }
+ }
}
// Only one of the dimensions has been requested. Calculate the other from
#include <dali/integration-api/bitmap.h>
#include "platform-capabilities.h"
#include "image-operations.h"
+#include <image-loading.h>
// EXTERNAL HEADERS
#include <libexif/exif-data.h>
unsigned char * const mTjMem;
};
- // Workaround to avoid exceeding the maximum texture size
- const int MAX_TEXTURE_WIDTH = 4096;
- const int MAX_TEXTURE_HEIGHT = 4096;
-
} // namespace
bool JpegFlipV( RGB888Type *buffer, int width, int height );
bool JpegFlipH( RGB888Type *buffer, int width, int height );
// Continue downscaling to below maximum texture size (if possible)
scaleFactorIndex = i;
- if( TJSCALED(postXformImageWidth, (factors[i])) < MAX_TEXTURE_WIDTH &&
- TJSCALED(postXformImageHeight, (factors[i])) < MAX_TEXTURE_HEIGHT )
+ if( TJSCALED(postXformImageWidth, (factors[i])) < static_cast< int >( Dali::GetMaxTextureSize() ) &&
+ TJSCALED(postXformImageHeight, (factors[i])) < static_cast< int >( Dali::GetMaxTextureSize() ) )
{
// Current scale-factor downscales to below maximum texture size
break;