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. Getting images from an RTF file

Getting images from an RTF file

Scheduled Pinned Locked Moved C#
csharpwinformshelpquestion
6 Posts 4 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
    sarabjs
    wrote on last edited by
    #1

    Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab

    G D M S 4 Replies Last reply
    0
    • S sarabjs

      Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      That won't be easy. You will need to read RTF specification. Here is an article that does the opposite you want: inserts images in richtextbox so it might help to understand basic concepts: Insert Plain Text and Images into RichTextBox at Runtime[^]

      Giorgi Dalakishvili #region signature my articles My blog[^] #endregion

      S 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        That won't be easy. You will need to read RTF specification. Here is an article that does the opposite you want: inserts images in richtextbox so it might help to understand basic concepts: Insert Plain Text and Images into RichTextBox at Runtime[^]

        Giorgi Dalakishvili #region signature my articles My blog[^] #endregion

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

        Hi Giorgi, Yes - that's the problem! I've found plenty of examples describing how to insert images into RTF but none on how to do the opposite! Am surprized no one else has had the need for this.. Hope someone else can help ... ? Sarab

        1 Reply Last reply
        0
        • S sarabjs

          Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          The RTF specification is available here[^] if that's any help. I think you're gonna have to parse the rtf and reconstruct the image from the data that's embedded.

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Expect everything to be hard and then enjoy the things that come easy. (code-frog)

          1 Reply Last reply
          0
          • S sarabjs

            Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab

            M Offline
            M Offline
            Mohammad Dayyan
            wrote on last edited by
            #5

            Did you see this article[^]

            1 Reply Last reply
            0
            • S sarabjs

              Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab

              S Offline
              S Offline
              sarabjs
              wrote on last edited by
              #6

              Hi, Thanks to everyone for your ideas! I managed to get the images. Here's how: Images in RTF are as hexadecimal strings (as noted from the specifications). So all that needed to be done was: 1. Convert the hexadecimal to a byte array: http://www.koders.com/csharp/fid8BD422682325288B294A97714AC061D115F0307D.aspx[^]) 2. Then make an image out of this array: byte[] bData; // The byte array MemoryStream memStream = new MemoryStream(bData, 0, bData.Length); Image iMage = Image.FromStream(memStream); Et voila! Sarab

              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