mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
fix docs compliance for CF_HDROP
This commit is contained in:
parent
5728662c7f
commit
1656edaf41
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
@ -79,7 +80,8 @@ $bmp = New-Object Drawing.Bitmap 200, 200
|
|||
p.communicate()
|
||||
|
||||
im = ImageGrab.grabclipboard()
|
||||
assert_image_equal_tofile(im, "Tests/images/hopper.gif")
|
||||
assert len(im) == 1
|
||||
assert os.path.samefile(im[0], "Tests/images/hopper.gif")
|
||||
|
||||
@pytest.mark.skipif(sys.platform != "win32", reason="Windows only")
|
||||
def test_grabclipboard_png(self):
|
||||
|
|
|
@ -93,15 +93,20 @@ def grabclipboard():
|
|||
os.unlink(filepath)
|
||||
return im
|
||||
elif sys.platform == "win32":
|
||||
import io
|
||||
|
||||
fmt, data = Image.core.grabclipboard_win32()
|
||||
if isinstance(data, str):
|
||||
if fmt == "file":
|
||||
with open(data, "rb") as f:
|
||||
im = Image.open(io.BytesIO(f.read()))
|
||||
return im
|
||||
if fmt == "file": # CF_HDROP
|
||||
import struct
|
||||
|
||||
o = struct.unpack_from("I", data)[0]
|
||||
if data[16] != 0:
|
||||
files = data[o:].decode("utf-16le").split("\0")
|
||||
return files[: files.index("")]
|
||||
else:
|
||||
files = data[o:].decode("mbcs").split("\0")
|
||||
return files[: files.index("")]
|
||||
if isinstance(data, bytes):
|
||||
import io
|
||||
|
||||
data = io.BytesIO(data)
|
||||
if fmt == "png":
|
||||
from . import PngImagePlugin
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <Shlobj.h>
|
||||
#include "ImDib.h"
|
||||
|
||||
#if SIZEOF_VOID_P == 8
|
||||
|
@ -504,27 +503,6 @@ PyImaging_GrabClipboardWin32(PyObject* self, PyObject* args)
|
|||
return Py_BuildValue("zO", NULL, Py_None);
|
||||
}
|
||||
|
||||
if (formats[format] == CF_HDROP) {
|
||||
LPDROPFILES files = (LPDROPFILES)GlobalLock(handle);
|
||||
size = GlobalSize(handle);
|
||||
|
||||
if (files->fWide) {
|
||||
LPCWSTR filename = (LPCWSTR)(((char*)files) + files->pFiles);
|
||||
size = wcsnlen(filename, (size - files->pFiles) / 2);
|
||||
result = Py_BuildValue("zu#", "file", filename, size);
|
||||
}
|
||||
else {
|
||||
LPCSTR filename = (LPCSTR)(((char*)files) + files->pFiles);
|
||||
size = strnlen(filename, size - files->pFiles);
|
||||
result = Py_BuildValue("zs#", "file", filename, size);
|
||||
}
|
||||
|
||||
GlobalUnlock(handle);
|
||||
CloseClipboard();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
data = GlobalLock(handle);
|
||||
size = GlobalSize(handle);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user