Advertisement
Guest User

Untitled

a guest
May 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. void showButton(int yPlace, int xPlace){        // y = x && x = y
  2.     short int file_handle, i, j, x, y;
  3.     int color;
  4.     file_handle = alt_up_sd_card_fopen("knopje.bmp", 0);
  5.     if (file_handle >= 0) {
  6.  
  7.         // Skip header data
  8.         short int read_byte;
  9.         for(i = 0; i < 54 ; i++) {
  10.             read_byte = alt_up_sd_card_read(file_handle);
  11.         }
  12.  
  13.         // Read image
  14.         for(j = 0; j < 16; j++) {
  15.             for(i = 0; i < 16; i++) {
  16.                 read_byte = alt_up_sd_card_read(file_handle);
  17.                 x = read_byte;
  18.                 if( read_byte == -1 ) {
  19.                     printf("no bytes to read\n");
  20.                     break;
  21.                 }
  22.                 read_byte = alt_up_sd_card_read(file_handle);
  23.                 y = read_byte;
  24.                 color =  (x << 8) | y;
  25.                 //color =  x | (y << 8);
  26.                 //if (color != 0) printf("Color = %x\n", color);
  27.                 *(pixel_buffer + ((xPlace-j) << 9) + (i + yPlace)) = (unsigned int) color;
  28.             }
  29.         }
  30.     } else {
  31.         printf("Can't open button image\n");
  32.     }
  33.     alt_up_sd_card_fclose(file_handle);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement