[Qt-interest] Windows: Copy from Qt app into GIMP fails?

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Wed Feb 16 09:56:11 CET 2011


On 2011-02-15 Jason Jason H wrote:

> I've only done limited clipboarding, but I'd say you need to find out what mime
> types GIMP accepts.

To my limited understanding of the Windows clipboard it stores it as "device independent bitmap" (BMP?). Simply calling http://doc.trolltech.com/4.7/qmimedata.html#setImageData should take care of all necessary encoding and properly setting the MIME data. And it does work for all applications I have tried so far - except GIMP :/

At least that's what I see within MS Word for example, when I choose "Paste Contents" ("Inhalte einfuegen" in my German Word version), it sais "Device independent bitmap" as the content of the clipboard, after I have copied the image data from my application.

> It should be that easy. I should take some kind image/??
> mime type. 

As a matter of fact in an earlier attempt I tried explicitly saving the image as PNG and setting the MIME data to 'image/png' (I also tried BMP) ("pseudo-code", might not actually compile, but you get the idea):

  QByteArray data;
  QBuffer buffer(data);
  buffer.open(QIODevice::Write)
  QImage image = ...;
  image.save(buffer, "PNG"); // save the image data as PNG
  QMimeData *mimeData = new QMimeData();
  mimeData->setData("image/png", data); // explicitly set MIME type to PNG

but same result, GIMP would say "No data to paste".


I do thing the error might actually be on the GIMP Windows clipboard implementation side, but somehow I have the feeling that it would not require much to "fix" it, either in my application code (maybe I really did miss something), or in the Qt clipboard implementation.

> As a failback, it probably accepts a URL, which could point to an on-
> disk copy of the image being dropped.

Hmmm, I just tried copying a file URL from within Windows File Explorer, and pasting to GIMP: does not work (same message: "No data to paste"). Anyway that would not work in my case, since the image data is generated in memory only.

Again, pasting image data from e.g. Firefox or MS Word into GIMP does work! Oh and by the way I am using the latest stable GIMP 2.6.11 (on all platforms, and yes, pasting from my app into GIMP on Mac and Linux /does/ work as well).


So for now I would be basically interested if anyone actually ever succeeded in pasting data from a Qt application (maybe also with an older Qt version, or an older GIMP installation maybe...) to GIMP on Windows. Or if you observe the same "bug" with your Qt image application.

Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22





More information about the Qt-interest-old mailing list