Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Bitmap + Clipboard + Transparency = Blue Background?

Bitmap + Clipboard + Transparency = Blue Background?

Scheduled Pinned Locked Moved C#
questiongraphicshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chadwick Posey
    wrote on last edited by
    #1

    Hey folks, I think this is my first time asking a question here, so please go easy on me ;) I have an application wherein I render a transparent bitmap (to be specific -- a chart with a transparent background).... When I do, I then try to copy it to the clipboard using: bmp.Save(filename); // Save to FS Clipboard.SetImage(bmp); // Save to Clipboard Now if I open Excel, and click Paste (from the clipboard), I end up with a copy of my chart with this lovely blue background wherever the transparency color was. If I, instead, use Excel's Insert->Image->From File, the chart's transparency is preserved... (same bitmap as above, just one is saved to file system, the other is copied via clipboard) What gives? Am I copying the bitmap incorrectly, or is there something else I need to do to make copy and paste of transparent bitmaps a reality? (I have searched high and low, and nothing seems to answer this question... I have tried all kinds of things to resolve this on my own, even using MakeTransparent() (which has no effect, since the bitmap was already transparent to begin with (as evidenced by the Flags value on the bitmap being "2" which is hasTransparency)... I have tried converting the image, using color maps, using SetClipboardDataObject, converting to an HBITMAP object or whatever.... all kinds of things, nothing seems to avert this issue....) Thanks in Advance!

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    C 1 Reply Last reply
    0
    • C Chadwick Posey

      Hey folks, I think this is my first time asking a question here, so please go easy on me ;) I have an application wherein I render a transparent bitmap (to be specific -- a chart with a transparent background).... When I do, I then try to copy it to the clipboard using: bmp.Save(filename); // Save to FS Clipboard.SetImage(bmp); // Save to Clipboard Now if I open Excel, and click Paste (from the clipboard), I end up with a copy of my chart with this lovely blue background wherever the transparency color was. If I, instead, use Excel's Insert->Image->From File, the chart's transparency is preserved... (same bitmap as above, just one is saved to file system, the other is copied via clipboard) What gives? Am I copying the bitmap incorrectly, or is there something else I need to do to make copy and paste of transparent bitmaps a reality? (I have searched high and low, and nothing seems to answer this question... I have tried all kinds of things to resolve this on my own, even using MakeTransparent() (which has no effect, since the bitmap was already transparent to begin with (as evidenced by the Flags value on the bitmap being "2" which is hasTransparency)... I have tried converting the image, using color maps, using SetClipboardDataObject, converting to an HBITMAP object or whatever.... all kinds of things, nothing seems to avert this issue....) Thanks in Advance!

      ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Transparency is only supported by some file formats, such as PNG. The raw BITMAP format, which is what Windows uses internally, does not support transparency. The Bitmap class does allow setting a color that is transparent, I *think* ( it may be that the support only exists at the point of drawing the image ), but ultimately I suspect what you're finding is that the clipboard contains a raw image, not an image in, say, PNG format. That's if Excel can work it out. More likely, an image in the clipboard is a plain vanilla bitmap, and the image when loaded by Excel, is loaded as a PNG or other format with transparency support, and thus it's respected by Excel, because it's still there.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups