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. WMF to Base64String

WMF to Base64String

Scheduled Pinned Locked Moved C#
question
7 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.
  • S Offline
    S Offline
    sunsher
    wrote on last edited by
    #1

    Hi, Is it possible to convert a .wmf file to Base64String? Thanks

    OriginalGriffO 1 Reply Last reply
    0
    • S sunsher

      Hi, Is it possible to convert a .wmf file to Base64String? Thanks

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Yes: all files are just a stream of byte values - it's the interpretation that software puts on the internal format of those bytes that makes it a "WMF" or "JPG" file. The extension just indicates what format the software should look for.

      string base64 = Convert.ToBase64String(file.ReadAllBytes(@"D:\Temp\myPicture.wmf"));

      However, that doesn't mean that whatever you pass the base64 string to can do anything useful with it. For example, not all browsers support WMF file data in any format, and changing it to Base64 will not fix that. WMF is pretty much a "Windows only" image format: you would probably be better off using a more generic format such as JPG, GIF, or PNG.

      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      S 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Yes: all files are just a stream of byte values - it's the interpretation that software puts on the internal format of those bytes that makes it a "WMF" or "JPG" file. The extension just indicates what format the software should look for.

        string base64 = Convert.ToBase64String(file.ReadAllBytes(@"D:\Temp\myPicture.wmf"));

        However, that doesn't mean that whatever you pass the base64 string to can do anything useful with it. For example, not all browsers support WMF file data in any format, and changing it to Base64 will not fix that. WMF is pretty much a "Windows only" image format: you would probably be better off using a more generic format such as JPG, GIF, or PNG.

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

        S Offline
        S Offline
        sunsher
        wrote on last edited by
        #3

        wow! that's just in one line!!! Thanks very much! How do I load it back to a form? :confused:

        OriginalGriffO 1 Reply Last reply
        0
        • S sunsher

          wow! that's just in one line!!! Thanks very much! How do I load it back to a form? :confused:

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Um... Convert.FromBase64String[^] :laugh:

          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          S 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Um... Convert.FromBase64String[^] :laugh:

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

            S Offline
            S Offline
            sunsher
            wrote on last edited by
            #5

            Thanks! :laugh:

            OriginalGriffO 1 Reply Last reply
            0
            • S sunsher

              Thanks! :laugh:

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              You're welcome!

              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              S 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                You're welcome!

                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                S Offline
                S Offline
                sunsher
                wrote on last edited by
                #7

                I more concern. ;P I want the metafile to be created in memory rather than saving to a disk. It should be a blank metafile. I assume it is like this.

                metfile = New Metafile(hdc, EmfType.EmfPlusDual)

                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