0

I'm writing a WinJS app and it would be a nice feature to handle animated GIFs. After some research, if would seem that in order to do that, that the data is copied to the clipboard using the little know CF_GIF clipboard format

how to get animated gif image from browser clipboard api?

but looking over the WinJS documentation for clipboard formats

http://msdn.microsoft.com/en-US/library/windows/apps/windows.applicationmodel.datatransfer.standarddataformats

it doesn't seem like CF_GIF is available, and when I copy a GIF to the clipboard and look at dataPackageView with the command

var dataPackageView = Windows.ApplicationModel.DataTransfer.Clipboard.getContent();

it just shows up as a bitmap. Can anyone tell me if it is indeed possible to get an animated GIF from the clipboard or some kind of work around?

Community
  • 1
  • 1
Bradley Bossard
  • 2,439
  • 2
  • 23
  • 30

1 Answers1

0

CF_Bitmap is the way to go here.

You COULD make a private data format, and put the entire GIF on there. And you could paste it into other instances of your app. But it wouldn't work with anything else, unless you also provided it as CF_Bitmap.

OK, there's another way. You could dump to a .gif file, then place the CF_HDROP (file pointer) onto the clipboard. Then when you paste, it's like pasting a file from windows explorer. That may work for some apps.

Yeah, like I said, use CF_Bitmap.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
  • Well, I would if I could, but what I'm saying is, it doesn't seem like WinJS even lets you know or gives you access to the CF_GIF identifier. In this link http://msdn.microsoft.com/en-US/library/windows/apps/windows.applicationmodel.datatransfer.standarddataformats it doesn't seem like they have exposed a function to be able to retrieve it, only other types. My use case is like someone copies a GIF in Chrome, then jumps over to my app and pastes it. – Bradley Bossard Nov 28 '13 at 00:10
  • When they copy a GIF in Chrome, what formats are presented on the clipboard? I think you'll find out that it doesn't matter that WinJS doesn't give you access to CF_GIF, as it's not on the clipboard as CF_GIF. Copying a GIF from Chrome yields CF_Bitmap, CF_DIB (another bitmap), HTML, and some private UniformResourceLocator thing. – Chris Thornton Dec 01 '13 at 02:45
  • Hi Chris, thanks for following up. I'm not exactly what format Chrome uses for posting a GIF to the clipboard, but looking at another answer you posted http://stackoverflow.com/a/14945981/1754642, it seems to me like there is still an unanswered question of "how does Gmail do it?" For instance, I just tried this, find an animated gif, right-click and "Copy Image", then compose a new email in Gmail, and paste and it pastes an animated GIF into the Gmail. Either Chrome does use the CF_GIF format, or they somehow get the URL of the GIF, but I was under the impression that gets thrown away. – Bradley Bossard Dec 02 '13 at 19:14