Render a white-colored bitmap encoded in a string
| 3447 | |
| 3448 | // Render a white-colored bitmap encoded in a string |
| 3449 | void ImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char) |
| 3450 | { |
| 3451 | ImTextureData* tex = atlas->TexData; |
| 3452 | IM_ASSERT(x >= 0 && x + w <= tex->Width); |
| 3453 | IM_ASSERT(y >= 0 && y + h <= tex->Height); |
| 3454 | |
| 3455 | switch (tex->Format) |
| 3456 | { |
| 3457 | case ImTextureFormat_Alpha8: |
| 3458 | { |
| 3459 | ImU8* out_p = (ImU8*)tex->GetPixelsAt(x, y); |
| 3460 | for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w) |
| 3461 | for (int off_x = 0; off_x < w; off_x++) |
| 3462 | out_p[off_x] = (in_str[off_x] == in_marker_char) ? 0xFF : 0x00; |
| 3463 | break; |
| 3464 | } |
| 3465 | case ImTextureFormat_RGBA32: |
| 3466 | { |
| 3467 | ImU32* out_p = (ImU32*)tex->GetPixelsAt(x, y); |
| 3468 | for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w) |
| 3469 | for (int off_x = 0; off_x < w; off_x++) |
| 3470 | out_p[off_x] = (in_str[off_x] == in_marker_char) ? IM_COL32_WHITE : IM_COL32_BLACK_TRANS; |
| 3471 | break; |
| 3472 | } |
| 3473 | } |
| 3474 | } |
| 3475 | |
| 3476 | static void ImFontAtlasBuildUpdateBasicTexData(ImFontAtlas* atlas) |
| 3477 | { |
no test coverage detected