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

Author Topic: sf::Image SaveToFile doesn't work in sfml2  (Read 2946 times)

0 Members and 1 Guest are viewing this topic.

Xorlium

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
sf::Image SaveToFile doesn't work in sfml2
« on: October 17, 2010, 10:04:31 pm »
Hi,

I'm using latest svn, freshly svn-updated and compiled.

Here is minimal code that doesn't work:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::Image myImage;
    myImage.Create(100,100,sf::Color::Blue);

    myImage.SaveToFile("myfile.png");

    return EXIT_SUCCESS;
}


This gives "Segmentation Fault".

I'm using Kubuntu linux, 10.04, x86_64.

I think it used to work in sfml 1.6 :)

Xorlium

Edit: Oh, and saving to .bmp or .jpg DOES work.

nulloid

  • Full Member
  • ***
  • Posts: 134
    • View Profile
sf::Image SaveToFile doesn't work in sfml2
« Reply #1 on: October 17, 2010, 10:11:49 pm »
I can confirm that, it segfaults when writing image to a file (Xubuntu 10.10, sfml2, x86)
Here's a stack list:
Code: [Select]
#0 0x1477b7    stbi_zlib_compress(unsigned char*, int, int*, int) () (/usr/local/lib/libsfml2-graphics.so:??)
#1 0x149823    stbi_write_png_to_mem(unsigned char*, int, int, int, int, int*) () (/usr/local/lib/libsfml2-graphics.so:??)
#2 0x149ab8    stbi_write_png() (/usr/local/lib/libsfml2-graphics.so:??)
#3 0x14c540    sf::priv::ImageLoader::SaveImageToFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, unsigned int, unsigned int) () (/usr/local/lib/libsfml2-graphics.so:??)
#4 0x141284    sf::Image::SaveToFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const() (/usr/local/lib/libsfml2-graphics.so:??)
#5 0x80488bb    main() (/home/nulloid/prg/bug/main.cpp:8)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Image SaveToFile doesn't work in sfml2
« Reply #2 on: October 17, 2010, 10:57:10 pm »
Make sure that you don't have old 1.6 libraries still installed (SFML 2 is installed to a different directory by default).

This code works for me on Windows. I can't try on Linux right now, I'll do it as soon as possible.
Laurent Gomila - SFML developer

Xorlium

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
sf::Image SaveToFile doesn't work in sfml2
« Reply #3 on: October 17, 2010, 11:40:07 pm »
Hi Laurent,

Yes, I don't have 1.6 installed, and besides, the names are different and I'm using sfml2-graphics, sfml2-system and sfml2-window, so no chance of confusion there.

Xorlium

 

anything