This is the snippet of code I will focus on
int Width = (int)InkControl.ActualWidth, Height = (int)InkControl.ActualHeight;
InkControl.Background = Brushes.White;
var Renderer = new RenderTargetBitmap(Width, Height, 96d, 96d, PixelFormats.Default);
System.Drawing.Bitmap SignImage = null;
using (MemoryStream OutStream = new MemoryStream())
{
Renderer.Render(InkControl);
var Encoder = new JpegBitmapEncoder();
Encoder.QualityLevel = 100;
Encoder.Frames.Add(BitmapFrame.Create(Renderer));
Encoder.Save(OutStream);
SignImage = new System.Drawing.Bitmap(OutStream);
}
Everything is fine and in SignImage
I have my image saved. Anyway when I resize it (mantaining proportion but reducing the size) it becomes very pixelated and horrible.
Is there is a way to avoid this and apply a proper scale to resize the image?
After this I have to put this image in a Signature Appearence in a PDF using iTextSharp, after this it loses again resolution, becoming a really really unrecognizable trait.
I'm developing in windows 7, with .NET 4.5 and Visual Studio 2013. The application has to be deployed in a Window Surface Device, with Windows 8.
This is the snippet for iText code
PdfSignatureAppearance SignAppearence = SignStamper.SignatureAppearance;
var rect = new iTextSharp.text.Rectangle(left, bottom, left + signImage.Width, bottom + signImage.Height);
SignAppearence.SetVisibleSignature(rect, page, fieldName: SignAppearence.GetNewSigName());
SignAppearence.SignatureGraphic = iTextSharp.text.Image.GetInstance(signImage, ImageFormat.Jpeg);
SignAppearence.SignatureRenderingMode = PdfSignatureAppearance.RenderingMode.GRAPHIC;