I'm trying to create an image on a bitmap using C#. Somehow it always adds grey border on all sides of the image. Many questions have been posted with the solution and I have tried almost all of them but none of them worked.
Code that I'm using:
Bitmap appearance = new Bitmap(490, 196, PixelFormat.Format32bppArgb);
using (Graphics graphics = Graphics.FromImage(appearance))
{
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.PixelOffsetMode = PixelOffsetMode.Half;
graphics.CompositingMode = CompositingMode.SourceCopy;
using (ImageAttributes wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
Rectangle destination = new Rectangle(5, 99, 240, 94);
graphics.DrawImage(img, destination, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, wrapMode);
}
}
appearance.Save("F:\\SignatureAppearance.jpeg");
Can anyone help me? The grey border does not show when zoomed out but as one starts zooming in, borders start appearing.
Any help will be appreciated
i have tried to create an image with white background even that has right and bottom borders .
Bitmap appearance = new Bitmap(490, 196, PixelFormat.Format32bppArgb);
using (Graphics graphics = Graphics.FromImage(appearance)) {
// graphics.Clear(Color.White);
Rectangle ImageSize = new Rectangle(0, 0, 490, 196);
graphics.FillRectangle(Brushes.White, ImageSize); }
appearance.Save("F:\\Signature_Appearance.png", ImageFormat.Png);
}
img
is. The border may very simply be inside that image. As for alternative, you should look into theSystem.Windows.Media.Imaging
namespace. – BalliettDrawImage
and what side effects it can cause: photosauce.net/blog/post/… – Balliett