2016-05-14 65 views
2

有没有一种方法来抗锯齿2色调位图(在.NET中)而不缩小图像。例如,我有黑白图像,黑色的物体有锯齿边缘。我想平滑“非白色”对象的边缘而不缩小整个位图。抗锯齿双色调位图在.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.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) 

我不知道是否有一些算法或图书馆中,我可以用它来执行以上,但没有上述缩小图像。我希望避免缩小图像的原因是因为我无法将完整的位图保存到内存中,我只能保存显示在屏幕上的内容,这对我造成了一些问题。

回答

0

我不知道已经了解你的意思,但我认为,你可以通过设置图形的插补方式:

graphic.InterpolationMode = InterpolationMode.NearestNeighbor