views:

423

answers:

3

I was wondering if anybody knew a way to detect when a picture is copied in the clipboard then perform the following when it happens:

  • Convert this picture into a GIF/PNG
  • Then put back this compressed picture into the clipboard

The reason I am asking is that we often copy paste screenshots to users and paste them in Lotus. For some reason, pasting directly the picture in Lotus makes bigger emails than pasting in Paint saving as GIF, copying from the GIF then pasting in Lotus.

I guess than the clipboard does not store the pixels themselves but literally an object knowing the format of the data taken.

Feel free to correct me if I am wrong !

EDIT:

After the reading the first answer, my question is: "how can I, every time a picture is in the clipboard, compress it and put it back in the clipboard ?"

+1  A: 

Assuming this is on Windows, the clipboard stores the image in non-compressed form. GIF is a compressed image file format, so it does compression which is why the files are smaller that way.

unwind
Edited my question: it would be then ... how can I compress a picture on the fly when it is taken from the clipboard and put it back in the clipboard
BlueTrin
A: 

If you're only looking for a Lotus Notes solution, depending on which version of Lotus Notes you're running, there's a preference for "Compress images pasted into documents". I think that came in version 8.0 but I could be wrong. Apart from that, I don't know of anything you could use.

I just did a test of pasting a screenshot into a draft email and the saved draft is 124KB. Pasted the screenshot into Paint and saved it as a GIF which was a 163KB file.

Jonesy
EDIT: I wish our Lotus team would update the clients, we are still using Lotus over here : (
BlueTrin
A: 

I use the following C# program for a similar purpose. It saves the clipboard into a PNG file. Then I upload the file in Gmail or whatever.

class Clip2Png {
[System.STAThread]
public static void Main(string[] args) {
    if (args.Length != 1) {
        System.Console.WriteLine("Usage: clip2png filename");
        return;
    }

    System.Windows.Forms.IDataObject lData = System.Windows.Forms.Clipboard.GetDataObject();
    if (lData == null || !lData.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap)) {
        System.Console.WriteLine("No image in clipboard");
        return;
    }

    System.Drawing.Image image = (System.Drawing.Image)
            lData.GetData(System.Windows.Forms.DataFormats.Bitmap, true);
    image.Save(args[0], System.Drawing.Imaging.ImageFormat.Png);
}
}
agsamek
EDIT, it would be very close to what I want except I would like to put it back in the clipboard, do you know how I could do that ?
BlueTrin
See @unwind answer - clipboard stores DIB images. It is the application that defines what to do with the clipboard - eg. my application stores it as a PNG file as the last step.
agsamek
Lotus attaches it as an uncompressed image.Where you able to paste the clipboard contents as GIF from any application to Lotus? I do not think so. Rather - you were able to attach a GIF file from hdd and in this case Lotus stores it as a GIF in the email.
agsamek