From 501fe7db20afa489e8eed485443c416bd3e1cf3b Mon Sep 17 00:00:00 2001 From: seungho Date: Tue, 22 Jun 2021 15:17:36 +0900 Subject: [PATCH 1/1] [Tizen] Return captured results with PixelBuffer - 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 --- dali/devel-api/adaptor-framework/capture-devel.cpp | 35 ++++++++++++++++++ dali/devel-api/adaptor-framework/capture-devel.h | 42 ++++++++++++++++++++++ dali/devel-api/file.list | 2 ++ dali/internal/system/common/capture-impl.cpp | 31 ++++++++++++++++ dali/internal/system/common/capture-impl.h | 7 ++++ 5 files changed, 117 insertions(+) create mode 100644 dali/devel-api/adaptor-framework/capture-devel.cpp create mode 100644 dali/devel-api/adaptor-framework/capture-devel.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 index 0000000..2d675f3 --- /dev/null +++ b/dali/devel-api/adaptor-framework/capture-devel.cpp @@ -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 +#include + + +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 index 0000000..d69f4fb --- /dev/null +++ b/dali/devel-api/adaptor-framework/capture-devel.h @@ -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 +#include + +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 diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index f4c3ee2..2973436 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -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 diff --git a/dali/internal/system/common/capture-impl.cpp b/dali/internal/system/common/capture-impl.cpp index 5bf9b55..9dd3199 100644 --- a/dali/internal/system/common/capture-impl.cpp +++ b/dali/internal/system/common/capture-impl.cpp @@ -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 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; diff --git a/dali/internal/system/common/capture-impl.h b/dali/internal/system/common/capture-impl.h index 273e8f0..77fff58 100644 --- a/dali/internal/system/common/capture-impl.h +++ b/dali/internal/system/common/capture-impl.h @@ -31,6 +31,7 @@ #include #include #include +#include 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; }; -- 2.7.4