Home > Back-end >  How can I load an image from the OpenGL/Glfw clipboard?
How can I load an image from the OpenGL/Glfw clipboard?

Time:11-05

I am making a program that loads images and displays them with OpenGL / Glfw. I have managed to load the images from a path but I also want to do it from the windows clipboard. With text it works for me to read it. But when I copy an image from windows explorer nothing comes up or it tells me that the clipboard is empty.

bool FeatherGUI::loadFromClipBoard() {
    std::cout << "Loading from clipboard" << std::endl;
    //Show content of clipboard with glfwGetClipboardString
    const char* clipboard = glfwGetClipboardString(this->windowContext);
    if (clipboard == NULL) {
        std::cout << "Clipboard is empty" << std::endl;
        return false;
    }else{
        std::cout << "Clipboard content: " << clipboard << std::endl;
    }
    return true;
}

How can I get what I want?

CodePudding user response:

GLFW doesn't provide that functionality at the moment.

See issue #260, "Support for clipboard image data".

GLFW's Windows implementation of glfwPlatformGetClipboardString() lives in src/win32_window.c if you feel like taking a stab at adding CF_BITMAP/CF_DIB/CF_DIBV5 support.

  • Related