Changeset 32066f2 in mainline for uspace/app/fontedit/fontedit.c
- Timestamp:
- 2020-08-27T11:24:39Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2776ff
- Parents:
- 20d0098
- git-author:
- Jiri Svoboda <jiri@…> (2020-08-26 18:34:29)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-08-27 11:24:39)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fontedit/fontedit.c
r20d0098 r32066f2 51 51 52 52 enum { 53 glyph_scale = 8 53 glyph_scale = 8, 54 glyph_orig_x = 100, 55 glyph_orig_y = 100 54 56 }; 55 57 … … 102 104 pos_event_t *event = (pos_event_t *) data; 103 105 font_edit_t *fedit; 106 int x, y; 104 107 105 108 fedit = (font_edit_t *) widget_get_data(widget); 106 109 107 110 if (event->type == POS_PRESS) { 108 gfx_glyph_bmp_setpix(fedit->gbmp, event->hpos / glyph_scale, 109 event->vpos / glyph_scale, 1); 111 x = gfx_coord_div_rneg((int)event->hpos - glyph_orig_x, 112 glyph_scale); 113 y = gfx_coord_div_rneg((int)event->vpos - glyph_orig_y, 114 glyph_scale); 115 116 printf("x=%d y=%d\n", x, y); 117 gfx_glyph_bmp_setpix(fedit->gbmp, x, y, 1); 110 118 font_edit_paint(fedit); 111 119 } 120 } 121 122 /** Convert glyph pixel coordinates to displayed rectangle. 123 * 124 * Since we upscale the glyph a pixel in the glyph corresponds to a rectangle 125 * on the screen. 126 * 127 * @param fedit Font editor 128 * @param x X coordinate in glyph 129 * @param y Y coordinate in glyph 130 * @param drect Place to store displayed rectangle coordinates 131 */ 132 static void font_edit_gpix_to_disp(font_edit_t *fedit, int x, int y, 133 gfx_rect_t *drect) 134 { 135 (void) fedit; 136 137 drect->p0.x = glyph_orig_x + x * glyph_scale; 138 drect->p0.y = glyph_orig_y + y * glyph_scale; 139 drect->p1.x = glyph_orig_x + (x + 1) * glyph_scale; 140 drect->p1.y = glyph_orig_y + (y + 1) * glyph_scale; 112 141 } 113 142 … … 120 149 gfx_color_t *color = NULL; 121 150 gfx_rect_t rect; 151 gfx_rect_t grect; 122 152 errno_t rc; 123 int w, h;124 153 int x, y; 125 154 int pix; 126 155 127 w = 50;128 h = 50;129 130 156 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color); 131 157 if (rc != EOK) … … 136 162 goto error; 137 163 138 for (y = 0; y < h; y++) { 139 for (x = 0; x < w; x++) { 164 gfx_glyph_bmp_get_rect(fedit->gbmp, &grect); 165 printf("grect=%d,%d,%d,%d\n", grect.p0.x, grect.p0.y, 166 grect.p1.x, grect.p1.y); 167 168 for (y = grect.p0.y; y < grect.p1.y; y++) { 169 for (x = grect.p0.x; x < grect.p1.x; x++) { 140 170 pix = gfx_glyph_bmp_getpix(fedit->gbmp, x, y); 141 171 142 rect.p0.x = x * glyph_scale;143 rect.p0.y = y * glyph_scale;144 rect.p1.x = (x + 1) * glyph_scale;145 rect.p1.y = (y + 1) * glyph_scale;146 147 172 if (pix != 0) { 173 font_edit_gpix_to_disp(fedit, x, y, &rect); 174 148 175 rc = gfx_fill_rect(fedit->gc, &rect); 149 176 if (rc != EOK) … … 154 181 155 182 gfx_color_delete(color); 183 184 /* Display glyph origin */ 185 186 rc = gfx_color_new_rgb_i16(0, 0xffff, 0, &color); 187 if (rc != EOK) 188 goto error; 189 190 rc = gfx_set_color(fedit->gc, color); 191 if (rc != EOK) 192 goto error; 193 194 font_edit_gpix_to_disp(fedit, 0, 0, &rect); 195 196 rc = gfx_fill_rect(fedit->gc, &rect); 197 if (rc != EOK) 198 goto error; 199 200 gfx_color_delete(color); 201 156 202 return EOK; 157 203 error:
Note:
See TracChangeset
for help on using the changeset viewer.