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. converting images

converting images

Scheduled Pinned Locked Moved C#
question
3 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How do you convert an image to an icon? I've tried a couple of things, the latest being statusBarPanel1.Icon = (Icon) (new ImageConverter.ConvertFrom(imageList1.Images[2])); Anyone have any success with this? Thanks. vaMope

    J 1 Reply Last reply
    0
    • L Lost User

      How do you convert an image to an icon? I've tried a couple of things, the latest being statusBarPanel1.Icon = (Icon) (new ImageConverter.ConvertFrom(imageList1.Images[2])); Anyone have any success with this? Thanks. vaMope

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      It appears that you can't :(( I tried new IconConverter().ConvertFrom(myBitmap); and it throws a NotSupportedException with the text "IconConverter cannot convert from System.Drawing.Bitmap". James Sonork ID: 100.11138 - Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971

      V 1 Reply Last reply
      0
      • J James T Johnson

        It appears that you can't :(( I tried new IconConverter().ConvertFrom(myBitmap); and it throws a NotSupportedException with the text "IconConverter cannot convert from System.Drawing.Bitmap". James Sonork ID: 100.11138 - Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971

        V Offline
        V Offline
        vaMope
        wrote on last edited by
        #3

        Thanks, James. I didn't get it to work that way, either, but I tried something else with better results. I set the build property of each image I wanted to reference to 'Embedded Resource' rather than 'Content'. Then, I used the following routine to grab the icon from the assembly. public static Icon GetIcon(string iconName) { Assembly assemb = Assembly.GetEntryAssembly(); return new Icon(assemb.GetManifestResourceStream("mynamespace.myfolder." + iconName)); } Note that the case must be correct and the file extension and folder name must be included. vaMope

        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