[Tizen] Return captured results with PixelBuffer 15/260215/3
authorseungho <sbsh.baek@samsung.com>
Tue, 22 Jun 2021 06:17:36 +0000 (15:17 +0900)
committerseungho <sbsh.baek@samsung.com>
Wed, 23 Jun 2021 04:38:53 +0000 (13:38 +0900)
 - Returns buffer of captured result
 - To return pixelBuffer help to control captured image like crop or picking color

Change-Id: Id11a3f98cc67feca4b1d55b6e1945a6431e8c1a1
Signed-off-by: seungho <sbsh.baek@samsung.com>
dali/devel-api/adaptor-framework/capture-devel.cpp [new file with mode: 0644]
dali/devel-api/adaptor-framework/capture-devel.h [new file with mode: 0644]
dali/devel-api/file.list
dali/internal/system/common/capture-impl.cpp
dali/internal/system/common/capture-impl.h

diff --git a/dali/devel-api/adaptor-framework/capture-devel.cpp b/dali/devel-api/adaptor-framework/capture-devel.cpp
new file mode 100644 (file)
index 0000000..2d675f3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/capture-devel.h>
+#include <dali/internal/system/common/capture-impl.h>
+
+
+namespace Dali
+{
+namespace DevelCapture
+{
+
+Dali::Devel::PixelBuffer GetCapturedBuffer(Dali::Capture capture)
+{
+  return GetImpl(capture).GetCapturedBuffer();
+}
+
+} // namespace DevelWindow
+
+} // namespace Dali
diff --git a/dali/devel-api/adaptor-framework/capture-devel.h b/dali/devel-api/adaptor-framework/capture-devel.h
new file mode 100644 (file)
index 0000000..d69f4fb
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef DALI_CAPTURE_DEVEL_H
+#define DALI_CAPTURE_DEVEL_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/capture/capture.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+
+namespace Dali
+{
+
+namespace DevelCapture
+{
+
+/**
+ * @brief Get PixelBuffer of captured image.
+ *
+ * @return PixelBuffer Captured result
+ */
+DALI_ADAPTOR_API Dali::Devel::PixelBuffer GetCapturedBuffer(Dali::Capture capture);
+
+} // namespace DevelCapture
+
+} // namespace Dali
+
+#endif // DALI_CAPTURE_DEVEL_H
index f4c3ee2..2973436 100755 (executable)
@@ -8,6 +8,7 @@ SET( devel_api_src_files
   ${adaptor_devel_api_dir}/adaptor-framework/autofill-item.cpp
   ${adaptor_devel_api_dir}/adaptor-framework/autofill-manager.cpp
   ${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.cpp
+  ${adaptor_devel_api_dir}/adaptor-framework/capture-devel.cpp
   ${adaptor_devel_api_dir}/adaptor-framework/clipboard.cpp
   ${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.cpp
   ${adaptor_devel_api_dir}/adaptor-framework/color-controller.cpp
@@ -56,6 +57,7 @@ SET( devel_api_adaptor_framework_header_files
   ${adaptor_devel_api_dir}/adaptor-framework/autofill-item.h
   ${adaptor_devel_api_dir}/adaptor-framework/autofill-manager.h
   ${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.h
+  ${adaptor_devel_api_dir}/adaptor-framework/capture-devel.h
   ${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.h
   ${adaptor_devel_api_dir}/adaptor-framework/clipboard.h
   ${adaptor_devel_api_dir}/adaptor-framework/color-controller-plugin.h
index 5bf9b55..9dd3199 100644 (file)
@@ -129,6 +129,37 @@ Dali::Texture Capture::GetTexture()
   return mTexture;
 }
 
+Dali::Devel::PixelBuffer Capture::GetCapturedBuffer()
+{
+  if(!mPixelBuffer || !mPixelBuffer.GetBuffer())
+  {
+    uint8_t* bufferPointer;
+    uint32_t             width, height;
+    Dali::Pixel::Format  pixelFormat;
+    if(mIsNativeImageSourcePossible)
+    {
+      std::vector<uint8_t> buffer;
+      if(!mNativeImageSourcePtr->GetPixels(buffer, width, height, pixelFormat))
+      {
+        return Dali::Devel::PixelBuffer();
+      }
+      bufferPointer = &buffer[0];
+    }
+    else
+    {
+      width = mTexture.GetWidth();
+      height = mTexture.GetHeight();
+      pixelFormat = Dali::Pixel::RGBA8888;
+      bufferPointer = mFrameBuffer.GetRenderedBuffer();
+    }
+    mPixelBuffer = Dali::Devel::PixelBuffer::New(width, height, pixelFormat);
+
+    memcpy(mPixelBuffer.GetBuffer(), bufferPointer, width * height * Dali::Pixel::GetBytesPerPixel(pixelFormat));
+  }
+
+  return mPixelBuffer;
+}
+
 Dali::Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
 {
   return mFinishedSignal;
index 273e8f0..77fff58 100644 (file)
@@ -31,6 +31,7 @@
 #include <dali/public-api/capture/capture.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 
 namespace Dali
 {
@@ -93,6 +94,11 @@ public:
   Dali::Texture GetTexture();
 
   /**
+   * @copydoc Dali::Capture::GetCapturedBuffer
+   */
+  Dali::Devel::PixelBuffer GetCapturedBuffer();
+
+  /**
    * @copydoc Dali::Capture::FinishedSignal
    */
   Dali::Capture::CaptureFinishedSignalType& FinishedSignal();
@@ -211,6 +217,7 @@ private:
   Dali::Capture::CaptureFinishedSignalType    mFinishedSignal;
   std::string                                 mPath;
   Dali::NativeImageSourcePtr                  mNativeImageSourcePtr; ///< pointer to surface image
+  Dali::Devel::PixelBuffer                    mPixelBuffer;
   bool                                        mFileSave;
   bool                                        mIsNativeImageSourcePossible;
 };