UI: Allow Clipboard Copy/Paste Images #105833

Merged
Harley Acheson merged 2 commits from Harley/blender:ClipboardImage into main 2023-04-14 03:48:28 +02:00
2 changed files with 17 additions and 3 deletions
Showing only changes of commit a8db9ec742 - Show all commits

View File

@ -2332,8 +2332,9 @@ static uint *getClipboardImageDibV5(int *r_width, int *r_height)
int offset = bitmapV5Header->bV5Size + bitmapV5Header->bV5ClrUsed * sizeof(RGBQUAD); int offset = bitmapV5Header->bV5Size + bitmapV5Header->bV5ClrUsed * sizeof(RGBQUAD);
if (bitmapV5Header->bV5Compression == BI_BITFIELDS) if (bitmapV5Header->bV5Compression == BI_BITFIELDS) {
offset += 12; offset += 12;
}
BYTE *buffer = (BYTE *)bitmapV5Header + offset; BYTE *buffer = (BYTE *)bitmapV5Header + offset;
int bitcount = bitmapV5Header->bV5BitCount; int bitcount = bitmapV5Header->bV5BitCount;
int width = bitmapV5Header->bV5Width; int width = bitmapV5Header->bV5Width;

View File

@ -2087,8 +2087,21 @@ ImBuf *WM_clipboard_image_get(void)
bool WM_clipboard_image_set(ImBuf *ibuf) bool WM_clipboard_image_set(ImBuf *ibuf)
{ {
IMB_rect_from_float(ibuf); bool free_byte_buffer = false;
return (bool)GHOST_putClipboardImage(ibuf->rect, ibuf->x, ibuf->y); if (ibuf->rect == NULL) {
/* Add a byte buffer if it does not have one. */
IMB_rect_from_float(ibuf);
free_byte_buffer = true;
}
bool success = (bool)GHOST_putClipboardImage(ibuf->rect, ibuf->x, ibuf->y);
if (free_byte_buffer) {
/* Remove the byte buffer if we added it. */
imb_freerectImBuf(ibuf);
}
return success;
} }
/** \} */ /** \} */