*/
struct Input
{
- Input(FILE* file, ScalingParameters scalingParameters = ScalingParameters(), bool reorientationRequested = true)
+ Input(FILE* file, ScalingParameters scalingParameters = ScalingParameters(), bool reorientationRequested = true, bool rotatedSizeRequested = false )
: file(file),
scalingParameters(scalingParameters),
- reorientationRequested(reorientationRequested)
+ reorientationRequested(reorientationRequested),
+ rotatedSizeRequested(rotatedSizeRequested)
{
}
FILE* file;
ScalingParameters scalingParameters;
bool reorientationRequested;
+ bool rotatedSizeRequested;
};
using LoadBitmapFunction = bool (*)(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& pixelData);
return TizenPlatform::ImageLoader::GetClosestImageSize(filename, ImageDimensions(0, 0), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true);
}
+ImageDimensions GetOriginalImageSize(const std::string& filename, bool orientationCorrection)
+{
+ return TizenPlatform::ImageLoader::GetRotatedImageSize(filename, ImageDimensions(0, 0), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true);
+}
+
Devel::PixelBuffer DownloadImageSynchronously(const std::string& url, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection)
{
Integration::BitmapResourceType resourceType(size, fittingMode, samplingMode, orientationCorrection);
bool orientationCorrection = true);
/**
- * @brief Get the size of an original image
+ * @brief Get the size of an original image. this method will not respect any rotation of image.
* @param[in] filename name of the image.
*
* @return dimensions to original image
const std::string& filename);
/**
+ * @brief Get the size of an original image. this method will respect any rotation of image.
+ * @param[in] filename name of the image.
+ *
+ * @return dimensions to original image
+ */
+DALI_ADAPTOR_API ImageDimensions GetOriginalImageSize(
+ const std::string& filename, bool orientationCorrection);
+
+/**
* @brief Load an image synchronously from a remote resource.
*
* @param [in] url The URL of the image file to load.
profile,
filename ) )
{
- const Dali::ImageLoader::Input input( fp, Dali::ImageLoader::ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection );
+ const Dali::ImageLoader::Input input( fp, Dali::ImageLoader::ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection , false );
const bool read_res = headerFunction( input, width, height );
if(!read_res)
return ImageDimensions( width, height );
}
+ImageDimensions GetRotatedImageSize( const std::string& filename,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection )
+{
+ unsigned int width = 0;
+ unsigned int height = 0;
+
+ Internal::Platform::FileReader fileReader( filename );
+ FILE *fp = fileReader.GetFile();
+ if (fp != NULL)
+ {
+ Dali::ImageLoader::LoadBitmapFunction loaderFunction;
+ Dali::ImageLoader::LoadBitmapHeaderFunction headerFunction;
+ Bitmap::Profile profile;
+
+ if ( GetBitmapLoaderFunctions( fp,
+ GetFormatHint(filename),
+ loaderFunction,
+ headerFunction,
+ profile,
+ filename ) )
+ {
+ const Dali::ImageLoader::Input input( fp, Dali::ImageLoader::ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection , true );
+
+ const bool read_res = headerFunction( input, width, height );
+ if(!read_res)
+ {
+ DALI_LOG_WARNING("Image Decoder failed to read header for %s\n", filename.c_str());
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("Image Decoder for %s unavailable\n", filename.c_str());
+ }
+ }
+ return ImageDimensions( width, height );
+}
void SetMaxTextureSize( unsigned int size )
{
gMaxTextureSize = size;
SamplingMode::Type samplingMode,
bool orientationCorrection );
+ImageDimensions GetRotatedImageSize( const std::string& filename,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection );
+
/**
* @brief Set the maximum texture size. Then size can be kwown by GL_MAX_TEXTURE_SIZE.
*
FILE* const fp = input.file;
bool success = false;
+
+ // If rotatedSizeRequested is true, just get size
+ if( input.rotatedSizeRequested )
+ {
+ unsigned int headerWidth;
+ unsigned int headerHeight;
+ if( LoadJpegHeader( fp, headerWidth, headerHeight ) )
+ {
+ auto transform = JpegTransform::NONE;
+ if( input.reorientationRequested )
+ {
+ auto exifData = LoadExifData( fp );
+ if( exifData )
+ {
+ transform = ConvertExifOrientation(exifData.get());
+ }
+ if( transform == JpegTransform::ROTATE_90 || transform == JpegTransform::ROTATE_270 || transform == JpegTransform::TRANSPOSE || transform == JpegTransform::TRANSVERSE)
+ {
+ std::swap( headerWidth, headerHeight );
+ }
+ }
+ success = true;
+ width = headerWidth;
+ height = headerHeight;
+ }
+ return success;
+ }
+
if( requiredWidth == 0 && requiredHeight == 0 )
{
success = LoadJpegHeader( fp, width, height );