在.net中消除混叠双色调位图而不收缩
有没有一种方法可以在不收缩图像的情况下反锯齿双色调位图(在.NET中)。例如,我有一个黑白图像,黑色对象有锯齿状的边缘。我希望平滑“非白色”对象上的边,而不收缩整个位图 以下是我当前执行操作的方式:在.net中消除混叠双色调位图而不收缩,.net,vb.net,bitmap,antialiasing,.net,Vb.net,Bitmap,Antialiasing,有没有一种方法可以在不收缩图像的情况下反锯齿双色调位图(在.NET中)。例如,我有一个黑白图像,黑色对象有锯齿状的边缘。我希望平滑“非白色”对象上的边,而不收缩整个位图 以下是我当前执行操作的方式: Dim from_bm = New Bitmap(frm.ClientSize.Width, frm.ClientSize.Height) Dim bm_gr As Graphics = Graphics.FromImage(from_bm) Dim bm_hdc As IntPtr = bm_gr
Dim from_bm = New Bitmap(frm.ClientSize.Width, frm.ClientSize.Height)
Dim bm_gr As Graphics = Graphics.FromImage(from_bm)
Dim bm_hdc As IntPtr = bm_gr.GetHdc
BitBlt(bm_hdc, 0, 0, frm.ClientSize.Width, frm.ClientSize.Height, hdc, 0, 0, SRCCOPY)
bm_gr.ReleaseHdc(bm_hdc)
Dim w As Integer = (from_bm.Width / 4) ' This is the operation I wish to avoid
Dim h As Integer = (from_bm.Height / 4)
to_bm = New Bitmap(w, h)
Dim gr As Graphics = Graphics.FromImage(to_bm)
gr.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
gr.DrawImage(from_bm, 0, 0, (w - 1), (h - 1))
gr.DrawImageUnscaled(to_bm, 0, 0)
我想知道是否有一些算法或库,我可以用来执行上述,但不缩小上面的图像。我希望避免缩小图像的原因是,我无法将完整的位图保存到内存中,我只能将显示的内容保存到屏幕上,这给我带来了一些问题。我不确定是否理解您的意思,但我认为您可以使用以下方法设置图形的插值模式:
graphic.InterpolationMode = InterpolationMode.NearestNeighbor