SFML community forums
Bindings - other languages => DotNet => Topic started by: rpgmaker on January 24, 2009, 05:29:14 am
-
When i try to retrieve the pixels for an Image, it always returns the wrong data (byte[]) which cannot be used to recreate the original image. it returns a byte array always contain data with repetition of 255s and 0s like this: 255, 255, 255, 0, 255, 255, 255.
Thanks for the help
-
bump
-
Yeah yeah, I saw your post.
I'll keep you informed as soon as I can work on it.
-
The OpenGL sample uses Image.Pixels to create an OpenGL texture, and it works fine for me. Does it work for you?
-
I tried the opengl sample and it works. But i am kinda of confused why it works because any time i try to use the image#pixels to create a .net image/bitmap it fails all the time.
-
Are you sure the problem is in Image.Pixels?
You should try to reduce your code to the minimum which reproduces the bug, and see what happens (or paste it here if you still don't know).
-
I did the following:
Image img = new Image.new("file.png");
byte[] data = img.Pixels;
Stream s = new MemoryStream(data);
System.Drawing.Image dotNetImage = System.Drawing.Image.FromStream(s);// It crashes stating paramater is not valid
img.Dispose();
s.Close();
-
Well, there are too many things that can fail in this piece of code. Try to remove them one by one.
For example, I would first use an hard-coded byte array instead of the pixels from the image.
-
After much research i figure out why it does not work. The reason was because the Image.FromStream method require a stream that contain (png, jpg, bmp file stream). My byte array did not work because it does not contain the necessary headers to be recognize as a valid image data. Thanks for the help.