Support YUV decoding for JPEG
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / image-loading.h
old mode 100755 (executable)
new mode 100644 (file)
index 3c19be0..53e07df
@@ -2,7 +2,7 @@
 #define DALI_IMAGE_LOADING_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // EXTERNAL INCLUDES
-#include <string>
-#include <dali/public-api/images/image-operations.h>
 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/public-api/images/image-operations.h>
+#include <string>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/dali-adaptor-common.h>
 
-
 namespace Dali
 {
-
 /**
  * @brief Load an image synchronously from local file.
  *
@@ -43,10 +41,51 @@ namespace Dali
  */
 DALI_ADAPTOR_API Devel::PixelBuffer LoadImageFromFile(
   const std::string& url,
-  ImageDimensions size = ImageDimensions( 0, 0 ),
-  FittingMode::Type fittingMode = FittingMode::DEFAULT,
-  SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
-  bool orientationCorrection = true );
+  ImageDimensions    size                  = ImageDimensions(0, 0),
+  FittingMode::Type  fittingMode           = FittingMode::DEFAULT,
+  SamplingMode::Type samplingMode          = SamplingMode::BOX_THEN_LINEAR,
+  bool               orientationCorrection = true);
+
+/**
+ * @brief Load an image and save each plane to a separate buffer synchronously from local file.
+ *
+ * @note This method is thread safe, i.e. can be called from any thread.
+ *       If the image file doesn't support to load planes, this method returns a bitmap image instead.
+ *
+ * @param [in] url The URL of the image file to load.
+ * @param [out] buffers The loaded PixelBuffer object list or an empty list in case loading failed.
+ * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
+ * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
+ * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
+ * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+ */
+DALI_ADAPTOR_API void LoadImagePlanesFromFile(
+  const std::string&               url,
+  std::vector<Devel::PixelBuffer>& buffers,
+  ImageDimensions                  size                  = ImageDimensions(0, 0),
+  FittingMode::Type                fittingMode           = FittingMode::DEFAULT,
+  SamplingMode::Type               samplingMode          = SamplingMode::BOX_THEN_LINEAR,
+  bool                             orientationCorrection = true);
+
+/**
+ * @brief Load an image synchronously from encoded buffer.
+ *
+ * @note This method is thread safe, i.e. can be called from any thread.
+ *
+ * @param [in] buffer The encoded buffer of the image to load.
+ *                    The buffer is not owned by FileStream and must be valid for entire lifetime of FileStream
+ * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
+ * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
+ * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
+ * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+ * @return handle to the loaded PixelBuffer object or an empty handle in case loading failed.
+ */
+DALI_ADAPTOR_API Devel::PixelBuffer LoadImageFromBuffer(
+  const Dali::Vector<uint8_t>& buffer,
+  ImageDimensions              size                  = ImageDimensions(0, 0),
+  FittingMode::Type            fittingMode           = FittingMode::DEFAULT,
+  SamplingMode::Type           samplingMode          = SamplingMode::BOX_THEN_LINEAR,
+  bool                         orientationCorrection = true);
 
 /**
  * @brief Determine the size of an image that LoadImageFromFile will provide when
@@ -66,10 +105,20 @@ DALI_ADAPTOR_API Devel::PixelBuffer LoadImageFromFile(
  */
 DALI_ADAPTOR_API ImageDimensions GetClosestImageSize(
   const std::string& filename,
-  ImageDimensions size = ImageDimensions(0, 0),
-  FittingMode::Type fittingMode = FittingMode::DEFAULT,
-  SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR ,
-  bool orientationCorrection = true );
+  ImageDimensions    size                  = ImageDimensions(0, 0),
+  FittingMode::Type  fittingMode           = FittingMode::DEFAULT,
+  SamplingMode::Type samplingMode          = SamplingMode::BOX_THEN_LINEAR,
+  bool               orientationCorrection = true);
+
+/**
+ * @brief Get the size of an original image. this method will respect any rotation of image.
+ * @param[in] filename name of the image.
+ * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+ *
+ * @return dimensions to original image
+ */
+DALI_ADAPTOR_API ImageDimensions GetOriginalImageSize(
+  const std::string& filename, bool orientationCorrection = true);
 
 /**
  * @brief Load an image synchronously from a remote resource.
@@ -84,17 +133,10 @@ DALI_ADAPTOR_API ImageDimensions GetClosestImageSize(
  */
 DALI_ADAPTOR_API Devel::PixelBuffer DownloadImageSynchronously(
   const std::string& url,
-  ImageDimensions size = ImageDimensions( 0, 0 ),
-  FittingMode::Type fittingMode = FittingMode::DEFAULT,
-  SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
-  bool orientationCorrection = true );
-
-/**
- * @brief Set the maximum texture size. Then size can be kwown by GL_MAX_TEXTURE_SIZE.
- *
- * @param [in] size The maximum texture size to set
- */
-DALI_ADAPTOR_API void SetMaxTextureSize( unsigned int size );
+  ImageDimensions    size                  = ImageDimensions(0, 0),
+  FittingMode::Type  fittingMode           = FittingMode::DEFAULT,
+  SamplingMode::Type samplingMode          = SamplingMode::BOX_THEN_LINEAR,
+  bool               orientationCorrection = true);
 
 /**
  * @brief get the maximum texture size.
@@ -103,6 +145,6 @@ DALI_ADAPTOR_API void SetMaxTextureSize( unsigned int size );
  */
 DALI_ADAPTOR_API unsigned int GetMaxTextureSize();
 
-} // Dali
+} // namespace Dali
 
 #endif // DALI_IMAGE_LOADING_H