Changeset dd65f4f7 in mainline for uspace/lib/gfxfont/src/glyph_bmp.c
- Timestamp:
- 2020-09-27T09:26:41Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d8cdaf1b
- Parents:
- efca2e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/src/glyph_bmp.c
refca2e4 rdd65f4f7 116 116 gfx_font_t *font = glyph->font; 117 117 gfx_coord_t x, y; 118 gfx_rect_t used_rect; 118 119 pixel_t pixel; 119 120 pixelmap_t pmap; 120 121 gfx_bitmap_alloc_t alloc; 121 122 errno_t rc; 123 124 /* Find actual rectangle being used */ 125 gfx_glyph_bmp_find_used_rect(bmp, &used_rect); 122 126 123 127 /* … … 126 130 * is adjusted. 127 131 */ 128 rc = gfx_font_splice_at_glyph(font, glyph, & bmp->rect);132 rc = gfx_font_splice_at_glyph(font, glyph, &used_rect); 129 133 if (rc != EOK) 130 134 return rc; … … 142 146 /* Copy pixels to font bitmap */ 143 147 144 for (y = bmp->rect.p0.y; y < bmp->rect.p1.y; y++) {145 for (x = bmp->rect.p0.x; x < bmp->rect.p1.x; x++) {148 for (y = used_rect.p0.y; y < used_rect.p1.y; y++) { 149 for (x = used_rect.p0.x; x < used_rect.p1.x; x++) { 146 150 pixel = bmp->pixels[(y - bmp->rect.p0.y) * 147 151 (bmp->rect.p1.x - bmp->rect.p0.x) + … … 176 180 } 177 181 182 /** Find minimum rectangle covering all non-background pixels. 183 * 184 * @param bmp Glyph bitmap 185 * @param rect Place to store rectangle 186 */ 187 void gfx_glyph_bmp_find_used_rect(gfx_glyph_bmp_t *bmp, gfx_rect_t *rect) 188 { 189 gfx_coord_t x, y; 190 gfx_coord2_t min; 191 gfx_coord2_t max; 192 bool anypix; 193 int pix; 194 195 min.x = bmp->rect.p1.x; 196 min.y = bmp->rect.p1.y; 197 max.x = bmp->rect.p0.x; 198 max.y = bmp->rect.p0.y; 199 200 anypix = false; 201 for (y = bmp->rect.p0.y; y < bmp->rect.p1.y; y++) { 202 for (x = bmp->rect.p0.x; x < bmp->rect.p1.x; x++) { 203 pix = gfx_glyph_bmp_getpix(bmp, x, y); 204 if (pix != 0) { 205 anypix = true; 206 if (x < min.x) 207 min.x = x; 208 if (y < min.y) 209 min.y = y; 210 if (x > max.x) 211 max.x = x; 212 if (y > max.y) 213 max.y = y; 214 } 215 } 216 } 217 218 if (anypix) { 219 rect->p0.x = min.x; 220 rect->p0.y = min.y; 221 rect->p1.x = max.x + 1; 222 rect->p1.y = max.y + 1; 223 } else { 224 rect->p0.x = 0; 225 rect->p0.y = 0; 226 rect->p1.x = 0; 227 rect->p1.y = 0; 228 } 229 } 230 178 231 /** Get pixel from glyph bitmap. 179 232 *
Note:
See TracChangeset
for help on using the changeset viewer.