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

Author Topic: Image stream  (Read 3949 times)

0 Members and 1 Guest are viewing this topic.

Darwin226

  • Newbie
  • *
  • Posts: 3
    • View Profile
Image stream
« on: April 27, 2010, 11:29:07 pm »
The Image constructor accepts Stream as one of the overloads.
I have an embedded image (a png file) and I'm loading it into a stream with Assembly.GetManifestResourceStream("name");

Then I make an image from that stream but it throws an error.
Object reference not set to an instance of an object.

If I use a .bmp image then it works fine.
Is there any way to load a png image?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Image stream
« Reply #1 on: April 28, 2010, 12:56:21 pm »
Quote
Object reference not set to an instance of an object.

Where does this happen? For which variable? Are you sure that the returned stream for your png image is a valid one (ie. no error happened)?
Laurent Gomila - SFML developer

Darwin226

  • Newbie
  • *
  • Posts: 3
    • View Profile
Image stream
« Reply #2 on: April 28, 2010, 03:59:16 pm »
The error is on this line

         Image img = new Image(stream);

The problem might be that Stream stream = a.GetManifestResourceStream("name.png");
doesn't know how to convert a png to a stream.
Keep in mind I don't know what I'm talking about, just guessing.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Image stream
« Reply #3 on: April 28, 2010, 09:18:41 pm »
Quote
Keep in mind I don't know what I'm talking about, just guessing.

Same for me, never used streams in C# :lol:

But I think that this error means that you have an uninitialized object.
Laurent Gomila - SFML developer