Image resizing efficiency in C# and .NET 3.5

后端 未结 6 1030
傲寒
傲寒 2020-12-31 05:24

I have written a web service to resize user uploaded images and all works correctly from a functional point of view, but it causes CPU usage to spike every time it is used.

6条回答
  •  春和景丽
    2020-12-31 06:28

    I suspect the spike is because you have the interpolation mode cranked right up. All interpolation modes work per pixel and BiCubic High Quality is about as high as you can go with GDI+ so I suspect the per pixel calculations are chewing up your CPU.
    As a test try dropping the interpolation mode down to InterpolationModeNearestNeighbor and see if the CPU spike drops - if so then that's your culprit.
    If so then do some trial and error for cost vs quality, chances are you might not need High Quality BiCubic to get decent results

提交回复
热议问题