I've written a Hexadecimal/ASCII chart, and would like to be able to show a larger version of the selected ASCII on screen. Is there a way to read the individual lines of bytes that make up a letter/symbol/number to show on screen.
1 2 3 4 5 6 7 8 9 10
|0|0|0|0|0|0|0|0| = 0
|0|1|0|0|0|0|1|0| = 66 O O ( These 'O' represent ASCII 219 )
|0|0|1|0|0|1|0|0| = 36 O O
|0|0|0|1|1|0|0|0| = 24 OO
|0|0|0|1|1|0|0|0| = 24 OO
|0|0|1|0|0|1|0|0| = 36 O O
|0|1|0|0|0|0|1|0| = 66 O O
|0|0|0|0|0|0|0|0| = 0
To make a large graphic X.
I'm using Microsoft 2012 Express, in the console. I don't feel comfortable yet programming in Windows mode.
Thanks for any help. And, if it can't be done, so be it.
Thanks for the suggestion on PDCurses, but I've never had any luck getting any of those add on libraries to work. I've tried PDCurses, STL, SFML and probably a couple others. All I get are errors. ( Even re-tried setting up PDCurses a couple more times today, downloading the latest versions, but to no avail.. ) Given up on ever using them..
#include <iostream>
usingnamespace std;
//|0|0|0|0|0|0|0|0| = 0
//|0|1|0|0|0|0|1|0| = 66 O O ( These 'O' represent ASCII 219 )
//|0|0|1|0|0|1|0|0| = 36 O O
//|0|0|0|1|1|0|0|0| = 24 OO
//|0|0|0|1|1|0|0|0| = 24 OO
//|0|0|1|0|0|1|0|0| = 36 O O
//|0|1|0|0|0|0|1|0| = 66 O O
//|0|0|0|0|0|0|0|0| = 0
int main() {
unsignedchar x_data[] = {0, 66, 36, 24, 24, 36, 66, 0};
// for each of the slices (should really use named const rather than 8)
for (int i = 0; i < 8; ++i) {
cout << i << "> ";
// mask starts with just high bit set
unsignedchar mask = 0x80;
// loop continues until bit is shifted off end of mask
while (mask) {
// bit-wise and mask with current slice of letter, display
// 'O' if bit set otherwise ' '
cout << ((mask & x_data[i]) ? 'O' : ' ');
// shift bit in mask one to right
mask >>= 1;
}
// end slice
cout << '\n';
}
return 0;
}
0>
1> O O
2> O O
3> OO
4> OO
5> O O
6> O O
7>
To handle strings, you'll need to output them in stripes using an extension of this approach.
You'll also need to either avoid or handle line wrapping.
Yes, that would work, if I go through all 255 ASCII codes, and make up the values for each of the 8 lines of bytes in each. But what I was hoping for, would be that when I select a character, a function can read what makes up that character, like the 'X' above', and outputs an enlarged version of it on screen, to make it easier for the user to see, than the one character shown now.
If you want to do this in code (bad idea), use the compiler that came with the November 2012 update (it has raw string literals). Something like this (with the Microsoft compiler the map would have to be initialized differently):
Ideally, don't do this in code; make it data driven.
Create a file with the character images (say 10 lines per character), and read it into a vector or map as part of initialization. Then, as in the above example, do a lookup to print the images. This will allow you to modify the images without having to rebuild the program, have more than one file to support different styles for the images etc.
Ooops -- I read your post a bit too simplistically.
I think the answer it that it can't be done. (That is, you cannot read the pixels of the current font.)
Or rather, it can't be done cleanly. The only way I can think to do it would be far messier than a proper GUI based solution. To start with, you'd have to draw the character offscreen and then find out what the pixels are using GetPixel or by examining the bits directly.
And the drawing the big char would be a problem. Using normal, small chars to draw the big letter would look odd as chars have a different aspect ration to pixels; drawing it directly into the console window using GDI would hit problems with screen refreshing etc. (it's not a good thing to do.)
> I've tried PDCurses, STL, SFML and probably a couple others. All I get are errors. (...)
> Given up on ever using them..
that's quite a shame, ¿have you considered changing your OS?
Either use them as they are, or modify them as you please; read the characters from the file into a vector or so, and just dump the characters on stdout.