C# PictureBox Copy&Paste

Started by
2 comments, last by Funkymunky 14 years, 3 months ago
I've implemented a little trick with the PictureBox control, where I added a context menu with "Paste" that when you click does this:
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Clipboard.GetDataObject().GetDataPresent("Bitmap"))
            {
                object o = Clipboard.GetDataObject().GetData("Bitmap");
                if (o != null)
                {
                    PBox.Image = (Image)o;
                    PBox.Width = PBox.Image.Width;
                    PBox.Height = PBox.Image.Height;
                }
            }
        }
This works like a charm copy & pasting straight out of firefox. However, it doesn't copy over the alpha channel if the source is a .gif or .png or something. Is there anyway to get that data too? Right now it just converts these pixels to black (0, 0, 0, 255).
Advertisement
damn! Photoshop gets it too! it must be in the way Firefox copies it to the clipboard. Blast!
Forgive me if this is a dumb question, but what keeps you from just doing a right-click/save image from within Firefox?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

nah its not a dumb question. im actually just playing around with c# for the first time, and i'm surprised at how easy it is to add all kinds of features like this. that's what i've ended up doing anyway, and since i need to load TGAs i've been planning to load from the disk from the get go

This topic is closed to new replies.

Advertisement