89 {
92
93 if (oversampleX <= 1 && oversampleY <= 1) {
94
99 );
100
102 size_t size =
static_cast<size_t>(
result.width) *
static_cast<size_t>(
result.height);
104 for (size_t i = 0; i < size; ++i) {
105 result.data[i] = bitmap[i];
106 }
108 }
109 } else {
110
113 scale *
static_cast<float>(oversampleX),
114 scale *
static_cast<float>(oversampleY),
115 0.0f, 0.0f,
116 codepoint,
119 );
120
122
123 i32 finalWidth = (
result.width + oversampleX - 1) / oversampleX;
124 i32 finalHeight = (
result.height + oversampleY - 1) / oversampleY;
125
127 static_cast<size_t>(finalWidth) * static_cast<size_t>(finalHeight)
128 );
129
130 for (i32
y = 0;
y < finalHeight; ++
y) {
131 for (i32
x = 0;
x < finalWidth; ++
x) {
132 i32 sum = 0;
133 i32 count = 0;
134
135 for (i32 oy = 0; oy < oversampleY; ++oy) {
136 i32 srcY =
y * oversampleY + oy;
137 if (srcY >=
result.height)
break;
138
139 for (i32 ox = 0; ox < oversampleX; ++ox) {
140 i32 srcX =
x * oversampleX + ox;
141 if (srcX >=
result.width)
break;
142
143 sum += bitmap[srcY *
result.width + srcX];
144 ++count;
145 }
146 }
147
148 result.data[
y * finalWidth +
x] =
static_cast<u8>(
149 count > 0 ? sum / count : 0
150 );
151 }
152 }
153
154 result.width = finalWidth;
155 result.height = finalHeight;
158
160 }
161 }
162
164 }
fl::UISlider scale("Scale", 4,.1, 4,.1)
third_party::truetype::stbtt_fontinfo mFontInfo
unsigned char * stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int32_t codepoint, int32_t *width, int32_t *height, int32_t *xoff, int32_t *yoff) FL_NOEXCEPT
void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) FL_NOEXCEPT
unsigned char * stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int32_t codepoint, int32_t *width, int32_t *height, int32_t *xoff, int32_t *yoff) FL_NOEXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)