DrawFunction.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Drawing.Imaging;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using OTSIncAReportGraph.Class;
  9. using System.Runtime.InteropServices;
  10. using System.IO;
  11. using OpenCvSharp;
  12. namespace OTSIncAReportGraph.Class
  13. {
  14. /// <summary>
  15. /// 相关图表绘制函数统一封装类
  16. /// </summary>
  17. static class DrawFunction
  18. {
  19. [DllImport("gdi32.dll")]
  20. public static extern System.UInt32 GetPixel(IntPtr hdc, int xPos, int yPos);
  21. /// <summary>
  22. /// 将一个byte的数组转换为8bit灰度位图
  23. /// </summary>
  24. /// <param name="data">数组</param>
  25. /// <param name="width">图像宽度</param>
  26. /// <param name="height">图像高度</param>
  27. /// <returns>位图</returns>
  28. public static Bitmap ToGrayBitmap(byte[] data, int width, int height)
  29. {
  30. //// 申请目标位图的变量,并将其内存区域锁定
  31. Bitmap bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
  32. //// BitmapData这部分内容 需要 using System.Drawing.Imaging;
  33. BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height),
  34. ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
  35. //// 获取图像参数
  36. // 扫描线的宽度
  37. //int stride = bmpData.Stride;
  38. // 显示宽度与扫描线宽度的间隙
  39. int offset = width - width;
  40. // 获取bmpData的内存起始位置
  41. IntPtr iptr = bmpData.Scan0;
  42. // 用stride宽度,表示这是内存区域的大小
  43. int scanBytes = width * height;
  44. //// 下面把原始的显示大小字节数组转换为内存中实际存放的字节数组
  45. int posScan = 0, posReal = 0;// 分别设置两个位置指针,指向源数组和目标数组
  46. byte[] pixelValues = new byte[scanBytes]; //为目标数组分配内存
  47. for (int x = 0; x < height; x++)
  48. {
  49. //// 下面的循环节是模拟行扫描
  50. for (int y = 0; y < width; y++)
  51. {
  52. pixelValues[posScan++] = data[posReal++];
  53. }
  54. posScan += offset; //行扫描结束,要将目标位置指针移过那段“间隙”
  55. }
  56. //// 用Marshal的Copy方法,将刚才得到的内存字节数组复制到BitmapData中
  57. System.Runtime.InteropServices.Marshal.Copy(pixelValues, 0, iptr, scanBytes);
  58. bmp.UnlockBits(bmpData); // 解锁内存区域
  59. //// 下面的代码是为了修改生成位图的索引表,从伪彩修改为灰度
  60. ColorPalette tempPalette;
  61. using (Bitmap tempBmp = new Bitmap(1, 1, PixelFormat.Format8bppIndexed))
  62. {
  63. tempPalette = tempBmp.Palette;
  64. }
  65. for (int i = 0; i < 256; i++)
  66. {
  67. tempPalette.Entries[i] = Color.FromArgb(i, i, i);
  68. }
  69. bmp.Palette = tempPalette;
  70. //// 算法到此结束,返回结果
  71. return bmp;
  72. }
  73. /// <summary>
  74. /// *有BUG*将图片缩放到目标宽高,该方法有问题,不应该继续使用,图像申缩存在不规则问题
  75. /// </summary>
  76. /// <param name="sourceImage"></param>
  77. /// <param name="targetWidth"></param>
  78. /// <param name="targetHeight"></param>
  79. /// <returns></returns>
  80. public static Image pictureProcess(Image sourceImage, int targetWidth, int targetHeight)
  81. {
  82. int width;//图片最终的宽
  83. int height;//图片最终的高
  84. try
  85. {
  86. System.Drawing.Imaging.ImageFormat format = sourceImage.RawFormat;
  87. Bitmap targetPicture = new Bitmap(targetWidth, targetHeight);
  88. Graphics g = Graphics.FromImage(targetPicture);
  89. g.Clear(Color.White);
  90. //计算缩放图片的大小
  91. if (sourceImage.Width > targetWidth && sourceImage.Height <= targetHeight)
  92. {
  93. width = targetWidth;
  94. height = (width * sourceImage.Height) / sourceImage.Width;
  95. }
  96. else if (sourceImage.Width <= targetWidth && sourceImage.Height > targetHeight)
  97. {
  98. height = targetHeight;
  99. width = (height * sourceImage.Width) / sourceImage.Height;
  100. }
  101. else if (sourceImage.Width <= targetWidth && sourceImage.Height <= targetHeight)
  102. {
  103. width = sourceImage.Width;
  104. height = sourceImage.Height;
  105. }
  106. else
  107. {
  108. width = targetWidth;
  109. height = (width * sourceImage.Height) / sourceImage.Width;
  110. if (height > targetHeight)
  111. {
  112. height = targetHeight;
  113. width = (height * sourceImage.Width) / sourceImage.Height;
  114. }
  115. }
  116. g.DrawImage(sourceImage, (targetWidth - width) / 2, (targetHeight - height) / 2, width, height);
  117. g.Dispose();
  118. return targetPicture;
  119. }
  120. catch (Exception ex)
  121. {
  122. string str = ex.ToString();
  123. }
  124. return null;
  125. }
  126. /// <summary>
  127. /// 根据传入的宽和高,取得当前对应显示的4:3的标准分辨率
  128. /// </summary>
  129. /// <returns></returns>
  130. public static Rectangle Get43ScaleResolving(int in_width, int in_height)
  131. {
  132. Rectangle rect_resolving = new Rectangle();
  133. int width_min = 0;
  134. int height_min = 0;
  135. int width_max = 0;
  136. int height_max = 0;
  137. width_min = 1600;
  138. height_min = 1200;
  139. width_max = 2048;
  140. height_max = 1536;
  141. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  142. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  143. width_min = 1400;
  144. height_min = 1050;
  145. width_max = 1600;
  146. height_max = 1200;
  147. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  148. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  149. width_min = 1280;
  150. height_min = 1024;
  151. width_max = 1400;
  152. height_max = 1050;
  153. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  154. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  155. width_min = 1024;
  156. height_min = 768;
  157. width_max = 1280;
  158. height_max = 1024;
  159. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  160. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  161. width_min = 800;
  162. height_min = 600;
  163. width_max = 1024;
  164. height_max = 768;
  165. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  166. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  167. width_min = 640;
  168. height_min = 480;
  169. width_max = 800;
  170. height_max = 600;
  171. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  172. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  173. width_min = 320;
  174. height_min = 240;
  175. width_max = 640;
  176. height_max = 480;
  177. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  178. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  179. width_min = 0;
  180. height_min = 0;
  181. width_max = 320;
  182. height_max = 240;
  183. if ((in_width >= width_min && in_width < width_max) || (in_height >= height_min && in_height < height_max))
  184. rect_resolving = new Rectangle(0, 0, width_min, height_min);
  185. return rect_resolving;
  186. }
  187. /// <summary>
  188. /// [该方法效果正确,但速度上慢,淘汰掉],上下翻转
  189. /// </summary>
  190. /// <param name="mybm">原始图片</param>
  191. /// <param name="width">原始图片的长度</param>
  192. /// <param name="height">原始图片的高度</param>
  193. public static Bitmap RevPicUD(Bitmap mybm, int width, int height)
  194. {
  195. Bitmap bm = new Bitmap(width, height);
  196. int x, y, z;
  197. Color pixel;
  198. for (x = 0; x < width; x++)
  199. {
  200. for (y = height - 1, z = 0; y >= 0; y--)
  201. {
  202. pixel = mybm.GetPixel(x, y);//获取当前像素的值
  203. bm.SetPixel(x, z++, Color.FromArgb(pixel.R, pixel.G, pixel.B));//绘图
  204. }
  205. }
  206. return bm;
  207. }
  208. /// <summary>
  209. /// 实现计算的方法,就是输出个数字,然后向上寻找倍数,然后返回来根
  210. /// </summary>
  211. /// <param name="in_number"></param>
  212. /// <returns></returns>
  213. public static int GetSquareRoot(int in_number)
  214. {
  215. int i_increase = 1;
  216. while (true)
  217. {
  218. //防止死循环
  219. if (i_increase > 10000)
  220. return i_increase;
  221. int ls_i = i_increase * i_increase;
  222. if (in_number > ls_i)
  223. {
  224. //如果当前的数值已经大于平方数的话,那就继续下一次的平方
  225. i_increase++;
  226. continue;
  227. }
  228. else
  229. {
  230. //如果已经小于平方数的话,那就说明已经找到了平方根,返回
  231. return i_increase;
  232. }
  233. }
  234. }
  235. /// <summary>
  236. /// 根据传入的数字返回对应的颜色,范围1-17种颜色,挑出来比较谈的颜色为对比效果好看而挑选
  237. /// </summary>
  238. /// <param name="number"></param>
  239. /// <returns></returns>
  240. public static Color GetColorByNumber(int number)
  241. {
  242. Color ret_color = new Color();
  243. switch (number)
  244. {
  245. case 1:
  246. ret_color = Color.Blue;
  247. break;
  248. case 2:
  249. ret_color = Color.Brown;
  250. break;
  251. case 3:
  252. ret_color = Color.LimeGreen;
  253. break;
  254. case 13:
  255. ret_color = Color.Cyan;
  256. break;
  257. case 4:
  258. ret_color = Color.DarkBlue;
  259. break;
  260. case 5:
  261. ret_color = Color.Red;
  262. break;
  263. case 6:
  264. ret_color = Color.SaddleBrown;
  265. break;
  266. case 7:
  267. ret_color = Color.DimGray;
  268. break;
  269. case 8:
  270. ret_color = Color.Navy;
  271. break;
  272. case 9:
  273. ret_color = Color.Peru;
  274. break;
  275. case 10:
  276. ret_color = Color.Red;
  277. break;
  278. case 11:
  279. ret_color = Color.SeaGreen;
  280. break;
  281. case 12:
  282. ret_color = Color.MintCream;
  283. break;
  284. case 14:
  285. ret_color = Color.PaleTurquoise;
  286. break;
  287. case 15:
  288. ret_color = Color.SeaShell;
  289. break;
  290. case 16:
  291. ret_color = Color.Snow;
  292. break;
  293. case 17:
  294. ret_color = Color.WhiteSmoke;
  295. break;
  296. default:
  297. ret_color = Color.White;
  298. break;
  299. }
  300. return ret_color;
  301. }
  302. /// <summary>
  303. /// 获取一个自绘模仿进度条的bitemap对象,传入进度的值,0-100之间
  304. /// </summary>
  305. /// <param name="process_value"></param>
  306. /// <returns></returns>
  307. public static Bitmap GetProcessBitmap(int process_value)
  308. {
  309. Bitmap bmp = new Bitmap(104, 30); //这里给104是为了左边和右边空出2个像素,剩余的100就是百分比的值
  310. Graphics g = Graphics.FromImage(bmp);
  311. g.Clear(Color.White); //背景填白色
  312. //g.FillRectangle(Brushes.Red, 2, 2, this.Press, 26); //普通效果
  313. //填充渐变效果
  314. SolidBrush drawBrush = new SolidBrush(Color.Black);
  315. g.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(30, 2), new System.Drawing.Point(30, 30), Color.Red, Color.Gray), 2, 2, process_value, 26);
  316. g.DrawString(process_value.ToString(), new Font("宋体", 9), drawBrush, 50, 8);
  317. return bmp;
  318. }
  319. /// <summary>
  320. /// 获取一个自绘模仿进度条的bitemap对象,传入进度的值,0-100之间[重载可以自定设置背景色]
  321. /// </summary>
  322. /// <param name="process_value"></param>
  323. /// <param name="back_color"></param>
  324. /// <returns></returns>
  325. public static Bitmap GetProcessBitmap(float process_value, Color back_color)
  326. {
  327. if (process_value < 0)
  328. process_value = 0;
  329. if (process_value > 100)
  330. process_value = 100;
  331. Bitmap bmp = new Bitmap(104, 30); //这里给104是为了左边和右边空出2个像素,剩余的100就是百分比的值
  332. Graphics g = Graphics.FromImage(bmp);
  333. g.Clear(back_color); //背景填白色
  334. //g.FillRectangle(Brushes.Red, 2, 2, this.Press, 26); //普通效果
  335. //填充渐变效果
  336. SolidBrush drawBrush = new SolidBrush(Color.Black);
  337. g.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(30, 2), new System.Drawing.Point(30, 30), Color.Red, Color.Gray), 2, 2, process_value, 26);
  338. g.DrawString(process_value.ToString(), new Font("宋体", 9), drawBrush, 50, 8);
  339. return bmp;
  340. }
  341. /// <summary>
  342. /// [颜色:16进制转成RGB]
  343. /// </summary>
  344. /// <param name="strColor">设置16进制颜色 [返回RGB]</param>
  345. /// <returns></returns>
  346. public static System.Drawing.Color colorHx16toRGB(string strHxColor)
  347. {
  348. try
  349. {
  350. if (strHxColor.Length == 0)
  351. {//如果为空
  352. return System.Drawing.Color.FromArgb(0, 0, 0);//设为黑色
  353. }
  354. else
  355. {//转换颜色
  356. if (strHxColor.IndexOf('#') > -1)
  357. {
  358. //如果颜色格式是 #0000FF 格式的
  359. return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(1, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(3, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(5, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
  360. }
  361. else
  362. {
  363. //如果颜色格式是 0000FF 格式的
  364. return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
  365. }
  366. }
  367. }
  368. catch
  369. {//设为黑色
  370. return System.Drawing.Color.FromArgb(0, 0, 0);
  371. }
  372. }
  373. /// <summary>
  374. /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
  375. /// </summary>
  376. /// <param name="path"></param>
  377. /// <returns></returns>
  378. public static Bitmap ReadImageFile(string path)
  379. {
  380. if (!File.Exists(path))
  381. {
  382. return null;//文件不存在
  383. }
  384. FileStream fs = File.OpenRead(path); //OpenRead
  385. int filelength = 0;
  386. filelength = (int)fs.Length; //获得文件长度
  387. Byte[] image = new Byte[filelength]; //建立一个字节数组
  388. fs.Read(image, 0, filelength); //按字节流读取
  389. System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
  390. fs.Close();
  391. Bitmap bit = new Bitmap(result);
  392. return bit;
  393. }
  394. //图片转成二进制
  395. public static byte[] GetPictureData(string imagepath)
  396. {
  397. /**/
  398. ////根据图片文件的路径使用文件流打开,并保存为byte[]
  399. FileStream FileStream = new FileStream(imagepath, FileMode.Open);
  400. byte[] byData = new byte[FileStream.Length];
  401. FileStream.Read(byData, 0, byData.Length);
  402. FileStream.Close();
  403. return byData;
  404. }
  405. /// <summary>
  406. /// 将image转成bytes
  407. /// </summary>
  408. /// <param name="in_img"></param>
  409. /// <returns></returns>
  410. public static byte[] ImageConvertToBytes(System.Drawing.Image in_img)
  411. {
  412. MemoryStream ms = new MemoryStream();
  413. in_img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  414. return ms.ToArray();
  415. }
  416. /// <summary>
  417. /// Resize图片
  418. /// </summary>
  419. /// <param name="bmp">原始Bitmap</param>
  420. /// <param name="newW">新的宽度</param>
  421. /// <param name="newH">新的高度</param>
  422. /// <returns>处理以后的图片</returns>
  423. public static Bitmap KiResizeImage(Bitmap bmp, int newW, int newH)
  424. {
  425. try
  426. {
  427. Bitmap b = new Bitmap(newW, newH);
  428. Graphics g = Graphics.FromImage(b);
  429.                 // 插值算法的质量
  430.                 g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  431. g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
  432. g.Dispose();
  433. return b;
  434. }
  435. catch
  436. {
  437. return null;
  438. }
  439. }
  440. public static Bitmap GetReZoomBitmap(Bitmap in_bp)
  441. {
  442. Mat src = OpenCvSharp.Extensions.BitmapConverter.ToMat(in_bp);
  443. Mat dst = new Mat();
  444. Cv2.AdaptiveThreshold(src, dst, 255, AdaptiveThresholdTypes.MeanC, ThresholdTypes.Binary, 27, 25);
  445. //绝对缩放,
  446. Mat dst2 = new Mat();
  447. int col = dst.Width;//获取原图像的大小
  448. int rows = dst.Height;
  449. Cv2.Resize(dst, dst2, new OpenCvSharp.Size(4 * col, 4 * rows), 0, 0, InterpolationFlags.Cubic);
  450. return OpenCvSharp.Extensions.BitmapConverter.ToBitmap(dst2);
  451. }
  452. }
  453. /// <summary>
  454. /// 获取当前桌面显示器相关信息,暂未考虑多显示器
  455. /// </summary>
  456. static public class MyPrimaryScreen
  457. {
  458. #region Win32 API  
  459. [DllImport("user32.dll")]
  460. static extern IntPtr GetDC(IntPtr ptr);
  461. [DllImport("gdi32.dll")]
  462. static extern int GetDeviceCaps(
  463. IntPtr hdc, // handle to DC  
  464. int nIndex // index of capability  
  465. );
  466. [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
  467. static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
  468. #endregion
  469. #region DeviceCaps常量  
  470. const int HORZRES = 8;
  471. const int VERTRES = 10;
  472. const int LOGPIXELSX = 88;
  473. const int LOGPIXELSY = 90;
  474. const int DESKTOPVERTRES = 117;
  475. const int DESKTOPHORZRES = 118;
  476. #endregion
  477. #region 属性  
  478. /// <summary>  
  479. /// 获取屏幕分辨率当前物理大小  
  480. /// </summary>  
  481. public static System.Drawing.Size WorkingArea
  482. {
  483. get
  484. {
  485. IntPtr hdc = GetDC(IntPtr.Zero);
  486. System.Drawing.Size size = new System.Drawing.Size();
  487. size.Width = GetDeviceCaps(hdc, HORZRES);
  488. size.Height = GetDeviceCaps(hdc, VERTRES);
  489. ReleaseDC(IntPtr.Zero, hdc);
  490. return size;
  491. }
  492. }
  493. /// <summary>  
  494. /// 当前系统DPI_X 大小 一般为96  
  495. /// </summary>  
  496. public static int DpiX
  497. {
  498. get
  499. {
  500. IntPtr hdc = GetDC(IntPtr.Zero);
  501. int DpiX = GetDeviceCaps(hdc, LOGPIXELSX);
  502. ReleaseDC(IntPtr.Zero, hdc);
  503. return DpiX;
  504. }
  505. }
  506. /// <summary>  
  507. /// 当前系统DPI_Y 大小 一般为96  
  508. /// </summary>  
  509. public static int DpiY
  510. {
  511. get
  512. {
  513. IntPtr hdc = GetDC(IntPtr.Zero);
  514. int DpiX = GetDeviceCaps(hdc, LOGPIXELSY);
  515. ReleaseDC(IntPtr.Zero, hdc);
  516. return DpiX;
  517. }
  518. }
  519. /// <summary>  
  520. /// 获取真实设置的桌面分辨率大小  
  521. /// </summary>  
  522. public static System.Drawing.Size DESKTOP
  523. {
  524. get
  525. {
  526. IntPtr hdc = GetDC(IntPtr.Zero);
  527. System.Drawing.Size size = new System.Drawing.Size();
  528. size.Width = GetDeviceCaps(hdc, DESKTOPHORZRES);
  529. size.Height = GetDeviceCaps(hdc, DESKTOPVERTRES);
  530. ReleaseDC(IntPtr.Zero, hdc);
  531. return size;
  532. }
  533. }
  534. /// <summary>  
  535. /// 获取宽度缩放百分比  
  536. /// </summary>  
  537. public static float ScaleX
  538. {
  539. get
  540. {
  541. IntPtr hdc = GetDC(IntPtr.Zero);
  542. int t = GetDeviceCaps(hdc, DESKTOPHORZRES);
  543. int d = GetDeviceCaps(hdc, HORZRES);
  544. float ScaleX = (float)GetDeviceCaps(hdc, DESKTOPHORZRES) / (float)GetDeviceCaps(hdc, HORZRES);
  545. ReleaseDC(IntPtr.Zero, hdc);
  546. return ScaleX;
  547. }
  548. }
  549. /// <summary>  
  550. /// 获取高度缩放百分比  
  551. /// </summary>  
  552. public static float ScaleY
  553. {
  554. get
  555. {
  556. IntPtr hdc = GetDC(IntPtr.Zero);
  557. float ScaleY = (float)(float)GetDeviceCaps(hdc, DESKTOPVERTRES) / (float)GetDeviceCaps(hdc, VERTRES);
  558. ReleaseDC(IntPtr.Zero, hdc);
  559. return ScaleY;
  560. }
  561. }
  562. #endregion
  563. }
  564. }