MCPcopy Create free account
hub / github.com/MapServer/MapServer / matchdxfcolor

Function matchdxfcolor

mapimagemap.c:199–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197
198static int lastcolor=-1;
199static int matchdxfcolor(colorObj col)
200{
201 int best=7;
202 int delta=128*255;
203 int tcolor = 0;
204 if (lastcolor != -1)
205 return lastcolor;
206 while (tcolor < 256 && (ctable[tcolor].r != col.red || ctable[tcolor].g != col.green || ctable[tcolor].b != col.blue)){
207 tcolor++;
208 if (abs(
209 (ctable[tcolor].r - col.red) * (ctable[tcolor].r - col.red)+
210 (ctable[tcolor].b - col.blue) * (ctable[tcolor].b - col.blue) +
211 (ctable[tcolor].g - col.green) * (ctable[tcolor].g - col.green) < delta)
212 ){
213 best = tcolor;
214 delta = abs(
215 (ctable[tcolor].r - col.red) * (ctable[tcolor].r - col.red)+
216 (ctable[tcolor].b - col.blue) * (ctable[tcolor].b - col.blue) +
217 (ctable[tcolor].g - col.green) * (ctable[tcolor].g - col.green)
218 );
219 }
220 }
221 if (tcolor >= 256) tcolor = best;
222/* DEBUG_IF printf("%d/%d/%d (%d/%d - %d), %d : %d/%d/%d<BR>\n", ctable[tcolor].r, ctable[tcolor].g, ctable[tcolor].b, tcolor, best, delta, lastcolor, col.red, col.green, col.blue); */
223 lastcolor = tcolor;
224 return tcolor;
225}
226
227#ifdef notdef /* not currently used */
228static gdImagePtr searchImageCache(struct imageCacheObj *ic, styleObj *style, int size) {

Callers 4

msDrawMarkerSymbolIMFunction · 0.85
msDrawLineSymbolIMFunction · 0.85
msDrawShadeSymbolIMFunction · 0.85
msDrawTextIMFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected