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. How to add blank space to an image

How to add blank space to an image

Scheduled Pinned Locked Moved C#
tutorialquestion
6 Posts 5 Posters 2 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.
  • P Offline
    P Offline
    Paul Brower
    wrote on last edited by
    #1

    I have an image that's been resized to 640x480 pixels. I want to add 'blank space' (white background) to the top of the image. I want to add 70 pixels to the height, so that I have the original image plus a blank 70 pixel high space at the top. Anyone know how to do this? Paul

    N P R 3 Replies Last reply
    0
    • P Paul Brower

      I have an image that's been resized to 640x480 pixels. I want to add 'blank space' (white background) to the top of the image. I want to add 70 pixels to the height, so that I have the original image plus a blank 70 pixel high space at the top. Anyone know how to do this? Paul

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      MS Paint?


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • P Paul Brower

        I have an image that's been resized to 640x480 pixels. I want to add 'blank space' (white background) to the top of the image. I want to add 70 pixels to the height, so that I have the original image plus a blank 70 pixel high space at the top. Anyone know how to do this? Paul

        P Offline
        P Offline
        Paul Brower
        wrote on last edited by
        #3

        Answered my own question: The following will return your image with a 'white' bar 70 pixels high at the top. public Bitmap AddLabelSpace(ref Bitmap img) { var ret = new Bitmap(img.Width, img.Height + 70); var g = Graphics.FromImage(ret); g.Clear(Color.White); g.DrawImage(img, 0, 71,imgr.Width,imgr.Height); ret.Save("f:\\test.jpg",ImageFormat.Jpeg); return ret; }

        L A 2 Replies Last reply
        0
        • P Paul Brower

          I have an image that's been resized to 640x480 pixels. I want to add 'blank space' (white background) to the top of the image. I want to add 70 pixels to the height, so that I have the original image plus a blank 70 pixel high space at the top. Anyone know how to do this? Paul

          R Offline
          R Offline
          R Giskard Reventlov
          wrote on last edited by
          #4

          I thought I was in the asp forum when I answered before, ignore it if it's still there. Create a new image in MSPaint of 640 X 550. Then go 'Paste From' and grab the image and move it to the bottom and Save. That should do it.

          me, me, me "The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!" Larry Niven

          1 Reply Last reply
          0
          • P Paul Brower

            Answered my own question: The following will return your image with a 'white' bar 70 pixels high at the top. public Bitmap AddLabelSpace(ref Bitmap img) { var ret = new Bitmap(img.Width, img.Height + 70); var g = Graphics.FromImage(ret); g.Clear(Color.White); g.DrawImage(img, 0, 71,imgr.Width,imgr.Height); ret.Save("f:\\test.jpg",ImageFormat.Jpeg); return ret; }

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            That is the right way to do it, except for the 71; should be 70, your code is dropping the bottom row of pixels! :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            Getting an article published on CodeProject now is hard and not sufficiently rewarded.


            1 Reply Last reply
            0
            • P Paul Brower

              Answered my own question: The following will return your image with a 'white' bar 70 pixels high at the top. public Bitmap AddLabelSpace(ref Bitmap img) { var ret = new Bitmap(img.Width, img.Height + 70); var g = Graphics.FromImage(ret); g.Clear(Color.White); g.DrawImage(img, 0, 71,imgr.Width,imgr.Height); ret.Save("f:\\test.jpg",ImageFormat.Jpeg); return ret; }

              A Offline
              A Offline
              Amar Chaudhary
              wrote on last edited by
              #6

              I was about to say that ;P

              It is Good to be Important but! it is more Important to be Good

              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