How to save Texture2D to BMP?

Hello, Developers!

I’m doing project with capturing from webcam and printing image that captured by webcam.

Since there is no way to connect directly to printer and to print in Unity/C#, I divided this project to Unity/C# and C++.

So, I take Unity/C# part that is to capture image and save it in computer, my partner takes C++ part which is to open the saved image, and to print that image.

When we merged our works, I thought that is completely worked, but there is some problem.
That is saving BMP.

In Unity, (as I know) there is no way to save image to BMP format.

Yes, there is to PNG, JPG. But C++ code is based in BMP. So, I converted it as below.

		...
		Texture2D snap = new Texture2D(tex.width, tex.height,TextureFormat.RGB565, false);

		System.IO.File.WriteAllBytes(_SavePath + "Image" + ".png", snap.EncodeToPNG());

		byte[] saveBmp = snap.EncodeToPNG();
		System.IO.File.WriteAllBytes (_SavePath + "Image" + ".bmp", saveBmp); // the problem is here
		...

Since Bitmap is composed of byte arrays, I thought it was right.
But the C++ codes doesn’t recognized that image as BMP.
Of cource, it saved as .bmp, but it looks its REAL CONTENT isn’t BMP but PNG format. So our project stoped here.

Is there a way to save Texture2D to BMP?

Thanks for reading this!

No, Unity cannot create BMP files. If you need this, you will have to write code that can convert the PNG into a BMP.