How to resize image in C# without smoothing

百般思念 提交于 2019-12-25 00:08:15

问题


How do you re-size a black and white image without any smoothing affect? I have a BarCode that is an image that is too big. I need to resize the image but with one caveat. The resulting image needs to be the same proportional size and the black and white bars can not turn into black,grey and white bars(which I believe is due to some smoothing occuring). Any example of how to do this in c#??


回答1:


@arul is correct. To be specific,

graphics.SmoothingMode = SmoothingMode.None;
graphics.DrawImage( barCodeImage, new Point( 0, 0 ) );

You might also want to check out the InterpolationMode, to see whether changing this value gives you results closer to what you want.




回答2:


You can specify the smoothing mode in the underlying Graphics object.




回答3:


You might want something like:

e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;


来源:https://stackoverflow.com/questions/936210/how-to-resize-image-in-c-sharp-without-smoothing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!