GetImageSizePt
(
Size oImageSizePx,
Workbook oWorkbook
)
{
Debug.Assert(oWorkbook != null);
// There doesn't seem to be a direct way to get the screen resolution
// from Excel or from .NET. As a workaround, leveredge the fact that
// a new bitmap is given a resolution equal to the screen resolution.
//
// Because this method is called one time only, this workaround is
// acceptable.
Bitmap oBitmap = new Bitmap(10, 10);
Single fPxPerInchX = oBitmap.HorizontalResolution;
Single fPxPerInchY = oBitmap.VerticalResolution;
oBitmap.Dispose();
const Single PointsPerInch = 72;
return ( new SizeF(
(Single)oImageSizePx.Width * PointsPerInch / fPxPerInchX,
(Single)oImageSizePx.Height * PointsPerInch / fPxPerInchY
) );
}