merge with master
[platform/framework/native/image.git] / src / inc / FMedia_ImageBufferImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18
19 /**
20  * @file   FMedia_ImageBufferImpl.h
21  * @brief  This is the header file for the _ImageBufferImpl class.
22  *
23  * This header file contains the declarations of the Tizen::Media::_ImageBufferImpl class.
24  */
25 #ifndef _FMEDIA_INTERNAL_IMAGE_BUFFER_IMPL_H_
26 #define _FMEDIA_INTERNAL_IMAGE_BUFFER_IMPL_H_
27
28 #include <unique_ptr.h>
29 #include <FMediaImageTypes.h>
30
31 namespace Tizen { namespace Media
32 {
33
34 class ImageBuffer;
35
36 class _OSP_EXPORT_ _ImageBufferImpl
37         : public Tizen::Base::Object
38 {
39 public:
40
41         /**
42         * This is the default constructor for this class.
43         * The object is not fully constructed after this constructor is called.
44         * For full construction, the Construct() method must be called right after
45         * calling this constructor.
46         *
47         * @see  Construct()
48         */
49         _ImageBufferImpl(void);
50
51         /**
52         * This is the destructor for this class.
53         * This destructor overrides Tizen::Base::Object::~Object()
54         *
55         * @see  Construct()
56         */
57         virtual ~_ImageBufferImpl(void);
58
59         /**
60         * @see ImageBuffer::Construct()
61         */
62         result Construct(int width, int height, MediaPixelFormat pixelFormat);
63
64         /**
65         * @see ImageBuffer::Construct()
66         */
67         result Construct(const Tizen::Base::String &srcImagePath,
68                 const Tizen::Graphics::Rectangle *pDecodingRegion = null,
69                 bool autoRotate = true);
70
71         /**
72         * @see ImageBuffer::Construct()
73         */
74         result Construct(const Tizen::Base::ByteBuffer &srcImageBuf,
75                 const Tizen::Graphics::Rectangle *pDecodingRegion = null,
76                 bool autoRotate = true);
77
78         /**
79         * @see ImageBuffer::Construct()
80         */
81         result Construct(int width, int height, MediaPixelFormat pixelFormat,
82                 const byte* pData = null, int length = 0);
83
84         /**
85         * @see ImageBuffer::Construct()
86         */
87         result Construct(const Tizen::Graphics::Bitmap &srcBitmap);
88
89         result Construct(const Tizen::Base::String &srcImagePath, int destWidth, int destHeight, ImageScalingMethod scalingMethod);
90
91         result Construct(const Tizen::Base::ByteBuffer &srcImageBuf, int destWidth, int destHeight, ImageScalingMethod scalingMethod);
92
93         ExifOrientation GetExifOrientation(void) const;
94
95         /**
96         * @see ImageBuffer::Equals()
97         */
98         virtual bool Equals(ImageBuffer* pRhs) const;
99
100         /**
101         * @see  ImageBuffer::GetHashCode()
102         */
103         virtual int GetHashCode(void) const;
104
105         /**
106         * @see  ImageBuffer::GetHeight()
107         */
108         int GetHeight(void) const;
109
110         /**
111         * @see  ImageBuffer::GetWidth()
112         */
113         int GetWidth(void) const;
114
115         /**
116         * @see  ImageBuffer::GetPixelFormat()
117         */
118         MediaPixelFormat GetPixelFormat(void) const;
119
120         /**
121         * @see  ImageBuffer::Lock()
122         */
123         result Lock(byte* &data, int &length, MediaPixelFormat &pixelFormat);
124
125         /**
126         * @see  ImageBuffer::Unlock()
127         */
128         result Unlock(void);
129
130         /**
131         * @see  ImageBuffer::EncodeToBufferN()
132         */
133         Tizen::Base::ByteBuffer* EncodeToBufferN(ImageFormat destImageFormat, int quality = 90) const;
134
135         /**
136         * @see  ImageBuffer::EncodeToFile()
137         */
138         result EncodeToFile(const Tizen::Base::String &destImagePath, ImageFormat destImageFormat, bool overwrite, int quality = 90) const;
139
140         /**
141         * @see  ImageBuffer::GetBitmapN()
142         */
143         Tizen::Graphics::Bitmap* GetBitmapN(Tizen::Graphics::BitmapPixelFormat pixelFormat, Tizen::Graphics::BufferScaling bufferScaling) const;
144
145         /**
146         * @see  ImageBuffer::GetBitmapN()
147         */
148         Tizen::Graphics::Bitmap* GetBitmapN(Tizen::Graphics::BitmapPixelFormat pixelFormat, const Tizen::Graphics::FloatDimension &destDim) const;
149
150         /**
151         * @see  ImageBuffer::GetByteBufferN()
152         */
153         Tizen::Base::ByteBuffer* GetByteBufferN(MediaPixelFormat pixelFormat) const;
154
155         /**
156         * @see  ImageBuffer::CloneN()
157         */
158         virtual ImageBuffer* CloneN(void) const;
159
160         /**
161         * @see  ImageBuffer::ConvertPixelFormatN()
162         */
163         ImageBuffer* ConvertPixelFormatN(MediaPixelFormat pixelFormat) const;
164
165         /**
166         * @see  ImageBuffer::ResizeN()
167         */
168         ImageBuffer* ResizeN(int width, int height) const;
169
170         /**
171         * @see  ImageBuffer::FlipN()
172         */
173         ImageBuffer* FlipN(ImageFlipType flipType) const;
174
175         /**
176         * @see  ImageBuffer::RotateN()
177         */
178         ImageBuffer* RotateN(ImageRotationType rotateType) const;
179
180         /**
181         * @see  ImageBuffer::CropN()
182         */
183         ImageBuffer* CropN(int x, int y, int width, int height) const;
184
185         /**
186         * @see  ImageBuffer::GetImageInfo()
187         */
188         static result GetImageInfo(const Tizen::Base::String& srcImagePath, ImageFormat &imageFormat, int &width, int &height);
189
190         /**
191         * @see  ImageBuffer::GetImageInfo()
192         */
193         static result GetImageInfo(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat &imageFormat, int &width, int &height);
194
195         static bool IsSupportedPixelFormat(MediaPixelFormat pixelFormat);
196         /**
197         * @see  ImageBuffer::GetSupportedPixelFormatListN()
198         */
199         static Tizen::Base::Collection::IListT<MediaPixelFormat>* GetSupportedPixelFormatListN(void);
200
201         static _ImageBufferImpl* GetInstance(ImageBuffer& a);
202
203         static const _ImageBufferImpl* GetInstance(const ImageBuffer& a);
204 private:
205
206         /**
207         * The implementation of this copy constructor is intentionally blank
208         * and declared as private to prohibit copying of objects.
209         */
210         _ImageBufferImpl(const _ImageBufferImpl& rhs);
211
212         /**
213         * The implementation of this copy assignment operator is intentionally blank
214         * and declared as private to prohibit copying of objects.
215         */
216         _ImageBufferImpl& operator =(const _ImageBufferImpl& rhs);
217
218         std::unique_ptr<byte[]> __pBuffer;
219         int __width;
220         int __height;
221         int __bufSize;
222         ExifOrientation __orientation;
223         MediaPixelFormat __pixelFormat;
224         bool __isLocked;
225 };
226
227 }} // Tizen::Media
228
229 #endif // _FMEDIA_INTERNAL_IMAGE_BUFFER_IMPL_H_