How to rotate image x degrees in c#?

后端 未结 2 957
北恋
北恋 2020-12-03 14:33

I have done some searching and i can not find any function thats doing what i whant it todo.

I have a image file of a scanned document with text, but the document is

2条回答
  •  失恋的感觉
    2020-12-03 15:18

    This is strictly a comment to the nice answer by VisualMelon above, But I'm not allowed to add comments...

    There are two tiny bugs in the code

    a) The first check after the modulus should either be split into two, or changed to e.g.

    if (180

    Otherwise angles between -360 and -180 will fail, as only +180 to +360 were handled

    b) Just after the newImg assignment, a resolution assignment is missing, e.g.

    newImg.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution);
    

    If omitted the image will be scaled if the source is not 96 dpi.

    ....And splitting sticks, the intermediate calculations of dimensions and offsets ought to be kept in double, and only reduced to float last

提交回复
热议问题