[英]Bitmap image - Decrease the number of pixels
我正在使用以下代碼
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
bitmap.Save(@"C:\test\2560.png", ImageFormat.Png);
該代碼有效。 我使用 graphics.CopyFromScreen() 截取屏幕截圖,並使用 bitmap.Save() 保存 bitmap。
圖像由 2560x1440 像素組成。 基本上我想遍歷像素以尋找顏色值。
3,686,400 查詢對我來說太多了,我想減少像素數,這意味着圖像質量會下降。 圖像處理是否有可能減少像素數? 這樣一些像素就會模糊在一起並產生平均值?
我將其設置為 bitmap.SetResolution(800, 600); 但不幸的是它沒有用。
這應該可以解決問題。
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
Bitmap smallBmp = new Bitmap(bitmap, new Size(800, 600));
smallBmp.Save(@"C:\test\2560.png", ImageFormat.Png);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.