Save an Image instance as png Magick++

1.7k views Asked by At

This is my 3rd subsequent post about Magick++ even though I spend tons of effort trying to deal with it myself.

I have this program:

int main( int argc, char ** argv)
{

  // Initialize ImageMagick install location for Windows
  InitializeMagick(*argv);

  try {

    Image button;
    Geometry size = Geometry(10,10);
    button.size(size);
    button.write("button_out.png");
  }
  catch( exception &error_ )
    {
      cout << "Caught exception: " << error_.what() << endl;
      system("Pause");
      return 1;
    }
  /*
  */
  
  return 0;
}

As you can see all I'm trying to do is to save 10x10 empty image to a png file. Unfortunately, Magick++ can't do that:

Caught exception: stripes.exe: no encode delegate for this image format `' @ err
or/constitute.c/WriteImage/1167
Pokračujte stisknutím libovolné klávesy...

That's a big disappointment. I spent six hours getting the library to work to end up with this. But I think Magick++ is capable of doing it, eventually. Therefore the question is, what have I done wrong?

Should I somewhere include/require/load some module that allows PNG saving?

1

There are 1 answers

4
zbigniewcebula On

Did you put DLL's in your binary folder? You know that PNG is compressed by zlib, right? For example: when you using SDL library and you use PNG's you need to put zlib and libpng DLL's in bin folder to allow program reading and writing PNG files.