| 458 | |
| 459 | template <int N> |
| 460 | void MSDFErrorCorrection::apply(BitmapSection<float, N> sdf) const { |
| 461 | sdf.reorient(stencil.yOrientation); |
| 462 | const byte *stencilRow = stencil.pixels; |
| 463 | float *rowStart = sdf.pixels; |
| 464 | for (int y = 0; y < sdf.height; ++y) { |
| 465 | const byte *mask = stencilRow; |
| 466 | float *pixel = rowStart; |
| 467 | for (int x = 0; x < sdf.width; ++x) { |
| 468 | if (*mask&ERROR) { |
| 469 | // Set all color channels to the median. |
| 470 | float m = median(pixel[0], pixel[1], pixel[2]); |
| 471 | pixel[0] = m, pixel[1] = m, pixel[2] = m; |
| 472 | } |
| 473 | ++mask; |
| 474 | pixel += N; |
| 475 | } |
| 476 | stencilRow += stencil.rowStride; |
| 477 | rowStart += sdf.rowStride; |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | BitmapConstSection<byte, 1> MSDFErrorCorrection::getStencil() const { |
| 482 | return stencil; |
no test coverage detected