mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
fix shadowed stuff that in reality was case sensitive naming of variables but sucks for me\!
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@116 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
* With some input from the "subtitle plugin" by Pekka Virtanen <pekka.virtanen@sci.fi>
|
* With some input from the "subtitle plugin" by Pekka Virtanen <pekka.virtanen@sci.fi>
|
||||||
*
|
*
|
||||||
* $Id: dvbsubtitle.cpp,v 1.1 2009/02/23 19:46:44 rhabarber1848 Exp $
|
* $Id: dvbsubtitle.cpp,v 1.1 2009/02/23 19:46:44 rhabarber1848 Exp $
|
||||||
* dvbsubtitle for HD1 ported by Coolstream LTD
|
* dvbsubtitle for HD1 ported by Coolstream LTD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dvbsubtitle.h"
|
#include "dvbsubtitle.h"
|
||||||
@@ -72,27 +72,27 @@ public:
|
|||||||
cSubtitleClut(int ClutId);
|
cSubtitleClut(int ClutId);
|
||||||
int ClutId(void) { return clutId; }
|
int ClutId(void) { return clutId; }
|
||||||
int Version(void) { return version; }
|
int Version(void) { return version; }
|
||||||
void SetVersion(int Version) { version = Version; }
|
void SetVersion(int pVersion) { version = pVersion; }
|
||||||
void SetColor(int Bpp, int Index, tColor Color);
|
void SetColor(int Bpp, int Index, tColor Color);
|
||||||
const cPalette *GetPalette(int Bpp);
|
const cPalette *GetPalette(int Bpp);
|
||||||
};
|
};
|
||||||
|
|
||||||
cSubtitleClut::cSubtitleClut(int ClutId)
|
cSubtitleClut::cSubtitleClut(int pClutId)
|
||||||
:palette2(2)
|
:palette2(2)
|
||||||
,palette4(4)
|
,palette4(4)
|
||||||
,palette8(8)
|
,palette8(8)
|
||||||
{
|
{
|
||||||
clutId = ClutId;
|
clutId = pClutId;
|
||||||
version = -1;
|
version = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSubtitleClut::SetColor(int Bpp, int Index, tColor Color)
|
void cSubtitleClut::SetColor(int Bpp, int pIndex, tColor Color)
|
||||||
{
|
{
|
||||||
switch (Bpp) {
|
switch (Bpp) {
|
||||||
case 2: palette2.SetColor(Index, Color); break;
|
case 2: palette2.SetColor(pIndex, Color); break;
|
||||||
case 4: palette4.SetColor(Index, Color); break;
|
case 4: palette4.SetColor(pIndex, Color); break;
|
||||||
case 8: palette8.SetColor(Index, Color); break;
|
case 8: palette8.SetColor(pIndex, Color); break;
|
||||||
default: esyslog("ERROR: wrong Bpp in cSubtitleClut::SetColor(%d, %d, %08X)", Bpp, Index, Color);
|
default: esyslog("ERROR: wrong Bpp in cSubtitleClut::SetColor(%d, %d, %08X)", Bpp, pIndex, Color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,18 +135,18 @@ public:
|
|||||||
int CodingMethod(void) { return codingMethod; }
|
int CodingMethod(void) { return codingMethod; }
|
||||||
bool NonModifyingColorFlag(void) { return nonModifyingColorFlag; }
|
bool NonModifyingColorFlag(void) { return nonModifyingColorFlag; }
|
||||||
void DecodeSubBlock(const uchar *Data, int Length, bool Even);
|
void DecodeSubBlock(const uchar *Data, int Length, bool Even);
|
||||||
void SetVersion(int Version) { version = Version; }
|
void SetVersion(int pVersion) { version = pVersion; }
|
||||||
void SetBackgroundColor(uchar BackgroundColor) { backgroundColor = BackgroundColor; }
|
void SetBackgroundColor(uchar BackgroundColor) { backgroundColor = BackgroundColor; }
|
||||||
void SetForegroundColor(uchar ForegroundColor) { foregroundColor = ForegroundColor; }
|
void SetForegroundColor(uchar ForegroundColor) { foregroundColor = ForegroundColor; }
|
||||||
void SetNonModifyingColorFlag(bool NonModifyingColorFlag) { nonModifyingColorFlag = NonModifyingColorFlag; }
|
void SetNonModifyingColorFlag(bool pNonModifyingColorFlag) { nonModifyingColorFlag = pNonModifyingColorFlag; }
|
||||||
void SetCodingMethod(int CodingMethod) { codingMethod = CodingMethod; }
|
void SetCodingMethod(int pCodingMethod) { codingMethod = pCodingMethod; }
|
||||||
void SetPosition(int x, int y) { px = x; py = y; }
|
void SetPosition(int x, int y) { px = x; py = y; }
|
||||||
void SetProviderFlag(int ProviderFlag) { providerFlag = ProviderFlag; }
|
void SetProviderFlag(int pProviderFlag) { providerFlag = pProviderFlag; }
|
||||||
};
|
};
|
||||||
|
|
||||||
cSubtitleObject::cSubtitleObject(int ObjectId, cBitmap *Bitmap)
|
cSubtitleObject::cSubtitleObject(int pObjectId, cBitmap *pBitmap)
|
||||||
{
|
{
|
||||||
objectId = ObjectId;
|
objectId = pObjectId;
|
||||||
version = -1;
|
version = -1;
|
||||||
codingMethod = -1;
|
codingMethod = -1;
|
||||||
nonModifyingColorFlag = false;
|
nonModifyingColorFlag = false;
|
||||||
@@ -155,7 +155,7 @@ cSubtitleObject::cSubtitleObject(int ObjectId, cBitmap *Bitmap)
|
|||||||
foregroundColor = 0;
|
foregroundColor = 0;
|
||||||
providerFlag = -1;
|
providerFlag = -1;
|
||||||
px = py = 0;
|
px = py = 0;
|
||||||
bitmap = Bitmap;
|
bitmap = pBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSubtitleObject::DecodeSubBlock(const uchar *Data, int Length, bool Even)
|
void cSubtitleObject::DecodeSubBlock(const uchar *Data, int Length, bool Even)
|
||||||
@@ -204,32 +204,32 @@ void cSubtitleObject::DecodeSubBlock(const uchar *Data, int Length, bool Even)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSubtitleObject::DrawLine(int x, int y, tIndex Index, int Length)
|
void cSubtitleObject::DrawLine(int x, int y, tIndex pIndex, int Length)
|
||||||
{
|
{
|
||||||
if (nonModifyingColorFlag && Index == 1)
|
if (nonModifyingColorFlag && pIndex == 1)
|
||||||
return;
|
return;
|
||||||
x += px;
|
x += px;
|
||||||
y += py;
|
y += py;
|
||||||
for (int pos = x; pos < x + Length; pos++)
|
for (int pos = x; pos < x + Length; pos++)
|
||||||
bitmap->SetIndex(pos, y, Index);
|
bitmap->SetIndex(pos, y, pIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar cSubtitleObject::Get2Bits(const uchar *Data, int &Index)
|
uchar cSubtitleObject::Get2Bits(const uchar *Data, int &pIndex)
|
||||||
{
|
{
|
||||||
uchar result = Data[Index];
|
uchar result = Data[pIndex];
|
||||||
if (!nibblePos) {
|
if (!nibblePos) {
|
||||||
Index++;
|
pIndex++;
|
||||||
nibblePos = 8;
|
nibblePos = 8;
|
||||||
}
|
}
|
||||||
nibblePos -= 2;
|
nibblePos -= 2;
|
||||||
return (result >> nibblePos) & 0x03;
|
return (result >> nibblePos) & 0x03;
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar cSubtitleObject::Get4Bits(const uchar *Data, int &Index)
|
uchar cSubtitleObject::Get4Bits(const uchar *Data, int &pIndex)
|
||||||
{
|
{
|
||||||
uchar result = Data[Index];
|
uchar result = Data[pIndex];
|
||||||
if (!nibblePos) {
|
if (!nibblePos) {
|
||||||
Index++;
|
pIndex++;
|
||||||
nibblePos = 4;
|
nibblePos = 4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -239,25 +239,25 @@ uchar cSubtitleObject::Get4Bits(const uchar *Data, int &Index)
|
|||||||
return result & 0x0F;
|
return result & 0x0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &Index, int &x, int y)
|
bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &pIndex, int &x, int y)
|
||||||
{
|
{
|
||||||
int rl = 0;
|
int rl = 0;
|
||||||
int color = 0;
|
int color = 0;
|
||||||
uchar code = Get2Bits(Data, Index);
|
uchar code = Get2Bits(Data, pIndex);
|
||||||
if (code) {
|
if (code) {
|
||||||
color = code;
|
color = code;
|
||||||
rl = 1;
|
rl = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
code = Get2Bits(Data, Index);
|
code = Get2Bits(Data, pIndex);
|
||||||
if (code & 2) { // switch_1
|
if (code & 2) { // switch_1
|
||||||
rl = ((code & 1) << 2) + Get2Bits(Data, Index) + 3;
|
rl = ((code & 1) << 2) + Get2Bits(Data, pIndex) + 3;
|
||||||
color = Get2Bits(Data, Index);
|
color = Get2Bits(Data, pIndex);
|
||||||
}
|
}
|
||||||
else if (code & 1)
|
else if (code & 1)
|
||||||
rl = 1; //color 0
|
rl = 1; //color 0
|
||||||
else {
|
else {
|
||||||
code = Get2Bits(Data, Index);
|
code = Get2Bits(Data, pIndex);
|
||||||
switch (code & 0x3) { //switch_3
|
switch (code & 0x3) { //switch_3
|
||||||
case 0:
|
case 0:
|
||||||
return false;
|
return false;
|
||||||
@@ -265,12 +265,12 @@ bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &Index, int &x
|
|||||||
rl = 2; //color 0
|
rl = 2; //color 0
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
rl = (Get2Bits(Data, Index) << 2) + Get2Bits(Data, Index) + 12;
|
rl = (Get2Bits(Data, pIndex) << 2) + Get2Bits(Data, pIndex) + 12;
|
||||||
color = Get2Bits(Data, Index);
|
color = Get2Bits(Data, pIndex);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
rl = (Get2Bits(Data, Index) << 6) + (Get2Bits(Data, Index) << 4) + (Get2Bits(Data, Index) << 2) + Get2Bits(Data, Index) + 29;
|
rl = (Get2Bits(Data, pIndex) << 6) + (Get2Bits(Data, pIndex) << 4) + (Get2Bits(Data, pIndex) << 2) + Get2Bits(Data, pIndex) + 29;
|
||||||
color = Get2Bits(Data, Index);
|
color = Get2Bits(Data, pIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,17 +280,17 @@ bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &Index, int &x
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &Index, int &x, int y)
|
bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &pIndex, int &x, int y)
|
||||||
{
|
{
|
||||||
int rl = 0;
|
int rl = 0;
|
||||||
int color = 0;
|
int color = 0;
|
||||||
uchar code = Get4Bits(Data, Index);
|
uchar code = Get4Bits(Data, pIndex);
|
||||||
if (code) {
|
if (code) {
|
||||||
color = code;
|
color = code;
|
||||||
rl = 1;
|
rl = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
code = Get4Bits(Data, Index);
|
code = Get4Bits(Data, pIndex);
|
||||||
if (code & 8) { // switch_1
|
if (code & 8) { // switch_1
|
||||||
if (code & 4) { //switch_2
|
if (code & 4) { //switch_2
|
||||||
switch (code & 3) { //switch_3
|
switch (code & 3) { //switch_3
|
||||||
@@ -301,18 +301,18 @@ bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &Index, int &x
|
|||||||
rl = 2;
|
rl = 2;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
rl = Get4Bits(Data, Index) + 9;
|
rl = Get4Bits(Data, pIndex) + 9;
|
||||||
color = Get4Bits(Data, Index);
|
color = Get4Bits(Data, pIndex);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
rl = (Get4Bits(Data, Index) << 4) + Get4Bits(Data, Index) + 25;
|
rl = (Get4Bits(Data, pIndex) << 4) + Get4Bits(Data, pIndex) + 25;
|
||||||
color = Get4Bits(Data, Index);
|
color = Get4Bits(Data, pIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rl = (code & 3) + 4;
|
rl = (code & 3) + 4;
|
||||||
color = Get4Bits(Data, Index);
|
color = Get4Bits(Data, pIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // color 0
|
else { // color 0
|
||||||
@@ -326,20 +326,20 @@ bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &Index, int &x
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSubtitleObject::Decode8BppCodeString(const uchar *Data, int &Index, int &x, int y)
|
bool cSubtitleObject::Decode8BppCodeString(const uchar *Data, int &pIndex, int &x, int y)
|
||||||
{
|
{
|
||||||
int rl = 0;
|
int rl = 0;
|
||||||
int color = 0;
|
int color = 0;
|
||||||
uchar code = Data[Index++];
|
uchar code = Data[pIndex++];
|
||||||
if (code) {
|
if (code) {
|
||||||
color = code;
|
color = code;
|
||||||
rl = 1;
|
rl = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
code = Data[Index++];
|
code = Data[pIndex++];
|
||||||
rl = code & 0x63;
|
rl = code & 0x63;
|
||||||
if (code & 0x80)
|
if (code & 0x80)
|
||||||
color = Data[Index++];
|
color = Data[pIndex++];
|
||||||
else if (!rl)
|
else if (!rl)
|
||||||
return false; //else color 0
|
return false; //else color 0
|
||||||
}
|
}
|
||||||
@@ -370,18 +370,18 @@ public:
|
|||||||
cSubtitleObject *GetObjectById(int ObjectId, bool New = false);
|
cSubtitleObject *GetObjectById(int ObjectId, bool New = false);
|
||||||
int HorizontalAddress(void) { return horizontalAddress; }
|
int HorizontalAddress(void) { return horizontalAddress; }
|
||||||
int VerticalAddress(void) { return verticalAddress; }
|
int VerticalAddress(void) { return verticalAddress; }
|
||||||
void SetVersion(int Version) { version = Version; }
|
void SetVersion(int pVersion) { version = pVersion; }
|
||||||
void SetClutId(int ClutId) { clutId = ClutId; }
|
void SetClutId(int pClutId) { clutId = pClutId; }
|
||||||
void SetLevel(int Level);
|
void SetLevel(int Level);
|
||||||
void SetDepth(int Depth);
|
void SetDepth(int Depth);
|
||||||
void SetHorizontalAddress(int HorizontalAddress) { horizontalAddress = HorizontalAddress; }
|
void SetHorizontalAddress(int pHorizontalAddress) { horizontalAddress = pHorizontalAddress; }
|
||||||
void SetVerticalAddress(int VerticalAddress) { verticalAddress = VerticalAddress; }
|
void SetVerticalAddress(int pVerticalAddress) { verticalAddress = pVerticalAddress; }
|
||||||
};
|
};
|
||||||
|
|
||||||
cSubtitleRegion::cSubtitleRegion(int RegionId)
|
cSubtitleRegion::cSubtitleRegion(int pRegionId)
|
||||||
:cBitmap(1, 1, 4)
|
:cBitmap(1, 1, 4)
|
||||||
{
|
{
|
||||||
regionId = RegionId;
|
regionId = pRegionId;
|
||||||
version = -1;
|
version = -1;
|
||||||
clutId = -1;
|
clutId = -1;
|
||||||
horizontalAddress = 0;
|
horizontalAddress = 0;
|
||||||
@@ -389,12 +389,12 @@ cSubtitleRegion::cSubtitleRegion(int RegionId)
|
|||||||
level = 0;
|
level = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSubtitleRegion::FillRegion(tIndex Index)
|
void cSubtitleRegion::FillRegion(tIndex pIndex)
|
||||||
{
|
{
|
||||||
dbgregions("FillRegion %d\n", Index);
|
dbgregions("FillRegion %d\n", pIndex);
|
||||||
for (int y = 0; y < Height(); y++) {
|
for (int y = 0; y < Height(); y++) {
|
||||||
for (int x = 0; x < Width(); x++)
|
for (int x = 0; x < Width(); x++)
|
||||||
SetIndex(x, y, Index);
|
SetIndex(x, y, pIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,16 +412,16 @@ cSubtitleObject *cSubtitleRegion::GetObjectById(int ObjectId, bool New)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSubtitleRegion::SetLevel(int Level)
|
void cSubtitleRegion::SetLevel(int pLevel)
|
||||||
{
|
{
|
||||||
if (Level > 0 && Level < 4)
|
if (pLevel > 0 && pLevel < 4)
|
||||||
level = 1 << Level;
|
level = 1 << pLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSubtitleRegion::SetDepth(int Depth)
|
void cSubtitleRegion::SetDepth(int pDepth)
|
||||||
{
|
{
|
||||||
if (Depth > 0 && Depth < 4)
|
if (pDepth > 0 && pDepth < 4)
|
||||||
SetBpp(1 << Depth);
|
SetBpp(1 << pDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- cDvbSubtitlePage ------------------------------------------------------
|
// --- cDvbSubtitlePage ------------------------------------------------------
|
||||||
@@ -447,16 +447,16 @@ public:
|
|||||||
cSubtitleRegion *GetRegionById(int RegionId, bool New = false);
|
cSubtitleRegion *GetRegionById(int RegionId, bool New = false);
|
||||||
int64_t Pts(void) const { return pts; }
|
int64_t Pts(void) const { return pts; }
|
||||||
int Timeout(void) { return timeout; }
|
int Timeout(void) { return timeout; }
|
||||||
void SetVersion(int Version) { version = Version; }
|
void SetVersion(int pVersion) { version = pVersion; }
|
||||||
void SetPts(int64_t Pts) { pts = Pts; }
|
void SetPts(int64_t pPts) { pts = pPts; }
|
||||||
void SetState(int State);
|
void SetState(int State);
|
||||||
void SetTimeout(int Timeout) { timeout = Timeout; }
|
void SetTimeout(int pTimeout) { timeout = pTimeout; }
|
||||||
void UpdateRegionPalette(cSubtitleClut *Clut);
|
void UpdateRegionPalette(cSubtitleClut *Clut);
|
||||||
};
|
};
|
||||||
|
|
||||||
cDvbSubtitlePage::cDvbSubtitlePage(int PageId)
|
cDvbSubtitlePage::cDvbSubtitlePage(int pPageId)
|
||||||
{
|
{
|
||||||
pageId = PageId;
|
pageId = pPageId;
|
||||||
version = -1;
|
version = -1;
|
||||||
state = -1;
|
state = -1;
|
||||||
pts = 0;
|
pts = 0;
|
||||||
@@ -523,9 +523,9 @@ cSubtitleObject *cDvbSubtitlePage::GetObjectById(int ObjectId)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDvbSubtitlePage::SetState(int State)
|
void cDvbSubtitlePage::SetState(int pState)
|
||||||
{
|
{
|
||||||
state = State;
|
state = pState;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0: // normal case - page update
|
case 0: // normal case - page update
|
||||||
dbgpages("page update\n");
|
dbgpages("page update\n");
|
||||||
@@ -643,12 +643,12 @@ public:
|
|||||||
void Clear(void);
|
void Clear(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
cDvbSubtitleBitmaps::cDvbSubtitleBitmaps(int64_t Pts, int Timeout, tArea *Areas, int NumAreas)
|
cDvbSubtitleBitmaps::cDvbSubtitleBitmaps(int64_t pPts, int pTimeout, tArea *pAreas, int pNumAreas)
|
||||||
{
|
{
|
||||||
pts = Pts;
|
pts = pPts;
|
||||||
timeout = Timeout;
|
timeout = pTimeout;
|
||||||
areas = Areas;
|
areas = pAreas;
|
||||||
numAreas = NumAreas;
|
numAreas = pNumAreas;
|
||||||
// max_x = max_y = 0;
|
// max_x = max_y = 0;
|
||||||
// min_x = min_y = 0xFFFF;
|
// min_x = min_y = 0xFFFF;
|
||||||
//dbgconverter("cDvbSubtitleBitmaps::new: PTS: %lld\n", pts);
|
//dbgconverter("cDvbSubtitleBitmaps::new: PTS: %lld\n", pts);
|
||||||
@@ -708,7 +708,7 @@ void cDvbSubtitleBitmaps::Draw()
|
|||||||
int yoff = (yend - (576-bitmaps[i]->Y0()))*stride;
|
int yoff = (yend - (576-bitmaps[i]->Y0()))*stride;
|
||||||
int ys = yend - (576-bitmaps[i]->Y0());
|
int ys = yend - (576-bitmaps[i]->Y0());
|
||||||
|
|
||||||
dbgconverter("cDvbSubtitleBitmaps::Draw %d colors= %d at %d,%d (x=%d y=%d) size %dx%d\n",
|
dbgconverter("cDvbSubtitleBitmaps::Draw %d colors= %d at %d,%d (x=%d y=%d) size %dx%d\n",
|
||||||
i, NumColors, bitmaps[i]->X0(), bitmaps[i]->Y0(), xoff, ys, bitmaps[i]->Width(), bitmaps[i]->Height());
|
i, NumColors, bitmaps[i]->X0(), bitmaps[i]->Y0(), xoff, ys, bitmaps[i]->Width(), bitmaps[i]->Height());
|
||||||
|
|
||||||
for (int y2 = 0; y2 < bitmaps[i]->Height(); y2++) {
|
for (int y2 = 0; y2 < bitmaps[i]->Height(); y2++) {
|
||||||
|
@@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
// --- cPalette --------------------------------------------------------------
|
// --- cPalette --------------------------------------------------------------
|
||||||
|
|
||||||
cPalette::cPalette(int Bpp)
|
cPalette::cPalette(int pBpp)
|
||||||
{
|
{
|
||||||
SetBpp(Bpp);
|
SetBpp(pBpp);
|
||||||
SetAntiAliasGranularity(10, 10);
|
SetAntiAliasGranularity(10, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,44 +41,44 @@ void cPalette::Reset(void)
|
|||||||
modified = false;
|
modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cPalette::Index(tColor Color)
|
int cPalette::Index(tColor pColor)
|
||||||
{
|
{
|
||||||
// Check if color is already defined:
|
// Check if color is already defined:
|
||||||
for (int i = 0; i < numColors; i++) {
|
for (int i = 0; i < numColors; i++) {
|
||||||
if (color[i] == Color)
|
if (color[i] == pColor)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
// No exact color, try a close one:
|
// No exact color, try a close one:
|
||||||
int i = ClosestColor(Color, 4);
|
int i = ClosestColor(pColor, 4);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
return i;
|
return i;
|
||||||
// No close one, try to define a new one:
|
// No close one, try to define a new one:
|
||||||
if (numColors < maxColors) {
|
if (numColors < maxColors) {
|
||||||
color[numColors++] = Color;
|
color[numColors++] = pColor;
|
||||||
modified = true;
|
modified = true;
|
||||||
return numColors - 1;
|
return numColors - 1;
|
||||||
}
|
}
|
||||||
// Out of colors, so any close color must do:
|
// Out of colors, so any close color must do:
|
||||||
return ClosestColor(Color);
|
return ClosestColor(pColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPalette::SetBpp(int Bpp)
|
void cPalette::SetBpp(int pBpp)
|
||||||
{
|
{
|
||||||
bpp = Bpp;
|
bpp = pBpp;
|
||||||
maxColors = 1 << bpp;
|
maxColors = 1 << bpp;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPalette::SetColor(int Index, tColor Color)
|
void cPalette::SetColor(int pIndex, tColor pColor)
|
||||||
{
|
{
|
||||||
if (Index < maxColors) {
|
if (pIndex < maxColors) {
|
||||||
if (numColors <= Index) {
|
if (numColors <= pIndex) {
|
||||||
numColors = Index + 1;
|
numColors = pIndex + 1;
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
modified |= color[Index] != Color;
|
modified |= color[pIndex] != pColor;
|
||||||
color[Index] = Color;
|
color[pIndex] = pColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,14 +91,14 @@ const tColor *cPalette::Colors(int &NumColors) const
|
|||||||
void cPalette::Take(const cPalette &Palette, tIndexes *Indexes, tColor ColorFg, tColor ColorBg)
|
void cPalette::Take(const cPalette &Palette, tIndexes *Indexes, tColor ColorFg, tColor ColorBg)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Palette.numColors; i++) {
|
for (int i = 0; i < Palette.numColors; i++) {
|
||||||
tColor Color = Palette.color[i];
|
tColor pColor = Palette.color[i];
|
||||||
if (ColorFg || ColorBg) {
|
if (ColorFg || ColorBg) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: Color = ColorBg; break;
|
case 0: pColor = ColorBg; break;
|
||||||
case 1: Color = ColorFg; break;
|
case 1: pColor = ColorFg; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int n = Index(Color);
|
int n = Index(pColor);
|
||||||
if (Indexes)
|
if (Indexes)
|
||||||
(*Indexes)[i] = n;
|
(*Indexes)[i] = n;
|
||||||
}
|
}
|
||||||
@@ -131,14 +131,14 @@ tColor cPalette::Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const
|
|||||||
return (A << 24) | (R << 16) | (G << 8) | B;
|
return (A << 24) | (R << 16) | (G << 8) | B;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cPalette::ClosestColor(tColor Color, int MaxDiff) const
|
int cPalette::ClosestColor(tColor pColor, int MaxDiff) const
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int d = INT_MAX;
|
int d = INT_MAX;
|
||||||
int A1 = (Color & 0xFF000000) >> 24;
|
int A1 = (pColor & 0xFF000000) >> 24;
|
||||||
int R1 = (Color & 0x00FF0000) >> 16;
|
int R1 = (pColor & 0x00FF0000) >> 16;
|
||||||
int G1 = (Color & 0x0000FF00) >> 8;
|
int G1 = (pColor & 0x0000FF00) >> 8;
|
||||||
int B1 = (Color & 0x000000FF);
|
int B1 = (pColor & 0x000000FF);
|
||||||
for (int i = 0; i < numColors; i++) {
|
for (int i = 0; i < numColors; i++) {
|
||||||
int A2 = (color[i] & 0xFF000000) >> 24;
|
int A2 = (color[i] & 0xFF000000) >> 24;
|
||||||
int R2 = (color[i] & 0x00FF0000) >> 16;
|
int R2 = (color[i] & 0x00FF0000) >> 16;
|
||||||
@@ -153,13 +153,13 @@ int cPalette::ClosestColor(tColor Color, int MaxDiff) const
|
|||||||
return d <= MaxDiff ? n : -1;
|
return d <= MaxDiff ? n : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cBitmap::cBitmap(int Width, int Height, int Bpp, int X0, int Y0)
|
cBitmap::cBitmap(int pWidth, int pHeight, int pBpp, int pX0, int pY0)
|
||||||
:cPalette(Bpp)
|
:cPalette(pBpp)
|
||||||
{
|
{
|
||||||
bitmap = NULL;
|
bitmap = NULL;
|
||||||
x0 = X0;
|
x0 = pX0;
|
||||||
y0 = Y0;
|
y0 = pY0;
|
||||||
SetSize(Width, Height);
|
SetSize(pWidth, pHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
cBitmap::~cBitmap()
|
cBitmap::~cBitmap()
|
||||||
@@ -167,12 +167,12 @@ cBitmap::~cBitmap()
|
|||||||
free(bitmap);
|
free(bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cBitmap::SetIndex(int x, int y, tIndex Index)
|
void cBitmap::SetIndex(int x, int y, tIndex pIndex)
|
||||||
{
|
{
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
if (0 <= x && x < width && 0 <= y && y < height) {
|
if (0 <= x && x < width && 0 <= y && y < height) {
|
||||||
if (bitmap[width * y + x] != Index) {
|
if (bitmap[width * y + x] != pIndex) {
|
||||||
bitmap[width * y + x] = Index;
|
bitmap[width * y + x] = pIndex;
|
||||||
if (dirtyX1 > x) dirtyX1 = x;
|
if (dirtyX1 > x) dirtyX1 = x;
|
||||||
if (dirtyY1 > y) dirtyY1 = y;
|
if (dirtyY1 > y) dirtyY1 = y;
|
||||||
if (dirtyX2 < x) dirtyX2 = x;
|
if (dirtyX2 < x) dirtyX2 = x;
|
||||||
@@ -182,12 +182,12 @@ void cBitmap::SetIndex(int x, int y, tIndex Index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cBitmap::SetSize(int Width, int Height)
|
void cBitmap::SetSize(int pWidth, int pHeight)
|
||||||
{
|
{
|
||||||
if (bitmap && Width == width && Height == height)
|
if (bitmap && pWidth == width && pHeight == height)
|
||||||
return;
|
return;
|
||||||
width = Width;
|
width = pWidth;
|
||||||
height = Height;
|
height = pHeight;
|
||||||
free(bitmap);
|
free(bitmap);
|
||||||
bitmap = NULL;
|
bitmap = NULL;
|
||||||
dirtyX1 = 0;
|
dirtyX1 = 0;
|
||||||
|
@@ -50,7 +50,7 @@ public:
|
|||||||
///< If Color is not yet contained in this palette, it will be added if
|
///< If Color is not yet contained in this palette, it will be added if
|
||||||
///< there is a free slot. If the color can't be added to this palette,
|
///< there is a free slot. If the color can't be added to this palette,
|
||||||
///< the closest existing color will be returned.
|
///< the closest existing color will be returned.
|
||||||
tColor Color(int Index) const { return Index < maxColors ? color[Index] : 0; }
|
tColor Color(int pIndex) const { return pIndex < maxColors ? color[pIndex] : 0; }
|
||||||
///< Returns the color at the given Index. If Index is outside the valid
|
///< Returns the color at the given Index. If Index is outside the valid
|
||||||
///< range, 0 will be returned.
|
///< range, 0 will be returned.
|
||||||
void SetBpp(int Bpp);
|
void SetBpp(int Bpp);
|
||||||
|
Reference in New Issue
Block a user