先上图,该图示一只小狗。

 
GDI+ 通过图像的分辨率,大小,屏幕的分辨率,来计算图像的大小。

可以有这么的一个算式:内存图像的大小/屏幕的大小 = 内存的分辨率/屏幕的分辨率

代码如下:

 1  private void Form1_Paint(object sender, PaintEventArgs e)
 2         {
 3             var g = e.Graphics;
 4             Bitmap bm = new Bitmap("rama.jpg");
 5             g.DrawImage(bm, 00);
 6 
 7             Console.WriteLine("display resolution:DPix{0},DpiY{1} ",g.DpiX,g.DpiY);
 8             Console.WriteLine("image resolution:DPix{0},DpiY{1} ",bm.HorizontalResolution,bm.VerticalResolution);
 9             Console.Write("image_width:{0}", bm.Width);
10             Console.Write("image_height:{0}",bm.Height);
11             Console.WriteLine("屏幕显示的实际宽度:width{0},height{1}",bm.Width*(g.DpiX/bm.HorizontalResolution),bm.Height*(g.DpiY/bm.VerticalResolution));
12             
13         }

 

 

 

 

相关文章:

  • 2023-03-25
  • 2021-12-04
  • 2021-06-06
  • 2021-05-01
  • 2021-11-14
  • 2021-12-13
猜你喜欢
  • 2021-12-04
  • 2021-06-03
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2021-11-23
相关资源
相似解决方案