Recent

Author Topic: Cocoa not pasting images  (Read 2728 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Cocoa not pasting images
« on: January 27, 2019, 11:28:45 am »
I believe Cocoa has a problem pasting images. Attached demo shows that when the clipboard contains an image copied from another application, the normal questions about "do you have an image" are always answered false. (press the Info button).

The issue, I believe is that Cocoa offers image formats that Lazarus cannot handle : public.html; Apple HTML pasteboard type; public.tiff; NeXT TIFF v4.0 pasteboard type
 
Carbon works fine. With both Carbon and Cocoa, an internally copied picture is reported as being image/bmp, is identified as an image and pastes fine.

I'm using Lazarus fixes_2_0 r60228, this looks similar to bug 34840 but is, in fact completely different !

Be cool if someone else can duplicate my results, if so, I'll report it in the bug tracker.

Run up the attached demo, build with fixes or trunk (1.8.4 not viable on Cocoa), copy an image from a webpage, maybe the one top left of this page and then go back to the app, click the info button. I expect you will see HasPictureFormat; FindPictureFormatID; return false, 0 and false. And cannot paste that picture with the paste button.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: Cocoa not pasting images
« Reply #1 on: January 27, 2019, 11:49:50 am »
Tried it with 60228/Cocoa, Mojave 10.14.2 as well ...


Right click image on this website (Lazarus logo), and clicked Info:



Code: Pascal  [Select][+][-]
  1.  
  2. HasPictureFormat is False
  3. FindPictureFormatID is 0
  4. HasFormat(CF_PICTURE) is False
  5. Format=public.tiff  ID=4305277376
  6. Format=NeXT TIFF v4.0 pasteboard type  ID=4305284736
  7. Format=public.html  ID=4305285120
  8. Format=Apple HTML pasteboard type  ID=4305285248
  9. Format=dyn.ah62d4rv4gu8yc6durvwwaznwmuuha2pxsvw0e55bsmwca7d3sbwu  ID=4305285312
  10. Format=Apple URL pasteboard type  ID=4305285440
  11. Format=public.url-name  ID=4305285568
  12. Format=CorePasteboardFlavorType 0x75726C6E  ID=4305285632
  13. Format=dyn.ah62d4rv4gu8zs3pcnzme2641rf4guzdmsv0gn64uqm10c6xenv61a3k  ID=4305285696
  14. Format=WebURLsWithTitlesPboardType  ID=4305285824
  15. Format=text/plain  ID=4305285888
  16. Format=NSStringPboardType  ID=4305286016
  17. Format=public.url  ID=4305286144
  18. Format=CorePasteboardFlavorType 0x75726C20  ID=4305286208
  19. End of format list, count=14
  20.  


Tried a screenshot (to clipboard) and clicked Info:


Code: Pascal  [Select][+][-]
  1. HasPictureFormat is False
  2. FindPictureFormatID is 0
  3. HasFormat(CF_PICTURE) is False
  4. Format=public.png  ID=4305286464
  5. Format=Apple PNG pasteboard type  ID=4305286272
  6. Format=public.tiff  ID=4305277376
  7. Format=NeXT TIFF v4.0 pasteboard type  ID=4305284736
  8. End of format list, count=4


(Command+V does the same)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cocoa not pasting images
« Reply #2 on: January 27, 2019, 12:23:41 pm »
Thanks Hansaplast, thats what I expected !

As you show, HasPictureFormat (eg) is false but we do have at least two tiff based formats available.

I am however surprised about the line 15 in your first block. You seem to have a fix for bug 0034832 where text/plan became text/plain. We are on same revision and I don't have that fix ?

Your screenshot one is interesting too. You get a png and we cannot handle that. A name space issue, "Its an image file Captain, but not as we know it".

I'll log a bug report tomorrow, getting late.....

Thanks,
Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: Cocoa not pasting images
« Reply #3 on: January 27, 2019, 12:38:36 pm »
You're welcome!
I've updated from SVN just before compiling your example project (Lazarus 2.1.0 r60228M FPC 3.0.4 x86_64-darwin-cocoa (alpha)) and copied the image from Google Chrome (Version 71.0.3578.98 (Official Build) (64-bit)). Maybe that's the difference?
[/size]This is what the info looks like from Safari:[/color]
[/size][/color]

Code: Pascal  [Select][+][-]
  1. HasPictureFormat is False
  2. FindPictureFormatID is 0
  3. HasFormat(CF_PICTURE) is False
  4. Format=public.tiff  ID=4305285568
  5. Format=NeXT TIFF v4.0 pasteboard type  ID=4305292864
  6. Format=dyn.ah62d4rv4gu8zs3pcnzme2641rf4guzdmsv0gn64uqm10c6xenv61a3k  ID=4305293248
  7. Format=WebURLsWithTitlesPboardType  ID=4305293376
  8. Format=dyn.ah62d4rv4gu8yc6durvwwaznwmuuha2pxsvw0e55bsmwca7d3sbwu  ID=4305293440
  9. Format=Apple URL pasteboard type  ID=4305293568
  10. Format=public.url  ID=4305293696
  11. Format=CorePasteboardFlavorType 0x75726C20  ID=4305293760
  12. Format=public.url-name  ID=4305293888
  13. Format=CorePasteboardFlavorType 0x75726C6E  ID=4305293952
  14. Format=text/plain  ID=4305294016
  15. Format=NSStringPboardType  ID=4305294144
  16. Format=com.apple.flat-rtfd  ID=4305294272
  17. Format=NeXT RTFD pasteboard type  ID=4305294400
  18. Format=com.apple.webarchive  ID=4305294528
  19. Format=Apple Web Archive pasteboard type  ID=4305294592
  20. End of format list, count=16

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cocoa not pasting images
« Reply #4 on: January 27, 2019, 11:55:47 pm »

Thanks Hans, I might checkout a fresh Fixes and see if I still see that plan/plain issue. But that has no bearing on the cocoa clipboard image issue. Needs to be logged.
 
Reported here - https://bugs.freepascal.org/view.php?id=34960

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018