Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Image#Pixels Property does not work  (Read 6854 times)

0 Members and 1 Guest are viewing this topic.

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Image#Pixels Property does not work
« 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

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Image#Pixels Property does not work
« Reply #1 on: January 25, 2009, 03:18:27 am »
bump

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image#Pixels Property does not work
« Reply #2 on: January 25, 2009, 01:00:16 pm »
Yeah yeah, I saw your post.

I'll keep you informed as soon as I can work on it.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image#Pixels Property does not work
« Reply #3 on: January 25, 2009, 03:16:04 pm »
The OpenGL sample uses Image.Pixels to create an OpenGL texture, and it works fine for me. Does it work for you?
Laurent Gomila - SFML developer

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Image#Pixels Property does not work
« Reply #4 on: January 25, 2009, 08:26:50 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image#Pixels Property does not work
« Reply #5 on: January 25, 2009, 08:32:13 pm »
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).
Laurent Gomila - SFML developer

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Image#Pixels Property does not work
« Reply #6 on: January 25, 2009, 08:57:35 pm »
I did the following:

Code: [Select]
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();

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image#Pixels Property does not work
« Reply #7 on: January 25, 2009, 10:43:35 pm »
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.
Laurent Gomila - SFML developer

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Image#Pixels Property does not work
« Reply #8 on: January 26, 2009, 12:16:13 am »
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.

 

anything