/*****************/ /*** Layer RGB ***/ /*****************/ #include #include #include "MkLevelLayer.h" #include "MkLevelLayerRGB.h" /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ CMkLevelLayerRGB::CMkLevelLayerRGB(sExpLayerHdr *LayerHdr) { int *iPtr; u8 *Ptr=(u8*)LayerHdr; Type=LayerHdr->Type; SubType=LayerHdr->SubType; Width=LayerHdr->Width; Height=LayerHdr->Height; RGBMap.SetSize(Width,Height); iPtr=(int*)(Ptr+sizeof(sExpLayerHdr)); ShadeFlag=*iPtr++; sRGBCol *RGB=(sRGBCol*)iPtr; for (int Y=0; Y256) ColorCount=256; OutRGBTable.SetSize(ColorCount,16); int RGBInc=6; if (ShadeFlag) RGBInc=-6; for (c=0;c255) R=255; if (G<0) G=0; else if (G>255) G=255; if (B<0) B=0; else if (B>255) B=255; } } } /*****************************************************************************/ int CMkLevelLayerRGB::FindClosestRGB(sRGBCol const &RGB) { int CIdx=-1; int CVal=0; for (int i=0; i<256; i++) { int ThisVal=(SortRGBList[i].RGB.R*SortRGBList[i].RGB.R)+ (SortRGBList[i].RGB.G*SortRGBList[i].RGB.G)+(SortRGBList[i].RGB.B*SortRGBList[i].RGB.B); if (CIdx==-1 || ThisVal RGBMap %i %i\n",ThisPos,ftell(File)-ThisPos); return(ThisPos); } /*****************************************************************************/ int CMkLevelLayerRGB::WriteRGBTable(FILE *File) { int ThisPos=ftell(File); int ListSize=OutRGBTable.GetWidth(); for (int c=0; c RGBTable %i %i\n",ThisPos,ftell(File)-ThisPos); return(ThisPos); }