namespace ConsoleApplication1{
class Program{
static void Main(string[] args){
var file = File.Open(@"D:\myfile.exe", FileMode.Open);
var byteLen = file.Length;
int size = (int)Math.Floor(Math.Sqrt(byteLen / 4));
Bitmap bm = new Bitmap(size,size);
for (int y = 0; y < size ; y++){
for (int x= 0; x < size ; x++){
byte[] rgba = new byte[]{ 0xFF,0xFF,0xFF, 0xFF};
short cnt = 0;
while (cnt < 4 && file.CanRead){
byte[] buff= new byte[1];
file.Read(buff,0,1);
rgba[cnt++] = buff[0];
}
bm.SetPixel(x, y, Color.FromArgb(rgba[0], rgba[1], rgba[2], rgba[3]));
}
}
file.Close();
var saveFile = File.Open(@"D:\myimg.png", FileMode.Create);
bm.Save(saveFile,ImageFormat.Png);
saveFile.Close();
}
}
}