Formatting API
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / bitmap-saver.h
index b8e67be..3792440 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_ADAPTOR_BITMAP_SAVER_H__
-#define __DALI_ADAPTOR_BITMAP_SAVER_H__
+#ifndef DALI_ADAPTOR_BITMAP_SAVER_H
+#define DALI_ADAPTOR_BITMAP_SAVER_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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/pixel.h>
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
 
 namespace Dali
 {
+static constexpr uint32_t DEFAULT_JPG_QUALITY = 100;
 
 /**
  * Store the given pixel data to a file.
@@ -37,13 +41,33 @@ namespace Dali
  *
  * @return true if the file was saved
  */
-DALI_IMPORT_API bool EncodeToFile(const unsigned char* const pixelBuffer,
-                                  const std::string& filename,
-                                  const Pixel::Format pixelFormat,
-                                  const std::size_t width,
-                                  const std::size_t height);
+DALI_ADAPTOR_API bool EncodeToFile(const unsigned char* const pixelBuffer,
+                                   const std::string&         filename,
+                                   const Pixel::Format        pixelFormat,
+                                   const std::size_t          width,
+                                   const std::size_t          height);
 
-} // namespace Dali
+/**
+ * Store the given pixel data to a file.
+ * The suffix of the filename determines what type of file will be stored,
+ * currently only jpeg and png formats are supported.
+ *
+ * @param[in] pixelBuffer Pointer to the pixel data
+ * @param[in] filename    Filename to save
+ * @param[in] pixelFormat The format of the buffer's pixels
+ * @param[in] width       The width of the image in pixels
+ * @param[in] height      The height of the image in pixels
+ * @param[in] quality     The value to control image quality for jpeg file format in the range [1, 100]
+ *
+ * @return true if the file was saved
+ */
+DALI_ADAPTOR_API bool EncodeToFile(const unsigned char* const pixelBuffer,
+                                   const std::string&         filename,
+                                   const Pixel::Format        pixelFormat,
+                                   const std::size_t          width,
+                                   const std::size_t          height,
+                                   const uint32_t             quality);
 
+} // namespace Dali
 
-#endif // __DALI_ADAPTOR_BITMAP_SAVER_H__
+#endif // DALI_ADAPTOR_BITMAP_SAVER_H