Jump to content

  • Log In with Google      Sign In   
  • Create Account


C# PictureBox Copy&Paste


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Funkymunky   Members   -  Reputation: 487

Like
0Likes
Like

Posted 16 January 2010 - 01:35 PM

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).

Sponsor:

#2 Funkymunky   Members   -  Reputation: 487

Like
0Likes
Like

Posted 16 January 2010 - 05:57 PM

damn! Photoshop gets it too! it must be in the way Firefox copies it to the clipboard. Blast!

#3 ApochPiQ   Moderators   -  Reputation: 12394

Like
0Likes
Like

Posted 16 January 2010 - 06:00 PM

Forgive me if this is a dumb question, but what keeps you from just doing a right-click/save image from within Firefox?

#4 Funkymunky   Members   -  Reputation: 487

Like
0Likes
Like

Posted 16 January 2010 - 09:36 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS