| 197 | |
| 198 | static int lastcolor=-1; |
| 199 | static 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 */ |
| 228 | static gdImagePtr searchImageCache(struct imageCacheObj *ic, styleObj *style, int size) { |
no outgoing calls
no test coverage detected