mirror of
https://github.com/glfw/glfw.git
synced 2024-11-14 18:34:34 +00:00
Add bitmap setting to clipboard on for windows
This commit is contained in:
parent
3eaf1255b2
commit
7d4e2d44ca
@ -5823,6 +5823,9 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
|
||||
*/
|
||||
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
|
||||
|
||||
// hacky way for a screenshot
|
||||
GLFWAPI void glfwSetClipboardBitmap(unsigned char * data, int width, int height);
|
||||
|
||||
/*! @brief Returns the contents of the clipboard as a string.
|
||||
*
|
||||
* This function returns the contents of the system clipboard, if it contains
|
||||
|
@ -1459,6 +1459,12 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
|
||||
_glfw.platform.setClipboardString(string);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetClipboardBitmap(unsigned char * data, int width, int height)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfw.platform.setClipboardBitmap();
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
@ -750,6 +750,7 @@ struct _GLFWplatform
|
||||
void (*getRequiredInstanceExtensions)(char**);
|
||||
GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
|
||||
VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
void (*setClipboardBitmap)();
|
||||
};
|
||||
|
||||
// Library global data
|
||||
|
@ -677,6 +677,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
||||
_glfwGetRequiredInstanceExtensionsWin32,
|
||||
_glfwGetPhysicalDevicePresentationSupportWin32,
|
||||
_glfwCreateWindowSurfaceWin32,
|
||||
_glfwSetClipboardBitmapWin32
|
||||
};
|
||||
|
||||
*platform = win32;
|
||||
|
@ -591,6 +591,7 @@ GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
|
||||
void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
|
||||
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
void _glfwSetClipboardStringWin32(const char* string);
|
||||
void _glfwSetClipboardBitmapWin32();
|
||||
const char* _glfwGetClipboardStringWin32(void);
|
||||
|
||||
EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs);
|
||||
|
@ -2291,6 +2291,49 @@ void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
updateCursorImage(window);
|
||||
}
|
||||
|
||||
void _glfwSetClipboardBitmapWin32(unsigned char * data, int width, int height) {
|
||||
// HDC hdcScreen;
|
||||
// HDC hdcMemDC = NULL;
|
||||
// HBITMAP hbmScreen = NULL;
|
||||
HBITMAP fillBm = NULL;
|
||||
// Retrieve the handle to a display device context for the client
|
||||
// area of the window.
|
||||
// hdcScreen = GetDC(NULL);
|
||||
|
||||
// and a device context to put it in
|
||||
// hdcMemDC = CreateCompatibleDC(hdcScreen);
|
||||
|
||||
// int width = 1920;
|
||||
// int height = 1080;
|
||||
|
||||
// Create a compatible bitmap from the Window DC.
|
||||
// hbmScreen = CreateCompatibleBitmap(hdcScreen, width, height);
|
||||
fillBm = CreateBitmap(width, height, 1, 32, data);
|
||||
|
||||
// get a new bitmap
|
||||
// HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcMemDC, hbmScreen);
|
||||
// BitBlt(hdcMemDC, 0, 0, width, height, hdcScreen, 0, 0, SRCCOPY);
|
||||
// hbmScreen = (HBITMAP)SelectObject(hdcMemDC, hOldBitmap);
|
||||
|
||||
|
||||
if (!OpenClipboard(_glfw.win32.helperWindowHandle)) {
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard");
|
||||
return;
|
||||
}
|
||||
EmptyClipboard();
|
||||
|
||||
// place handle to clipboard
|
||||
SetClipboardData(CF_BITMAP, fillBm);
|
||||
|
||||
// Close the clipboard.
|
||||
CloseClipboard();
|
||||
DeleteObject(fillBm);
|
||||
// DeleteObject(hbmScreen);
|
||||
// DeleteObject(hOldBitmap);
|
||||
// DeleteObject(hdcMemDC);
|
||||
// ReleaseDC(NULL, hdcScreen);
|
||||
}
|
||||
|
||||
void _glfwSetClipboardStringWin32(const char* string)
|
||||
{
|
||||
int characterCount;
|
||||
|
Loading…
Reference in New Issue
Block a user