Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win32clipboard increasing size of data when SetClipboardData used with CF_DIB #2096

Closed
cmdvmd opened this issue Aug 8, 2023 · 1 comment
Closed

Comments

@cmdvmd
Copy link

cmdvmd commented Aug 8, 2023

  • Expected behavior and actual behavior.

    When copying an image to the clipboard using CF_DIB, the size of the data should be the same both before AND after copying the image. However, the size of the copied image is 1 byte larger.

  • Steps to reproduce the problem.

    Download the image.png file (or just any image file named image.png) and run the following Python script in the same
    directory:

    import win32clipboard
    
    with open('image.png', 'rb') as image:
        image_bytes = image.read()
    
    
    win32clipboard.OpenClipboard()
    
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardData(win32clipboard.CF_DIB, image_bytes)
    
    copied_bytes = win32clipboard.GetClipboardData(win32clipboard.CF_DIB)
    
    win32clipboard.CloseClipboard()
    
    print('Original image size:', len(image_bytes))  # 37257 bytes using attached file
    print('Copied data size:', len(copied_bytes))  # 37258 bytes using attached file
  • Version of Python and pywin32
    Python: 3.11.4
    pywin32: 306

@Avasam
Copy link
Collaborator

Avasam commented Mar 28, 2024

Closed by #2184

@Avasam Avasam closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants