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. .NET (Core and Framework)
  4. drawing text on an image

drawing text on an image

Scheduled Pinned Locked Moved .NET (Core and Framework)
graphicsquestioncsharp
4 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
    sarabjs
    wrote on last edited by
    #1

    Hello folks, I wish to write text on an Image in .NET I figure I can use the Graphics.drawString() method to do so, but it turns out that .NET would only allow me to write on images with non-indexed pixel formats. The format I'm now using is 1bppIndexed, which allows me to keep the size of these image objects limited. I do not wish to change these images to a non-indexed pixel format like 24bppRGB (even though that allows me to draw text on the image), 'cause here I'm only dealing with binary images, each around 3500pixels by 2480pixels. Since a format like 24bppRGB occupies much more space than what is required, I was hoping there would be a way to write on the 1bppIndexed images directly. Any ideas? Thanks...

    G 1 Reply Last reply
    0
    • S sarabjs

      Hello folks, I wish to write text on an Image in .NET I figure I can use the Graphics.drawString() method to do so, but it turns out that .NET would only allow me to write on images with non-indexed pixel formats. The format I'm now using is 1bppIndexed, which allows me to keep the size of these image objects limited. I do not wish to change these images to a non-indexed pixel format like 24bppRGB (even though that allows me to draw text on the image), 'cause here I'm only dealing with binary images, each around 3500pixels by 2480pixels. Since a format like 24bppRGB occupies much more space than what is required, I was hoping there would be a way to write on the 1bppIndexed images directly. Any ideas? Thanks...

      G Offline
      G Offline
      Guido_d
      wrote on last edited by
      #2

      If you're using 1bpp images, that's plain black and white. Truetype fonts require more color depth to perform antialiasing, so that won't work. You can go three ways IMO: - render the font to a transparent image, convert to black & white and overlay over the original image, possibly creating a jagged font or - convert the image to more bpp, then render the text on top of it, then convert back to b&w. Will use a lot of memory for the converted image. or - use a bitmapped font that you can directly add to the image by using SetPixel() Good luck..

      G S 2 Replies Last reply
      0
      • G Guido_d

        If you're using 1bpp images, that's plain black and white. Truetype fonts require more color depth to perform antialiasing, so that won't work. You can go three ways IMO: - render the font to a transparent image, convert to black & white and overlay over the original image, possibly creating a jagged font or - convert the image to more bpp, then render the text on top of it, then convert back to b&w. Will use a lot of memory for the converted image. or - use a bitmapped font that you can directly add to the image by using SetPixel() Good luck..

        G Offline
        G Offline
        Guido_d
        wrote on last edited by
        #3

        Oops I overlooked the 1bpp INDEXED, so not black & white, but the same solutions apply IMO.

        1 Reply Last reply
        0
        • G Guido_d

          If you're using 1bpp images, that's plain black and white. Truetype fonts require more color depth to perform antialiasing, so that won't work. You can go three ways IMO: - render the font to a transparent image, convert to black & white and overlay over the original image, possibly creating a jagged font or - convert the image to more bpp, then render the text on top of it, then convert back to b&w. Will use a lot of memory for the converted image. or - use a bitmapped font that you can directly add to the image by using SetPixel() Good luck..

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

          Understood the anti-aliasing part.. But didn't quite understand your first suggestion.. As for your second suggestion, I figure it doesn't solve the memory problem.. Guess will take a shot at attempting your third suggestion though... Thanks... 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