Helper functions replace_color, simply replaces one color in the surface with another */
| 401 | replace_color, simply replaces one color in the surface with another |
| 402 | */ |
| 403 | void grSurface::replace_color(ddgr_color sc, ddgr_color dc) { |
| 404 | int rowsize; |
| 405 | ASSERT(m_SurfInit); |
| 406 | |
| 407 | grSurface::lock(&rowsize); |
| 408 | |
| 409 | switch (ddsfObj.bpp) { |
| 410 | case BPP_16: { |
| 411 | uint16_t *data = (uint16_t *)m_DataPtr; |
| 412 | int rowsize_w = m_DataRowsize / 2; |
| 413 | uint16_t scc = XLAT_RGB_TO_16(sc), dcc = XLAT_RGB_TO_16(dc); |
| 414 | |
| 415 | for (int y = 0; y < ddsfObj.h; y++) { |
| 416 | for (int x = 0; x < ddsfObj.w; x++) |
| 417 | if (data[x] == scc) |
| 418 | data[x] = dcc; |
| 419 | |
| 420 | data += rowsize_w; |
| 421 | } |
| 422 | break; |
| 423 | } |
| 424 | |
| 425 | case BPP_32: |
| 426 | default: |
| 427 | Int3(); |
| 428 | } |
| 429 | |
| 430 | grSurface::unlock(); |
| 431 | } |
| 432 | |
| 433 | // --------------------------------------------------------------------------- |
| 434 | // lock and unlock functions |
no test coverage detected