lib/unigraphic/GraphicsDisplay.cpp

changeset 66
48f29a1d43d6
parent 58
c1dfd75f2842
equal deleted inserted replaced
65:d9c5eaf85fab 66:48f29a1d43d6
275 275
276 void GraphicsDisplay::character(int x, int y, int c) 276 void GraphicsDisplay::character(int x, int y, int c)
277 { 277 {
278 char_x=x; 278 char_x=x;
279 char_y=y; 279 char_y=y;
280 int j,i,b; 280 unsigned int j, i, b;
281 unsigned char* zeichen; 281 unsigned char* zeichen;
282 unsigned char z,w,v, wtot; 282 unsigned char z, w, v, wtot;
283 283
284 /* // read font parameter from start of array 284 /* // read font parameter from start of array
285 offset = font[0]; // bytes / char 285 offset = font[0]; // bytes / char
286 hor = font[1]; // get hor size of font 286 hor = font[1]; // get hor size of font
287 vert = font[2]; // get vert size of font 287 vert = font[2]; // get vert size of font
299 if (char_x + fonthor*fontzoomhor > oriented_width) { 299 if (char_x + fonthor*fontzoomhor > oriented_width) {
300 // a bit brutal, but meh 300 // a bit brutal, but meh
301 // so if the char to write crosses the width, do not display it 301 // so if the char to write crosses the width, do not display it
302 return; 302 return;
303 } 303 }
304 wtot = 0;
305
304 if ((c < firstch) || (c > lastch)) { // test char range - if not exist fill with blank 306 if ((c < firstch) || (c > lastch)) { // test char range - if not exist fill with blank
305 window(char_x, char_y, fonthor*fontzoomhor, fontvert*fontzoomver); // char box 307 window(char_x, char_y, fonthor*fontzoomhor, fontvert*fontzoomver); // char box
306 window_pushpixel(_background, fontzoomhor*fonthor*fontvert*fontzoomver); //(color, howmany) 308 window_pushpixel(_background, fontzoomhor*fonthor*fontvert*fontzoomver); //(color, howmany)
307 w = fonthor; 309 w = fonthor;
308 } else { 310 } else {
351 return w; 353 return w;
352 } 354 }
353 355
354 void GraphicsDisplay::Bitmap_BW(Bitmap_s bm, int x, int y) 356 void GraphicsDisplay::Bitmap_BW(Bitmap_s bm, int x, int y)
355 { 357 {
356 int h,v,b; 358 unsigned int h,v,b;
357 // int cropX; 359 // int cropX;
358 char d; 360 char d;
359 if(x<0) x=0; 361 if(x<0) x=0;
360 if(y<0) y=0; 362 if(y<0) y=0;
361 int cropX = (x+bm.xSize)-oriented_width; 363 int cropX = (x+bm.xSize)-oriented_width;
374 } 376 }
375 } 377 }
376 } 378 }
377 if(auto_up) copy_to_lcd(); 379 if(auto_up) copy_to_lcd();
378 } 380 }
379 void GraphicsDisplay::Bitmap(int x, int y, int w, int h,unsigned char *bitmap) 381 void GraphicsDisplay::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap)
380 { 382 {
381 int j; 383 int j;
382 unsigned char padd; 384 unsigned char padd;
383 unsigned short *bitmap_ptr = (unsigned short *)bitmap; 385 unsigned short *bitmap_ptr = (unsigned short *)bitmap;
384 386
385 padd = w%2; // the lines are padded to multiple of 4 bytes in a bitmap 387 padd = w%2; // the lines are padded to multiple of 4 bytes in a bitmap
386 if(x<0) x=0; 388 if(x >= oriented_width) return;
387 else if(x>=oriented_width) return; 389 if(y >= oriented_height) return;
388 if(y<0) y=0;
389 else if(y>=oriented_height) return;
390 int cropX = (x+w)-oriented_width; 390 int cropX = (x+w)-oriented_width;
391 if(cropX<0) cropX=0; 391 if(cropX<0) cropX=0;
392 int cropY = (y+h)-oriented_height; 392 int cropY = (y+h)-oriented_height;
393 if(cropY<0) cropY=0; 393 if(cropY<0) cropY=0;
394 window(x, y, w-cropX, h-cropY); 394 window(x, y, w-cropX, h-cropY);

mercurial