Decoding stream containing hex-values received on Serial port.

Maybe you are making this more complicated than it needs to be.

Think of each printing ASCII character as representing 4 bits or pixels.

So storing an array of 32 characters would give you the data needed to print one line of 128 pixels (where the pixel is either on or off no colour).

So to print a line you just process the character array one character at a time and output the pixels to the printer;

‘0’ prints 0000

‘1’ prints 0001

‘2’ prints 0010

‘3’ prints 0011

‘4’ prints 0100

‘5’ prints 0101

‘6’ prints 0110

‘7’ prints 0111

‘8’ prints 1000

‘9’ prints 1001

‘A’ prints 1010

‘B’ prints 1011

‘C’ prints 1100

‘D’ prints 1101

‘E’ prints 1110

‘F’ prints 1111

You are using pecial characters to denote the beginning and end of the file.

Personally I would also include end of line characters after every 32 hex characters sent.

That will make looking at what is being sent and debugging your code much easier.