I'm looking for a 2D image manipulation library for C++, ideally something modern which uses C++20.


  • works on Windows 10 (support for Windows filenames, mainly)
  • works with Visual Studio 2022 (no makefiles please)
  • simple to include (maybe header only; ideally just a few files), like GLFW if you know that
  • produces no or few warnings only, when being comiled
  • I only need basic operations like
    • get pixel / set pixel
    • draw line, ellipse and rectangle
  • support for PNG files (JPG and BMP welcome), reading and writing
  • gratis


  • displaying images on screen

I have tried:

  • Magick++
    • the site says it's up to Windows 7
    • the download location is unclear

      'win2k' subdirectory of the ImageMagick ftp site (and mirrors)

    • Visual Studio version is outdated

      ready-made Visual C++ 8.0 build environment

  • Leptonica
    • looks very C-ish, not C++-ish
  • Hi Thomas. I haven't tried Magick++ on Win10, but I've heard it will work as expected. Nov 24, 2022 at 8:17
  • @RockPaperLz-MaskitorCasket thanks for the suggestion. I hope I get another task that requires a graphics library so that I can test it as well. For now I implemented it with SFML (see answer below) and I liked it. Dec 5, 2022 at 12:36

1 Answer 1


I found SFML to suit my needs.

I really like the method names. They are straight forward, IMHO. Not cryptic or abbreviated.

For the requirements:

  • works on Windows 10

  • works with Visual Studio 2022.

    The download site mentions Visual Studio 2017 as the latest versions, but when I opened an issue on Github, the answer was that the VS2017 version is compatible with VS2019 and VS2022.

  • simple to include.

    The Tutorial for Visual Studio tells you what you need to do. Basically add some paths so that SFML can be found - stuff you know how to do when doing C++ development in Visual Studio.

  • get pixel / set pixel

    The code I used is as simple as

    sf::Image buffer;
    buffer.create(size, size, sf::Color(0, 0, 0));
    // some loop here
         buffer.setPixel(x, y, sf::Color::Green);

  • support for PNG files (JPG and BMP welcome), reading and writing

    Writing is definitely possible, see code before.

  • gratis

    zlib/png licensed

Displaying an image as a window was not so straight forward. It can't draw images on the window. It needs a sprite for that. And the Sprite needs a texture. I see that this may have benefit in game development and might speed up stuff if textures are reused. So the code is a little more complicated, but still ok:

    sf::RenderWindow window(sf::VideoMode(1000, 1000), "Visualization");

    sf::Image buffer;
    buffer.create(size, size, sf::Color(0, 0, 0));
    // Some loop here
        buffer.setPixel(x, y, sf::Color::Green);

    sf::Texture texture;

    sf::Sprite sprite;
    sprite.setPosition(sf::Vector2f(0.f, 0.f));
    sprite.scale(1000.f / size, 1000.f / size);

    while (window.isOpen())
        sf::Event event;
        while (window.pollEvent(event))
            if (event.type == sf::Event::Closed)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.