Possible bug w/ "clipboard:"

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
odditude
Posts: 2
Joined: 2012-02-07T16:23:55-07:00
Authentication code: 8675308

Possible bug w/ "clipboard:"

Post by odditude »

I'm trying to use ImageMagick in conjunction with VBA to create PNGs from Excel via the clipboard. If the data is copied to the clipboard normally, ImageMagick works perfectly. However, if the data is copied to the clipboard through VBA, ImageMagick fails to see any image data on the clipboard.

The VBA code in question is:

Code: Select all

Range(<rangeObject>).CopyPicture xlScreen, xlPicture
which copies the contents of <rangeObject> to the clipboard as an image.

With this data, ImageMagick returns:

Code: Select all

C:\test>convert clipboard:myimage -density 150 -units pixelsperinch testpls.png
convert.exe: no bitmap on clipboard `myimage' @ error/clipboard.c/ReadCLIPBOARDImage/138.
convert.exe: missing an image filename `testpls.png' @ error/convert.c/ConvertImageCommand/3016.
With the same data,

Code: Select all

i_view32 /clippaste /convert=testIV.png
generates the image properly.

Installed version is ImageMagick-6.7.5-0-Q16-windows.zip (portable package) on Windows 7 (x64), running Excel 2010 (32-bit).

Easiest way to reproduce is by opening Excel, putting some random data in a cell, selecting said cell, and in the VBA Immediate window running:

Code: Select all

Selection.CopyPicture xlScreen, xlPicture
This will put the image data on the clipboard for analysis.
Werty
Posts: 66
Joined: 2010-08-06T05:37:36-07:00
Authentication code: 8675308

Re: Possible bug w/ "clipboard:"

Post by Werty »

Are you sure you are feeding it image data and not just a Handle to the data ?

Try...

Code: Select all

Convert rose: clipboard:

then...

Convert clipboard: image.jpg
^this works for me, having no image data on the clipboard gives me the same error as yours, so it seems you arent getting the correct data on your clipboard.
Windows 7 user
odditude
Posts: 2
Joined: 2012-02-07T16:23:55-07:00
Authentication code: 8675308

Re: Possible bug w/ "clipboard:"

Post by odditude »

OK - got it to work (you need to use xlBitmap instead of xlPicture). xlBitmap was giving me bad data in both programs before, likely due to Excel misbehaving.

Using InsideClipboard, though, I verified that xlPicture is passing just handles to a WMF and EMF; xlBitmap provides actual DIB and DIBv5 data.
Post Reply