Display raw data from image file using TextBox or RichTextBox?

My program reads a DDS image file and saves it as an array of bytes. I want to show users the source data in the TextBox form, so first I convert the byte array to a string using the following code:

string data = System.Text.Encoding.ASCII.GetString(bytes);

Then I set the TextBox text:

textBox.Text = data;

The problem I encountered is a text box that does not display all the data. Here is a screenshot of what it looks like:

Textbox view

As you can see, only the first few characters are displayed. I assume this is because the line contains a null delimiter, which the TextBox interprets as the end of the line. Here's a copy of the first 50 or so characters in the line that I copied directly from the debugger viewport:

DDS | \ 0 \ 0 \ 0 \ a \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \

, "DDS |" , TextBox.

, , , , DDS , Notepadd ++.

DDS Notepad ++ :

Notepad ++ view

: TextBox ( RichTextBox) , Notepad ++?

+2
1

- :

textbox.Text = data.Replace("\0", @"\0");

, , null. , .

+1

Source: https://habr.com/ru/post/1544947/


All Articles