Tell me how to convert the byte array into a bitmap?

public: array<Byte>^ imageToByteArray(System::Drawing::Image^ imageIn) { MemoryStream^ ms = gcnew MemoryStream(); int t = 0; imageIn->Save(ms, System::Drawing::Imaging::ImageFormat::Bmp); ArrayTemp = ms->ToArray(); } 

The array has been converted so

  • It depends on how Bitmap was converted to a byte array. - Alexander Petrov
  • @AlexanderPetrov added conversion to an array - Pablo Murena
  • Is that what? Some piece of non-compiled code. Was it difficult to copy-paste correctly ? (However, there is also a typo). - Alexander Petrov

1 answer 1

 Image^ ConvertToImage(array<Byte>^ bytes) { MemoryStream^ stream = gcnew MemoryStream(bytes); Image^ image = Image::FromStream(stream); return image; } 

Truth be told, exception handling and proper resource cleanup are also needed (as in your code for converting an image into an array of bytes). In C # this is done easily and pleasantly, but masochists choose C ++ / CLI. How to do it right? For example, look here .