And so, the disposition is as follows: There is an Image (control) with a size of 100 by 100. The image is set to 100 by 100 as the image source.
In runtime, I translate Image into BitMap and save it to a file with the following code:
int width = (int)image.ActualWidth; int height = (int)image.ActualHeight; RenderTargetBitmap rtb = new RenderTargetBitmap(width, height, 96d, 96d, PixelFormats.Default); rtb.Render(image); BmpBitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(rtb)); MemoryStream ms = new MemoryStream(); encoder.Save(ms); ms.Position = 0; Bitmap CurentPrintLabelImg = new Bitmap(ms); CurentPrintLabelImg.Save("Test.bmp"); As a result, I expect that at the output I will receive an image of 100 by 100 absolutely identical to sorsy. But I get an image with grayscale on the borders of black areas. (looks like a blur)
Also noticed that image.ActualWidth and image.ActualHeight are less than 100 (~ 99 and 98)
How to achieve the coincidence of the original and the output image and why the control is scaled in runtime?
Image.Source. - VladDWritableBitmap,Drawing,RenderTargetBitmapand so on. Type this: stackoverflow.com/a/14387686/276994 . Here you certainly control all sizes, and you can separate this part from the presentation - VladD