📄 rgbindex.h
字号:
//
// RgbIndex.h
// Interface for indexing Rgb images using [row][col][R,G,B].
// Usage is
// (In derived class definition) : public IRgbIndex
// (In derived class constructor) : IRgbIndex(<pointer to memory area>,<Columns>)
// The class will then support indexing by [row][col][Rgbval]
//
// Copyright (C) 2003, 2006 by Jon A. Webb (Contact via GMail; username is jonawebb)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#ifndef RgbIndex_h
#define RgbIndex_h
#include <e32cons.h>
#include <fbs.h>
namespace Core
{
typedef enum { // these are as color images are layed out for DisplayMode == EColor16M
R = 2,
G = 1,
B = 0
} TRgbVal;
// postfix ++
inline TRgbVal operator++(TRgbVal& c, int) {
int nC = int(c);
c = TRgbVal(nC+1);
return TRgbVal(nC);
}
// prefix ++
inline TRgbVal operator++(TRgbVal& c) {
c = TRgbVal(int(c)+1);
return c;
}
class RTwoDRgbIndex
{
friend class IRgbIndex;
// Lifecycle
protected:
inline RTwoDRgbIndex(unsigned char* pData) :
ipData(pData)
{}
public:
inline ~RTwoDRgbIndex() {};
// Operators
public:
inline const unsigned char* operator[](unsigned int nCol) const {
return ipData + nCol * 3;
}
inline unsigned char* operator[](unsigned int nCol) {
return ipData + nCol * 3;
}
private:
// Attributes
unsigned char* ipData;
};
class IRgbIndex
{
// Lifecycle
public:
inline IRgbIndex(const CImage& image) :
inRowBytes(0),
ipData(NULL)
{
_LIT(LRgbErr, "IRgbIndex: Not a color 24-bit image");
__ASSERT_ALWAYS(image.iBitmap.DisplayMode() == EColor16M, User::Panic(LRgbErr, KErrGeneral));
ipData = (unsigned char*) image.iBitmap.DataAddress();
inRowBytes = CFbsBitmap::ScanLineLength(image.iBitmap.SizeInPixels().iWidth, EColor16M);
}
inline IRgbIndex(const IRgbIndex& other)
{
ipData = other.ipData;
inRowBytes = other.inRowBytes;
}
inline ~IRgbIndex(void)
{
};
// Operators
public:
inline IRgbIndex& operator=(const IRgbIndex& other) {
if (this != &other) {
inRowBytes = other.inRowBytes;
ipData = other.ipData;
}
return *this;
}
inline const RTwoDRgbIndex operator[](unsigned int nRow) const {
return RTwoDRgbIndex(ipData + nRow*inRowBytes);
}
inline RTwoDRgbIndex operator[](unsigned int nRow) {
return RTwoDRgbIndex(ipData + nRow*inRowBytes);
}
private:
// Attributes
unsigned int inRowBytes;
unsigned char* ipData;
};
};
#endif // RgbIndex_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -