Created
February 2, 2019 04:28
-
-
Save Sam-Belliveau/69f1ef6bd2cbe839f52107db07066853 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdint.h> | |
| int main(){uint16_t i[]={14894U,15710U,14478U,4100U,4100U,16382U,16385U,24021U, | |
| 20821U,24029U,21573U,23621U,16385U,16382U};for(int r=0;r<0xE;++r){for(int | |
| m=0x8000;m;m>>=1)if(i[r]&m)printf("##");else printf(" ");puts("");}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> // printf(), puts() | |
| #include <stdint.h> // uint16_t | |
| // Image stored in compact binary | |
| const uint16_t image[14] = | |
| { | |
| // Each row is 15 pixels wide | |
| // Using a 16 bit integer, you | |
| // can store a bitmap image | |
| 0b011101000101110, // ###### ## ## ###### | |
| 0b011110101011110, // ######## ## ## ######## | |
| 0b011100010001110, // ###### ## ###### | |
| 0b001000000000100, // ## ## | |
| 0b001000000000100, // ## ## | |
| 0b011111111111110, // ########################## | |
| 0b100000000000001, // ## ## | |
| 0b101110111010101, // ## ###### ###### ## ## ## | |
| 0b101000101010101, // ## ## ## ## ## ## ## | |
| 0b101110111011101, // ## ###### ###### ###### ## | |
| 0b101010001000101, // ## ## ## ## ## ## | |
| 0b101110001000101, // ## ###### ## ## ## | |
| 0b100000000000001, // ## ## | |
| 0b011111111111110 // ########################## | |
| }; | |
| // Take 16 bit int, and print 16 pixels from it | |
| void putLine(const uint16_t line) | |
| { | |
| // Use a bit mask to print the int bit by bit | |
| for(uint16_t mask = 0x8000; mask; mask >>= 1) | |
| { | |
| // If the mask and the line match up, its an active bit | |
| if(line & mask) { printf("##"); } | |
| else { printf(" "); } | |
| } | |
| // New line for end of each row | |
| putchar('\n'); | |
| } | |
| int main() | |
| { | |
| // Go through each line of the image | |
| for(int i = 0; i < 14; ++i) { putLine(image[i]); } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
epic