我需要調整一個像MS Paint中的調整大小那樣的bmp - 這是沒有反鋸齒的。 任何人都知道如何在c#或vb.net中做到這一點?調整像MS Paint中的位圖
回答
可以使用Image.GetThumbnailImage
方法。我不知道它的抗鋸齒。
編輯:因爲我最近在一個項目中使用了它,所以我在考慮縮略圖。但你只是要求調整大小。此方法可能不會導致高質量大尺寸調整。
http://msdn.microsoft.com/en-us/library/system.drawing.image.getthumbnailimage.aspx
從MSDN How to: Copy Images。
油漆只是將圖像切掉,不是嗎?該頁面上的示例提供了所需的工具。
@Robert - Paint.Net最近因爲品牌重塑和轉售而關閉了源代碼。然而,舊版本(3.36)仍然是開源的。
@Moshe,這是更好地表述爲評論根據我的回答,並不是OP的問題的另一個答案。 – 2009-12-06 07:16:10
他需要50個代表。能夠寫評論... – Jan 2009-12-06 19:52:52
您可以將圖形插值模式設置爲最近的鄰居,然後使用drawimage調整大小而不進行抗鋸齒。 (原諒我的VB :-))
Dim img As Image = Image.FromFile("c:\jpg\1.jpg")
Dim g As Graphics
pic1.Image = New Bitmap(180, 180, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
g = Graphics.FromImage(pic1.Image)
g.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor
g.DrawImage(img, 0, 0, pic1.Image.Width, pic1.Image.Height)
// ********************************************** ScaleBitmap
/// <summary>
/// Scale a bitmap by a scale factor, growing or shrinking
/// both axes, maintaining the aspect ratio
/// </summary>
/// <param name="inputBmp">
/// Bitmap to scale
/// </param>
/// <param name="scale_factor">
/// Factor by which to scale
/// </param>
/// <returns>
/// New bitmap containing the original image, scaled by the
/// scale factor
/// </returns>
/// <citation>
/// A Bitmap Manipulation Class With Support For Format
/// Conversion, Bitmap Retrieval from a URL, Overlays, etc.,
/// Adam Nelson, The Code Project, September 2003.
/// </citation>
private Bitmap ScaleBitmap (Bitmap bitmap,
float scale_factor)
{
Graphics g = null;
Bitmap new_bitmap = null;
Rectangle rectangle;
int height = (int) ((float) bitmap.Size.Height *
scale_factor);
int width = (int) ((float) bitmap.Size.Width *
scale_factor);
new_bitmap = new Bitmap (width,
height,
PixelFormat.Format24bppRgb);
g = Graphics.FromImage ((Image) new_bitmap);
g.InterpolationMode = InterpolationMode.High;
g.ScaleTransform (scale_factor, scale_factor);
rectangle = new Rectangle (0,
0,
bitmap.Size.Width,
bitmap.Size.Height);
g.DrawImage (bitmap,
rectangle,
rectangle,
GraphicsUnit.Pixel);
g.Dispose ();
return (new_bitmap);
}
你想要InterpolationMode.NearestNeighbor - 不是InterpolationMode.High。 – BrainSlugs83 2013-12-18 22:58:23
- 1. C#WinForms - 圖片/圖像框選擇 - 像MS Paint
- 2. CSS圖像位置調整
- 3. 調整位圖圖像的大小
- 4. 如何在MS Reporting Services報表中動態調整圖像的中心位置?
- 5. 工具調色板喜歡在MS Paint
- 6. 調整位圖圖像大小?
- 7. 位圖圖像爲null調整後
- 8. 位圖圖像調整大小
- 9. 調整位圖
- 10. 用MS Paint保存後圖像文件更改內容
- 11. MS Paint中的TextBox的java代碼
- 12. CSS中的圖像調整
- 13. 調整,如MS畫圖位圖 - 無抗鋸齒
- 14. Android位圖將小圖像調整爲圖像視圖
- 15. 調整圖像大小,固定位置
- 16. Tensorflow:調整圖像佔位符
- 17. 調整圖像
- 18. 調整圖像
- 19. 在datagridview的單元格中調整位圖圖像大小
- 20. Bitmap.decodeResource調整圖像
- 21. 在css中調整圖像
- 22. 在WPF中調整圖像
- 23. 在ms-paint中獲取像素座標by c#
- 24. Paint:如何使用漸變圖像或位圖圖像繪製圓弧
- 25. 如何在android中調整位圖圖像對比度?
- 26. PHP調整圖像
- 27. uitableviewcell調整圖像
- 28. 調整圖像上的圖像點擊
- 29. 在WinForms中將調整大小後的位圖圖像調回原始大小
- 30. CSS:在div中調整4個圖像的位置
從WPF的新功能通常比老System.Drawing中的人更快,更好。檢查出http://stackoverflow.com/questions/754168/how-to-serve-high-resolution-imagery-in-a-low-resolution-form-using-c – 2009-12-06 19:44:58