lib/unigraphic/GraphicsDisplay.cpp

changeset 45
2da50a3d4e9f
parent 26
86f099bda525
child 58
c1dfd75f2842
equal deleted inserted replaced
44:b3c3d54d2c7c 45:2da50a3d4e9f
265 character(char_x, char_y, value); 265 character(char_x, char_y, value);
266 if(auto_up) copy_to_lcd(); 266 if(auto_up) copy_to_lcd();
267 } 267 }
268 return value; 268 return value;
269 } 269 }
270
271 void GraphicsDisplay::character(int c)
272 {
273 character(char_x, char_y, c);
274 }
275
270 void GraphicsDisplay::character(int x, int y, int c) 276 void GraphicsDisplay::character(int x, int y, int c)
271 { 277 {
272 char_x=x; 278 char_x=x;
273 char_y=y; 279 char_y=y;
274 int j,i,b; 280 int j,i,b;
275 unsigned char* zeichen; 281 unsigned char* zeichen;
276 unsigned char z,w,v; 282 unsigned char z,w,v, wtot;
277 283
278 /* // read font parameter from start of array 284 /* // read font parameter from start of array
279 offset = font[0]; // bytes / char 285 offset = font[0]; // bytes / char
280 hor = font[1]; // get hor size of font 286 hor = font[1]; // get hor size of font
281 vert = font[2]; // get vert size of font 287 vert = font[2]; // get vert size of font
286 char_y = char_y + fontvert*fontzoomver; 292 char_y = char_y + fontvert*fontzoomver;
287 if (char_y > oriented_height - fontvert*fontzoomver) { 293 if (char_y > oriented_height - fontvert*fontzoomver) {
288 char_y = 0; 294 char_y = 0;
289 } 295 }
290 } 296 }
291 window(char_x, char_y, fonthor*fontzoomhor, fontvert*fontzoomver); // char box
292 if ((c < firstch) || (c > lastch)) { // test char range - if not exist fill with blank 297 if ((c < firstch) || (c > lastch)) { // test char range - if not exist fill with blank
298 window(char_x, char_y, fonthor*fontzoomhor, fontvert*fontzoomver); // char box
293 window_pushpixel(_background, fontzoomhor*fonthor*fontvert*fontzoomver); //(color, howmany) 299 window_pushpixel(_background, fontzoomhor*fonthor*fontvert*fontzoomver); //(color, howmany)
294 w = fonthor; 300 w = fonthor;
295 } else { 301 } else {
296 zeichen = &font[((c-firstch) * fontoffset) + 4]; // start of char bitmap 302 zeichen = &font[((c-firstch) * fontoffset) + 4]; // start of char bitmap
297 w = zeichen[0]; // width of actual char 303 w = zeichen[0]; // width of actual char
304 if((fontprop) && (w<fonthor))
305 // put at least 1 blank after variable-width characters, except
306 // characters that occupy whole fonthor space like "_"
307 wtot = (w*fontzoomhor) + 1;
308 else
309 wtot = fonthor*fontzoomhor;
310 window(char_x, char_y, wtot, fontvert*fontzoomver); // char box
311
298 // construct the char into the buffer 312 // construct the char into the buffer
299 for (j=0; j<(fontbpl); j++) { // vert bytes 313 for (j=0; j<(fontbpl); j++) { // vert bytes
300 for (v=0; v<fontzoomver; v++) { // repeat horiz line for vertical zooming 314 for (v=0; v<fontzoomver; v++) { // repeat horiz line for vertical zooming
301 for (int p=0; p<8; p++) { // pixel in the current vert byte 315 for (int p=0; p<8; p++) { // pixel in the current vert byte
302 if ((j*8+p) > fontvert) 316 if ((j*8+p) > fontvert)
303 break; 317 break;
304 b = 1 << p; 318 b = 1 << p;
305 for (i=0; i<fonthor; i++) { // horz line 319 for (i=0; i<wtot; i++) { // horz line
306 z = zeichen[(fontbpl * i) + j + 1]; 320 z = zeichen[(fontbpl * i) + j + 1];
307 window_pushpixel(( z & b ) ? _foreground : _background, fontzoomhor); //(color, howmany) 321 window_pushpixel(( z & b ) ? _foreground : _background, fontzoomhor); //(color, howmany)
308 } 322 }
309 } 323 }
310 } //for each zoomed vert 324 } //for each zoomed vert
311 } 325 }
312 } 326 }
327 char_x += wtot;
328 }
329
330 uint8_t GraphicsDisplay::char_width(char c, bool move_location)
331 {
332 unsigned char* zeichen;
333 uint8_t w;
334
335 zeichen = &font[((c-firstch) * fontoffset) + 4]; // start of char bitmap
336 w = zeichen[0]; // width of actual char
337
313 if((fontprop) && (w<fonthor)) 338 if((fontprop) && (w<fonthor))
314 // put at least 1 blank after variable-width characters, except 339 w = (w*fontzoomhor) + 1;
315 // characters that occupy whole fonthor space like "_"
316 char_x += (w*fontzoomhor) + 1;
317 else 340 else
318 char_x += fonthor*fontzoomhor; 341 w = fonthor*fontzoomhor;
342 if (move_location)
343 char_x += w;
344 return w;
319 } 345 }
320 346
321 void GraphicsDisplay::Bitmap_BW(Bitmap_s bm, int x, int y) 347 void GraphicsDisplay::Bitmap_BW(Bitmap_s bm, int x, int y)
322 { 348 {
323 int h,v,b; 349 int h,v,b;

mercurial