public static BitmapSource ConvertBitmapTo96DPI(BitmapImage bitmapImage)
{
try
{
double dpi = 96;
int width = bitmapImage.PixelWidth;
int height = bitmapImage.PixelHeight;
int stride = width * 4; // 4 bytes per pixel
byte[] pixelData = new byte[stride * height];
bitmapImage.CopyPixels(pixelData, stride, 0);
return BitmapSource.Create(width, height, dpi, dpi, PixelFormats.Bgra32, null, pixelData, stride);
}
catch (System.Exception ex1)
{
TaskDialog.Show("Error!", "exception: " + ex1);
}
return null;
}