This commit is contained in:
parent
98ff69a23e
commit
5a8d2b0d90
11 changed files with 267 additions and 198 deletions
|
@ -40,13 +40,12 @@ CLayerRGB::CLayerRGB(sLayerDef &Def)
|
|||
{
|
||||
InitLayer(Def);
|
||||
|
||||
CurrentRGB.R=128;
|
||||
CurrentRGB.G=128;
|
||||
CurrentRGB.B=128;
|
||||
ShadeRGB.R=224;
|
||||
ShadeRGB.G=224;
|
||||
ShadeRGB.B=224;
|
||||
CurrentMode=0;
|
||||
CurrentBrush=0;
|
||||
CurrentRate=0;
|
||||
ShadeFlag=false;
|
||||
LastCursPos.x=-1;
|
||||
LastCursPos.y=-1;
|
||||
CurrentUndo=0;
|
||||
|
@ -71,10 +70,10 @@ void CLayerRGB::Load(CFile *File,int Version)
|
|||
{
|
||||
InitLayer(LayerDef);
|
||||
|
||||
File->Read(&CurrentRGB,sizeof(sRGBElem));
|
||||
File->Read(&ShadeRGB,sizeof(sRGBElem));
|
||||
File->Read(&CurrentBrush,sizeof(int));
|
||||
File->Read(&CurrentMode,sizeof(int));
|
||||
File->Read(&ShadeFlag,sizeof(bool));
|
||||
File->Read(&SpareFlag,sizeof(bool));
|
||||
|
||||
// Read Map
|
||||
File->Read(&MapWidth,sizeof(int));
|
||||
|
@ -95,10 +94,10 @@ void CLayerRGB::Load(CFile *File,int Version)
|
|||
void CLayerRGB::Save(CFile *File)
|
||||
{
|
||||
// Always Save current version
|
||||
File->Write(&CurrentRGB,sizeof(sRGBElem));
|
||||
File->Write(&ShadeRGB,sizeof(sRGBElem));
|
||||
File->Write(&CurrentBrush,sizeof(int));
|
||||
File->Write(&CurrentMode,sizeof(int));
|
||||
File->Write(&ShadeFlag,sizeof(bool));
|
||||
File->Write(&SpareFlag,sizeof(bool));
|
||||
|
||||
// Read Map
|
||||
File->Write(&MapWidth,sizeof(int));
|
||||
|
@ -192,6 +191,12 @@ bool Ret=false;
|
|||
case CmdMsg_Undo:
|
||||
Undo();
|
||||
break;
|
||||
case CmdMsg_Filter:
|
||||
CreateUndo();
|
||||
if (Param0==0) BiFilter(Core);
|
||||
if (Param0==1) TriFilter(Core);
|
||||
if (Param0==2) STriFilter(Core);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -418,6 +423,9 @@ int ListSize,i;
|
|||
GUIRGB.m_RateList.AddString(Str);
|
||||
}
|
||||
|
||||
GUIRGB.m_RSpin.SetRange(0,255);
|
||||
GUIRGB.m_GSpin.SetRange(0,255);
|
||||
GUIRGB.m_BSpin.SetRange(0,255);
|
||||
GUIRGB.EnableCallback();
|
||||
Core->RedrawView();
|
||||
}
|
||||
|
@ -438,7 +446,7 @@ void CLayerRGB::GUIUpdate(CCore *Core)
|
|||
GUIRGB.m_ModeList.SetCurSel(CurrentMode);
|
||||
GUIRGB.m_BrushList.SetCurSel(CurrentBrush);
|
||||
GUIRGB.m_RateList.SetCurSel(CurrentRate);
|
||||
GUIRGB.m_Shade.SetCheck(ShadeFlag);
|
||||
GUIRGB.SetRGB(ShadeRGB.R,ShadeRGB.G,ShadeRGB.B);
|
||||
GUIRGB.EnableCallback();
|
||||
}
|
||||
|
||||
|
@ -448,7 +456,8 @@ void CLayerRGB::GUIChanged(CCore *Core)
|
|||
CurrentMode=GUIRGB.m_ModeList.GetCurSel();
|
||||
CurrentBrush=GUIRGB.m_BrushList.GetCurSel();
|
||||
CurrentRate=GUIRGB.m_RateList.GetCurSel();
|
||||
ShadeFlag=GUIRGB.m_Shade.GetCheck()!=0;
|
||||
GUIRGB.GetRGB(ShadeRGB.R,ShadeRGB.G,ShadeRGB.B);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -568,7 +577,6 @@ int Ofs=0;
|
|||
RGB=MapElem.R+RGBInc;
|
||||
break;
|
||||
case GUI_MODE_DARKEN:
|
||||
// RGBInc=255-RGBInc;
|
||||
RGB=MapElem.R-RGBInc;
|
||||
break;
|
||||
}
|
||||
|
@ -593,20 +601,150 @@ void CLayerRGB::Grab(CCore *Core,CPoint &CursorPos)
|
|||
GUIUpdate(Core);
|
||||
*/
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerRGB::BiFilter(CCore *Core)
|
||||
{
|
||||
for(int Y=0;Y<MapHeight; Y++)
|
||||
{
|
||||
for(int X=0; X<MapWidth; X++)
|
||||
{
|
||||
int SCol=0,SCount=0;
|
||||
|
||||
// *p=(( (*p) + ( ( *(p+1)+*(p-1)+*(p-WIDTH)+*(p+WIDTH) ) >>2 ) )>>1);
|
||||
GetFilterCol(Core,X-1,Y+0,SCol,SCount);
|
||||
GetFilterCol(Core,X+1,Y+0,SCol,SCount);
|
||||
GetFilterCol(Core,X+0,Y-1,SCol,SCount);
|
||||
GetFilterCol(Core,X+0,Y+1,SCol,SCount);
|
||||
if (SCount)
|
||||
{
|
||||
SCol/=SCount;
|
||||
SetFilterCol(Core,X,Y,SCol,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerRGB::TriFilter(CCore *Core)
|
||||
{
|
||||
for(int Y=0;Y<MapHeight; Y++)
|
||||
{
|
||||
for(int X=0; X<MapWidth; X++)
|
||||
{
|
||||
int SCol=0,SCount=0;
|
||||
|
||||
// *p=(( (*p) + ( (*(p+1)+*(p-1)+*(p-WIDTH)+*(p+WIDTH)+*(p-WIDTH-1)+*(p-WIDTH+1)+*(p+WIDTH-1)+*(p+WIDTH+1)) >>3 ) )>>1);
|
||||
GetFilterCol(Core,X-1,Y-1,SCol,SCount);
|
||||
GetFilterCol(Core,X+0,Y-1,SCol,SCount);
|
||||
GetFilterCol(Core,X+1,Y-1,SCol,SCount);
|
||||
GetFilterCol(Core,X-1,Y+0,SCol,SCount);
|
||||
GetFilterCol(Core,X+1,Y+0,SCol,SCount);
|
||||
GetFilterCol(Core,X-1,Y+1,SCol,SCount);
|
||||
GetFilterCol(Core,X+0,Y+1,SCol,SCount);
|
||||
GetFilterCol(Core,X+1,Y+1,SCol,SCount);
|
||||
if (SCount)
|
||||
{
|
||||
SCol/=SCount;
|
||||
SetFilterCol(Core,X,Y,SCol,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerRGB::STriFilter(CCore *Core)
|
||||
{
|
||||
for(int Y=0;Y<MapHeight; Y++)
|
||||
{
|
||||
for(int X=0; X<MapWidth; X++)
|
||||
{
|
||||
int SCol=0,SCount=0;
|
||||
// c=(( (*p) + ( (*(p+1)+*(p-1)+*(p-WIDTH)+*(p+WIDTH)+*(p-WIDTH-1)+*(p-WIDTH+1)+*(p+WIDTH-1)+*(p+WIDTH+1)) >>3 ) )>>1);
|
||||
// *(p-WIDTH-1)=c;
|
||||
// *(p-WIDTH+1)=c;
|
||||
// *(p+WIDTH-1)=c;
|
||||
// *(p+WIDTH+1)=c;
|
||||
|
||||
GetFilterCol(Core,X-1,Y-1,SCol,SCount);
|
||||
GetFilterCol(Core,X+0,Y-1,SCol,SCount);
|
||||
GetFilterCol(Core,X+1,Y-1,SCol,SCount);
|
||||
GetFilterCol(Core,X-1,Y+0,SCol,SCount);
|
||||
GetFilterCol(Core,X+1,Y+0,SCol,SCount);
|
||||
GetFilterCol(Core,X-1,Y+1,SCol,SCount);
|
||||
GetFilterCol(Core,X+0,Y+1,SCol,SCount);
|
||||
GetFilterCol(Core,X+1,Y+1,SCol,SCount);
|
||||
if (SCount)
|
||||
{
|
||||
SCol/=SCount;
|
||||
SetFilterCol(Core,X-1,Y-1,SCol,1);
|
||||
SetFilterCol(Core,X+1,Y-1,SCol,1);
|
||||
SetFilterCol(Core,X-1,Y+1,SCol,1);
|
||||
SetFilterCol(Core,X+1,Y+1,SCol,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerRGB::GetFilterCol(CCore *Core,int X,int Y,int &SumCol,int &Count)
|
||||
{
|
||||
CLayerTile *ActionLayer=(CLayerTile*)Core->GetActionLayer();
|
||||
|
||||
if (X>=0 && X<MapWidth && Y>=0 && Y<MapHeight)
|
||||
{
|
||||
sMapElem &MapElem=ActionLayer->GetMapElem(X,Y);
|
||||
if (MapElem.Tile)
|
||||
{
|
||||
sRGBElem &C=Map[X][Y];
|
||||
SumCol+=C.R;
|
||||
Count++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerRGB::SetFilterCol(CCore *Core,int X,int Y,int Col,int Div)
|
||||
{
|
||||
CLayerTile *ActionLayer=(CLayerTile*)Core->GetActionLayer();
|
||||
|
||||
if (X>=0 && X<MapWidth && Y>=0 && Y<MapHeight)
|
||||
{
|
||||
sMapElem &MapElem=ActionLayer->GetMapElem(X,Y);
|
||||
if (MapElem.Tile)
|
||||
{
|
||||
sRGBElem &ThisElem=Map[X][Y];
|
||||
Col+=ThisElem.R;
|
||||
if (Div) Col/=Div;
|
||||
ThisElem.R=Col;
|
||||
ThisElem.G=Col;
|
||||
ThisElem.B=Col;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*****************************************************************************/
|
||||
void CLayerRGB::Export(CCore *Core,CExport &Exp)
|
||||
{
|
||||
sRGBCol RGB;
|
||||
|
||||
Exp.ExportLayerHeader(LayerDef);//LAYER_TYPE_RGB,LayerDef.SubType,LayerDef.Width,LayerDef.Height);
|
||||
|
||||
int f=ShadeFlag;
|
||||
Exp.Write(&f,sizeof(int));
|
||||
RGB.R=ShadeRGB.R;
|
||||
RGB.G=ShadeRGB.G;
|
||||
RGB.B=ShadeRGB.B;
|
||||
|
||||
Exp.Write(&RGB,sizeof(sRGBCol));
|
||||
|
||||
for (int Y=0; Y<MapHeight; Y++)
|
||||
{
|
||||
for (int X=0; X<MapWidth; X++)
|
||||
{
|
||||
sRGBElem &ThisElem=Map[X][Y];
|
||||
sRGBCol RGB;
|
||||
|
||||
RGB.R=ThisElem.R;
|
||||
RGB.G=ThisElem.G;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue