Solution of C # image amplification problem

Source: Internet
Author: User
Enlarge | solve | Problem recently, when I was writing tools, I found a very disgusting problem, when using drawimage to enlarge the image, the default amplification algorithm of C # is not Nearestneighbor algorithm, and Java Swing's DrawImage amplification algorithm defaults to the Nearestneighbor algorithm, the solution is: G.interpolationmode = System.Drawing.Drawing2D.InterpolationMo De.         Nearestneighbor; I thought this would solve the problem, the results of the enlarged image of the upper left half pixel less, that is, if the magnified image is 8 times times, then the magnification of the image is less than 4 pixels wide, do not know why C # to do so, it is said to be due to the floating point and the rounding of the problem caused by, if not Java convenient Ah, The solution is: g.pixeloffsetmode = System.Drawing.Drawing2D.PixelOffsetMode.Half;


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.