【问题标题】:Draw zoomed pixelated image to picturebox将缩放的像素化图像绘制到图片框
【发布时间】:2018-09-09 00:08:14
【问题描述】:

我有一个 120x120 的 png 图像。我想取其中的一部分 (10x10) 并将其缩放 x32 倍并显示给 picturebox pixelated

我做了什么:

bmp = New Bitmap(320, 320, PixelFormat.Format32bppArgb) 'create a bitmap x32
Dim g As Graphics = Graphics.FromImage(bmp)

'draw the part in that bitmap
g.DrawImage(My.Resources.MyImage, New Rectangle(0, 0, 320, 320), New Rectangle(50, 50, 10, 10), GraphicsUnit.Pixel)

PictureBox1.Image = bmp

g.Dispose()

图像未像素化。我能做些什么来解决它?

【问题讨论】:

    标签: vb.net image winforms picturebox


    【解决方案1】:

    您必须在图形中指定:

    g.InterpolationMode = InterpolationMode.NearestNeighbor
    

    并将矩形更改为:

    g.DrawImage(My.Resources.MyImage, New RectangleF(0, 0, 320, 320), New RectangleF(49.5, 49.5, 10, 10), GraphicsUnit.Pixel)
    

    这样你就不会损失半个像素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 2013-05-14
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 2019-09-17
      相关资源
      最近更新 更多