Putting a Xojo Picture on the Clipboard as a Jpeg

On my Mac, when I create a Picture in XOJO and put it on the clipboard, and then paste it into a email, it ends up in the email as a tiff.
For example:
Dim p as picture
p = CreateSomePicture()
Dim c as New Clipboard
c.Picture = p

Then Paste this picture into the body of an email message, it will be a tiff.
How do I get it to be a jpeg in the email.
If I open a jpeg picture file in Preview, Select All, Copy, then Paste this into an email, it will be a jpeg in the email.

Of course, I could save the Xojo picture as a jpeg file then do the above view,select all, copy, but this is cumbersome
Does anyone know how to do this?


I think this might have something to do with the native format of the macOS pasteboard… Not knowing how the .Picture method saves the image to the pasteboard… I do not know if converting the picture to a JPEG MemoryBlock and then out to a string, to use .AddRawData, with the UTI image.jpeg would work…

First of all, please check what you have in yout clipboard.

To do that, go to the AppleScript Editor application (don’t know the US name) and copy/paste the script below:

return clipboard info

Then run the code and watch what you will find in the Results area (window bottom). As a test, I used cmd-shift-4, select a part of the screen to be copied in the Clipboard and run the script/ I get:

{{«class PNGf», 78024}, {«class 8BPS», 482416}, {GIF picture, 25991}, {«class jp2 », 88890}, {JPEG picture, 48012}, {TIFF picture, 2110432}, {«class BMP », 2106166}, {«class TPIC», 238482}}

At Paste time, either (or both or…) the OS / the Application will choose the appropriate contents to paste. The mechanism is the same one that does not allw you to paste a text in Preview as graphics document -{ or Paste an image in TextEdit in the raw (not RTF /RTFD) format.

So, telling you get tiff and… can be wrong.

That said, I do not know how to convert an image to the JPEG format (and since this is a lossy format, I do not want to do that).

For jpeg use:

dim c as new Clipboard c.AddRawData p.GetData(Picture.FormatJPEG,100),Picture.FormatJPEG

If you like MBS Plugins:

You could use NSPasteBoardMBS class on Mac or WindowsClipboardMBS class on Windows to do it with more control on details.


The default is for the NSPasteboard is TIFF (for various reasons).

I was about to suggest the same thing, i.e. manually making JPEG data and then manually stuffing it there.