Advertisement
Guest User

Glyph Printing

a guest
Dec 8th, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include "dbg.h"
  7.  
  8. #include "Bitmap.h"
  9.  
  10. int main(int argc, char* argv[])
  11. {
  12.   Bitmap img;
  13.   img.loadBMP("24bit.bmp");
  14.  
  15.   uint8_t imgWidth = img.width;
  16.   uint8_t imgHeight = img.height;
  17.   uint8_t imgBPP = img.bpp / 8;
  18.  
  19.   uint16_t Scanline = imgWidth * imgBPP; // 128 * 3bpp = one horiz line
  20.   uint8_t i, j, k;
  21.  
  22.   // ASCII 48 = '0'
  23.   uint8_t X = 64;
  24.   uint8_t Y = 0;
  25.   uint8_t Width = 7;
  26.   uint8_t Height = 15;
  27.   char tmpChar[Width][Height][imgBPP];
  28.  
  29.   // Load the above glyph into memory
  30.   for(j = 0; j < Height; ++j) {
  31.     for(i = 0; i < Width; ++i) {
  32.       for(k = 0; k < imgBPP; ++k) {
  33.         tmpChar[i][j][k] = img.data[ ((Scanline*Y)+(Scanline+j)) + // Y Offset + Y Count
  34.                                      ((imgBPP*X)+(imgBPP*i)) +     // X Off + X Count
  35.                                      k];                           // Current ColorBit
  36.       }
  37.     }
  38.   }
  39.  
  40.   // Print out the glyph in memory in a nice grid
  41.   for(j = 0; j < Height; ++j) {
  42.     printf("\n");
  43.     for(i = 0; i < Width; ++i) {
  44.       for(k = 0; k < imgBPP; ++k) {
  45.         printf("%+d ", tmpChar[i][j][k]);
  46.       }
  47.     }
  48.   }
  49.  
  50.   return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement