Skip to content

sf::Clipboard new setImage and getImage #3657

Description

@Zombieschannel

Prerequisite Checklist

Describe your feature request here

With drag and drop support planned for SFML 3.2.0, adding the ability to copy/paste images to/from the clipboard would further improve the ease of use of SFML apps.

Use Cases

Similar to how drag and drop would make opening files quicker in some situations, copy pasting images from/to clipboard could be useful in also many situations (editors, image viewers, ...)

API Example

#include <SFML/Graphics.hpp>

int main()
{
    sf::Image image;
    ...
    sf::Clipboard::setImage(image.getSize(), image.getPixelsPtr());
    
    sf::Vector2u size;
    uint8_t* pixels = nullptr;
    sf::Clipboard::getImage(size, pixels); //pixels stays nullptr if no image is in clipboard
    
    //or something like
    auto img = sf::Clipboard::getImage(); //img is a pair or optional or something similar
}

Design for setting the image would be something similar to sf::Window::setIcon as sf::Image is in SFML-Graphics and sf::Clipboard is in SFML-Window so we cannot just pass an sf::Image as an argument.

As for getting the image from the clipboard I'm not sure, maybe return a std::pair or set size and pixels as parameters which the function would then change...
I'd love to hear other suggestions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions