how to enlarge an image (any type) from c# without losing quality
question says it all..
app would be in asp.net and c# (4.0)开发者_StackOverflow
This is impossible. Just think of the very simple case of a 10 x 10 bitmap with 8-bit color. Therefore there are 10 * 10 * 8 = 800 bits of information. Now try to enlarge this to a 100 x 100 bitmap with 8-bit color. This requires 80000 bits of information. Where is that extra information going to come from? There are all sorts of interpolation schemes for trying guess what the information should be but that's the best we can do. There must be a loss of quality as we don't know what the information should be.
Here are some interpolation schemes:
- Nearest neighbor
- Bilinear
- Bicubic
- hq2x
These methods have different qualities. Some lead to jaggedness (nearest neighbor), others lead to a softening of the image (bilinear) and others lead to ringing artifacts (bicubic).
If you enlarge an image beyond its original size, you lose quality. There is no way around that.
That said, there are different methods/algorithms for resizing, some of which may introduce less quality degradation than others. Experiment with the resizing parameters to figure out which works best for your situation.
It's not impossible! Check out the Genuine Fractals plug-in. It uses "fractal based interpolation algorithms" to enlarge an image without losing quality.
It's a plugin for Photoshop, but illustrates that high-quality enlargement is indeed possible. (I wonder whether it's possible to invoke it via a .Net application? Hmmm...)
精彩评论