How to convert a byte array of 19200 bytes in size where each byte represents 4 pixels (2 bits per p

Posted by Klinger on Stack Overflow See other posts from Stack Overflow or by Klinger
Published on 2010-06-03T19:42:33Z Indexed on 2010/06/03 20:04 UTC
Read the original article Hit count: 194

Filed under:
|
|

I am communicating with an instrument (remote controlling it) and
one of the things I need to do is to draw the instrument screen.

In order to get the screen I issue a command and the instrument
replies with an array of bytes that represents the screen.

Below is what the instrument manual has to say about converting the response to the actual screen:

The command retrieves the framebuffer data used for the display.
It is 19200 bytes in size, 2-bits per pixel, 4 pixels per byte arranged as
320x240 characteres.
The data is sent in RLE encoded form.
To convert this data into a BMP for use in Windows, it needs to be
turned into a 4BPP. Also note that BMP files are upside down relative
to this data, i.e. the top display line is the last line in the BMP.

I managed to unpack the data, but now I am stuck on how to actually
go from the unpacked byte array to a bitmap.

My background on this is pretty close to zero and my searches
have not revealed much either.

I am looking for directions and/or articles I could use to help me
undestand how to get this done.

Any code or even pseudo code would also help. :-)

So, just to summarize it all:

How to convert a byte array of 19200 bytes in size, where
each byte represents 4 pixels (2 bits per pixel),
to a bitmap arranged as 320x240 characters.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about bitmap