2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 FGrp_EffectFlip.cpp
20 * @brief This is the header file for internal utility class.
28 #include <FBaseSysLog.h>
30 #include "FGrp_Effect.h"
33 using namespace Tizen::Graphics;
36 template<typename Pixel>
38 CreateFlippedImage(int width, int height, int pitch, Pixel* pSour, _Effect::Flip flip)
40 std::auto_ptr <_Util::Pixmap> dstImage(new (std::nothrow) _Util::Pixmap(width, height, sizeof(Pixel) * 8));
42 SysTryReturn(NID_GRP, dstImage.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
44 Pixel* pDest = (Pixel*) dstImage->pBitmap;
53 case _Effect::FLIP_VERTICAL:
55 pSour += height * pitch;
57 for (int y = 0; y < height; y++)
60 memcpy(pDest, pSour, width * sizeof(Pixel));
66 case _Effect::FLIP_HORIZONTAL:
70 for (int y = 0; y < height; y++)
72 for (int x = 0; x < width; x++)
77 pSour += (pitch << 1);
87 return dstImage.release();
92 Tizen::Graphics::_Effect::GetFlippedImage(const _Util::Pixmap& srcImage, Flip flip)
95 if ((srcImage.width <= 0) || (srcImage.height <= 0) || (srcImage.pBitmap == null))
101 if (srcImage.depth == 32)
103 return CreateFlippedImage(srcImage.width, srcImage.height, srcImage.bytesPerLine * 8 / srcImage.depth,
104 (unsigned long*) srcImage.pBitmap,
107 else if (srcImage.depth == 16)
109 return CreateFlippedImage(srcImage.width, srcImage.height, srcImage.bytesPerLine * 8 / srcImage.depth,
110 (unsigned short*) srcImage.pBitmap,