2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FMedia_ImageUtilImpl.cpp
20 * @brief This file contains the implementation of _ImageUtilImpl class.
24 #include <FGrpDimension.h>
25 #include <FGrpBitmapCommon.h>
26 #include <FMediaTypes.h>
27 #include <FMediaImageTypes.h>
28 #include <FBaseSysLog.h>
29 #include "FMedia_MediaUtil.h"
30 #include "FMedia_ImageUtil.h"
31 #include "FMedia_ImageUtilImpl.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Io;
37 namespace Tizen { namespace Media
41 _ImageUtilImpl::ConvertPixelFormat(const ByteBuffer& srcBuf, ByteBuffer& dstBuf,
42 MediaPixelFormat srcFormat, MediaPixelFormat dstFormat,
45 return _ImageUtil::ConvertPixelFormat(srcBuf, srcFormat, dim.width, dim.height,
51 _ImageUtilImpl::Resize(const ByteBuffer& srcBuf, ByteBuffer& dstBuf,
52 const Dimension& srcDim, const Dimension& dstDim,
53 MediaPixelFormat pixelFormat)
55 return _ImageUtil::Resize(srcBuf, pixelFormat, srcDim.width, srcDim.height,
56 dstBuf, dstDim.width, dstDim.height);
61 _ImageUtilImpl::Rotate(const ByteBuffer& srcBuf, ByteBuffer& dstBuf,
62 const Dimension& dim, ImageRotationType rotate,
63 MediaPixelFormat pixelFormat)
65 return _ImageUtil::Rotate(srcBuf, pixelFormat, dim.width, dim.height,
71 _ImageUtilImpl::Flip(const ByteBuffer& srcBuf, ByteBuffer& dstBuf, const Dimension& dim,
72 ImageFlipType flip, MediaPixelFormat pixelFormat)
74 return _ImageUtil::Flip(srcBuf, pixelFormat, dim.width, dim.height,
78 Tizen::Media::ImageFormat
79 _ImageUtilImpl::GetImageFormat(const Tizen::Base::String& srcImageFile)
81 return _ImageUtil::GetImageFormat(srcImageFile);
86 _ImageUtilImpl::HasAlphaChannel(const Tizen::Base::String& srcImageFile)
88 return _ImageUtil::HasAlphaChannel(srcImageFile);
92 _ImageUtilImpl::MinImageFormatLength(void)
94 return _ImageUtil::MinImageFormatLength();
98 _ImageUtilImpl::GetImageFormat(const Tizen::Base::ByteBuffer& srcBuf)
100 return _ImageUtil::GetImageFormat(srcBuf);
104 _ImageUtilImpl::HasAlphaChannel(const Tizen::Base::ByteBuffer& srcBuf)
106 return _ImageUtil::HasAlphaChannel(srcBuf);
109 Tizen::Base::ByteBuffer*
110 _ImageUtilImpl::ResizeN(const Tizen::Base::ByteBuffer &srcBuf,
111 const Tizen::Graphics::Dimension& srcDim,
112 MediaPixelFormat pixelFormat,
113 const Tizen::Graphics::Dimension& dstDim)
115 return _ImageUtil::ResizeN(srcBuf, pixelFormat, srcDim.height, srcDim.width, dstDim.height, dstDim.width);
120 _ImageUtilImpl::ToMediaPixelFormat(BitmapPixelFormat bitmapFormat)
124 BitmapPixelFormat key;
125 MediaPixelFormat value;
127 { BITMAP_PIXEL_FORMAT_RGB565, MEDIA_PIXEL_FORMAT_RGB565LE },
128 { BITMAP_PIXEL_FORMAT_ARGB8888, MEDIA_PIXEL_FORMAT_BGRA8888 },
129 { BITMAP_PIXEL_FORMAT_R8G8B8A8, MEDIA_PIXEL_FORMAT_RGBA8888 },
131 MediaPixelFormat ret = MEDIA_PIXEL_FORMAT_NONE;
133 for (unsigned int i = 0; i < sizeof(map)/sizeof(map[0]); i++)
135 if (map[i].key == bitmapFormat)
145 _ImageUtilImpl::GetBufferSize(const Tizen::Graphics::Dimension& dim, MediaPixelFormat pixelFormat)
147 return _ImageUtil::GetBufferSize(pixelFormat, dim.width, dim.height);
151 _ImageUtilImpl::IsValidDimension(MediaPixelFormat pixelFormat, const Tizen::Graphics::Dimension& dim)
153 return _ImageUtil::IsValidDimension(pixelFormat, dim.width, dim.height);
157 _ImageUtilImpl::ToString(ImageFormat imgFormat)
164 { IMG_FORMAT_NONE, "None"},
165 { IMG_FORMAT_JPG, "JPG"},
166 { IMG_FORMAT_PNG, "PNG"},
167 { IMG_FORMAT_GIF, "GIF"},
168 { IMG_FORMAT_TIFF, "TIFF"},
169 { IMG_FORMAT_BMP, "BMP"},
170 { IMG_FORMAT_WBMP, "WBMP"},
172 const char* pStr = "None";
174 for (unsigned int i = 0; i < sizeof(map)/sizeof(map[0]); i++)
176 if (map[i].key == imgFormat)