![]() |
| | #1 |
| Registered User Join Date: Nov 2001
Posts: 626
| Creating Bitmap from byte[] Parameter is not valid. I also tried: 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); [Edit] Well I tried swapping all the bytes from RGBA to ARGB and that just made it look even worse.
__________________ "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein Last edited by xds4lx; 01-11-2010 at 05:34 PM. |
| xds4lx is offline | |
| | #2 |
| Registered User Join Date: Mar 2009 Location: england
Posts: 117
| I know you've said stream doesn't work, but maybe try this anyway? It works for me... Code: public static Bitmap bytes2bmp(byte[] data)
{
return new Bitmap(new System.IO.MemoryStream(data));
}
|
| theoobe is offline | |
| | #3 |
| Registered User Join Date: Nov 2001
Posts: 626
| That is basically what I tried, from what I understand you can only create the file from the stream if the stream has the bitmap header information in it.
__________________ "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein |
| xds4lx is offline | |
| | #4 |
| Registered User Join Date: Nov 2001
Posts: 626
| Well I solved the problem. Even though the image was in RGBA format it was being displayed wrong, I swapped the R and B ad now the image shows up correctly, using the LockBits and UnlockBits method.
__________________ "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein |
| xds4lx is offline | |
| | #5 | |
| Registered User Join Date: May 2003
Posts: 1,219
| Quote:
Now, on a big-endian machine this would be the same as the order of the bytes within the 32-bit integer, but on a little-endian machine, blue is stored and read first (at the lowest byte address), then green, red, alpha. So if you're writing bytewise, you need to write B G R A in order to read it as 32bppARGB.
__________________ You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards. | |
| Cat is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating ICON form BITMAP files | Uwar | Windows Programming | 0 | 12-21-2009 05:32 AM |
| Profiler Valgrind | afflictedd2 | C++ Programming | 4 | 07-18-2008 09:38 AM |
| OpenGL -- Bitmaps | HQSneaker | Game Programming | 14 | 09-06-2004 04:04 PM |
| Copying Bitmap Resources without Creating HDC's | bartybasher | Windows Programming | 1 | 08-02-2004 06:35 AM |
| Help creating a Bitmap | Kristian25 | Windows Programming | 1 | 02-25-2003 05:17 AM |