I cant seem to get this to work. I have a program in C++ that returns to my C# app through a DLL a char* (byte) on the C# side. The image data is stored as RGBA, I am trying to turn this into a bitmap, however when trying to create it from a stream i get an exception of:
Parameter is not valid.
I also tried:
Which sort of works however all the image colors are now way off, and I know this is due to the PixelFormat, is there no way to do this without swapping pixels in the data?Code:Bitmap bmp = new Bitmap(width,height); BitmapData bmpData = bmp.LockBits(new Rectangle(0,0,width,height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); Marshal.Copy(imgData, 0, bmpData.Scan0, imgData.Length); bmp.UnlockBits(bmpData);
Well I tried swapping all the bytes from RGBA to ARGB and that just made it look even worse.