How to add blank space to an image
-
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
-
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
MS Paint?
I know the language. I've read a book. - _Madmatt
-
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
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; }
-
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
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
-
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; }
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.
-
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; }
I was about to say that ;P
It is Good to be Important but! it is more Important to be Good