You cannot create a raster image class directly with raw data that does not have a raster image header. The bitmap header is similar to a bitmap recipe. It includes important information about width, height, bits per pixels, data length, etc., to create the right array for the image.
Creating a bitmap header is pretty simple if you look closely at the bitmap header structure here
But nothing is better than a complete source code example.
I broke them into several parts and commented on each step for you throughout the process. It probably looks a bit overkill, but it will be a good guide for you, I think.
The following is an example of a 2 × 2-pixel 24-bit bitmap (Windows DIB header BITMAPINFOHEADER) with the pixel format RGB24.
BMP file format - Wikipedia
#region Bitmap Making...
source share