#include #include #include #include #include "piwdgx.h" #include "picmapx.h" /* --Methode-- */ PIColorMapX::PIColorMapX() : PIColorMapGen() { mColors = NULL; mColRGB = NULL; mNewCol = NULL; } /* --Methode-- */ PIColorMapX::PIColorMapX(int id, int nc, string const& nom) : PIColorMapGen(id, nc, nom) { int n = nc; mColors = new PIXColor[n]; mColRGB = new PIColor[n]; mNewCol = new bool[n]; int i; for(i=0; i= NCol())) { PIColor picr; picr.red = picr.green = picr.blue = 0; return(picr); } return(mColRGB[n]); } static Colormap defxcmap; static int xinicmap = 0; static int NTotColors = 0; static int NTotAllocCol = 0; static int nerrallocol = 0; /* --Methode-- */ bool PIColorMapX::AllocColor(PIColor const& col, int index) { XColor myxcol; if (!xinicmap) { defxcmap = XDefaultColormap (PIXDisplay(), PIXScreen()); xinicmap = 1; } if ( (index < 0) || (index >= mNCol) ) return(false); if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) ) { mColors[index] = BlackPixel(PIXDisplay(), PIXScreen()); mColRGB[index] = col; mNewCol[index] = false; return(true); } // Pour diminuer les requetes X, on verifie si la couleur // ne se trouve pas deja dans la table Reza 19/05/98 int kc; for(kc=0; kc 0) return(NTotColors); // Visual* vis; // DefaultVisual(PIXDisplay(), PIXScreen() ); int k,kk; // On calcule le nombre de couleurs a partir du nb de plans image kk = DefaultDepth(PIXDisplay(), PIXScreen() ); NTotColors = 1; for(k=0; kmColors[i]; mColRGB[i] = ((PIColorMapX *)x)->mColRGB[i]; // C'est la table de couleur originale qui est responsable de liberer les couleurs - Reza 8/2/98 mNewCol[i] = false; } }