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_EffectManip.cpp
20 * @brief This is the header file for internal utility class.
24 #include "FGrp_EffectFunc.h"
25 #include "FGrp_Effect.h"
27 using namespace Tizen::Graphics;
33 template<typename Pixel>
34 struct _NinePatchedKey
39 struct _NinePatchedKey <unsigned long>
48 struct _NinePatchedKey <unsigned short>
56 template<typename Pixel>
58 _IsNinePatched(const _Util::Pixmap& dstImage, Pixel dummy)
62 KEY = _NinePatchedKey <Pixel>::KEY
65 // assert(dstImage.depth == sizeof(Pixel)*8);
67 if (dstImage.depth != sizeof(Pixel) * 8)
72 // verify horizontal line
76 Pixel* pProbe = (Pixel*) (dstImage.pBitmap);
77 Pixel* pProbeEnd = pProbe + dstImage.width;
79 while (!found && (pProbe < pProbeEnd))
81 found = (*pProbe++ == KEY);
90 // verify vertical line
94 int pitch = dstImage.bytesPerLine / (dstImage.depth / 8);
96 Pixel* pProbe = (Pixel*) (dstImage.pBitmap);
97 Pixel* pProbeEnd = pProbe + dstImage.height * pitch;
99 while (!found && (pProbe < pProbeEnd))
101 found = (*pProbe == KEY);
118 Tizen::Graphics::_Effect::IsNinePatchedBitmap(const _Util::Pixmap& dstImage)
120 // verifiy the spcified parameters
122 if ((dstImage.width <= 0) || (dstImage.height <= 0) || (dstImage.pBitmap == null))
128 switch (dstImage.depth)
131 return _IsNinePatched <unsigned long>(dstImage, 0);
133 return _IsNinePatched <unsigned short>(dstImage, 0);
140 Tizen::Graphics::_Effect::IsOpaqueAllOver(const _Util::Pixmap& dstImage)
142 // it returns true as default
144 if ((dstImage.width <= 0) || (dstImage.height <= 0) || (dstImage.pBitmap == null))
150 switch (dstImage.depth)
154 typedef unsigned long Pixel;
158 for (int y = 0; y < dstImage.height; y++)
160 Pixel* pProbe = (Pixel*) (dstImage.pBitmap + dstImage.bytesPerLine * y);
161 Pixel* pProbeEnd = pProbe + dstImage.width;
163 while (!found && (pProbe < pProbeEnd))
165 found = (((*pProbe++) >> 24) < 0xFF);