|
64 | 64 | #include "debug.h" |
65 | 65 | #include "pixfmt_conv.h" |
66 | 66 | #include "ug_runtime_error.hpp" |
| 67 | +#include "utils/bitmap_font.h" // for FONT_H |
67 | 68 | #include "utils/color_out.h" |
68 | 69 | #include "utils/macros.h" |
69 | 70 | #include "utils/string_view_utils.hpp" |
@@ -164,16 +165,20 @@ class image_pattern_bars : public image_pattern { |
164 | 165 | if (init == "help"s) { |
165 | 166 | col() << "Testcard bar usage:\n\t" |
166 | 167 | << SBOLD(SRED("-t testcard:pattern=bars") |
167 | | - << "[=<text>[,big]]") |
168 | | - << " - optionally annotate with text (+ big font)" << "\n"; |
| 168 | + << "[=<text>[,XYpt]]") |
| 169 | + << " - optionally annotate with text (+ opt font size)" << "\n"; |
169 | 170 | throw 1; |
170 | 171 | } |
171 | 172 | annotate = init; |
172 | 173 |
|
173 | | - const std::string::size_type n = annotate.find(",big"); |
174 | | - if (n == annotate.size() - 4) { |
175 | | - annotate.resize(n); |
176 | | - big = true; |
| 174 | + const char *last_comma = strrchr(init.c_str(), ','); |
| 175 | + if (last_comma != nullptr) { |
| 176 | + char *endptr = nullptr; |
| 177 | + long val = strtol(last_comma + 1, &endptr, 10); |
| 178 | + if (strcmp(endptr, "pt") == 0) { |
| 179 | + annotate.resize(annotate.rfind(',')); |
| 180 | + scale = (val + FONT_H - 1) / FONT_H; |
| 181 | + } |
177 | 182 | } |
178 | 183 | } |
179 | 184 | private: |
@@ -219,12 +224,12 @@ class image_pattern_bars : public image_pattern { |
219 | 224 | if (!annotate.empty()) { |
220 | 225 | draw_line_scaled((char *) data, width * 4, |
221 | 226 | annotate.c_str(), 0xFFFFFFFF, |
222 | | - 0xFF000000, big ? 6 : 1); |
| 227 | + 0xFF000000, scale); |
223 | 228 | } |
224 | 229 | return generator_depth::bits8; |
225 | 230 | } |
226 | 231 | string annotate; |
227 | | - bool big = false; |
| 232 | + int scale = 6; |
228 | 233 | }; |
229 | 234 |
|
230 | 235 | /** |
@@ -846,7 +851,7 @@ video_pattern_generator_create(const char *config, int width, int height, codec_ |
846 | 851 | col() << "Pattern to use, one of: \n"; |
847 | 852 | for (const auto *p : |
848 | 853 | { |
849 | | - "bars[=<text>[,big]]", |
| 854 | + "bars[=<text>[,XYpt]]", |
850 | 855 | BLANK_USAGE, |
851 | 856 | "diagonal*", |
852 | 857 | "ebu_bars", |
|
0 commit comments