Click here to Skip to main content
Licence 
First Posted 9 Jan 2000
Views 180,435
Bookmarked 74 times

High quality image rotation (rotate by shear)

By Eran Yariv | 9 Jan 2000
Rotating images using shear
1 vote, 14.3%
1

2
1 vote, 14.3%
3

4
5 votes, 71.4%
5
4.32/5 - 25 votes
μ 4.32, σa 2.75 [?]
  • Download demo project - 21 Kb
  • Download source files - 4 Kb

    Sample Image - RotateByShear.gif

    Unlike traditional rotation of images, where every n'th pixel is sampled and copied to the result image, this template provides much more accurate image rotation features (weighing the pixels).

    template is instantiated with a specific pixel format and must be inherited to support pixel access functions for a specific bitmap implementation. This provides abstaction of the rotation mechanism from the actual bitmap representation.

    Major features:

    • ides professional quality image rotation.
    • Code is optimized for image quality, not speed.
    • Rotated image retains size and aspect ratio of source image (destination image size is usally bigger).
    • Supports double precision rotation angles (0..360).
    • Supports generic bitmap structures. Specific bitmap structure is defined by inheritance.
    • Template based - no need for libraries, DLLs etc. No linkage problems.

    How to use the rotation template:

    You must derive you own class from the rotation template.

    For example:

    class CRotateByShearRGB : public CRotateByShear<COLORREF>

    will define a concrete class where each pixel is of COLORREF type.

    Next, you must override 5 abstract functions which support creation, destruction of bitmap buffers and pixel level access to the bitmap buffers.

    Then you instantiate your derived class and call the AllocAndRotate(...) function which allocates a new destination bitmap buffer and rotates the input image into it.

    That's it.

    For further instructions please view the attached sample command-line project (Rotate.cpp). It is a simple command line utility which reads PPM (ASCII or binary) image file into a DIB structure, rotates it and saves it to another PPM image file.

  • License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Eran Yariv



    United States United States

    Member


    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    GeneralMy vote of 1 Pinmembersujeshsasi19:57 5 Mar '09  
    Generalhave bugs in the demo PinmemberWeiHua zhang19:06 24 Oct '07  
    Generala show stopper bug PinmemberXiaotian Guo21:12 7 Jul '03  
    GeneralRe: a show stopper bug PinmemberJim the Bad7:06 11 Aug '05  
    GeneralRotation of BMP PinmemberSandeep11_165:21 3 Jun '03  
    I have created a control on a Dialog. I have set a BMP on that Control.
    Now I want to rotate that control.
     
    Please tell me how can I do that?
    GeneralSpeed optimized version Pinmemberantontreskunov16:03 24 Apr '03  
    GeneralRe: Speed optimized version Pinmemberyyt_yyt23:20 8 Jul '03  
    GeneralRe: Speed optimized version PinsussAnonymous9:39 12 Jul '03  
    GeneralRe: Speed optimized version Pinmemberpmidd10:23 17 Oct '03  
    GeneralRe: Speed optimized version Pinmemberantontreskunov7:55 21 Oct '03  
    GeneralRe: Speed optimized version PinmemberAlexandre GRANVAUD3:52 14 Jan '08  
    Questionhow to get the ppm image from a bitmap? PinmemberAlanShen18:11 19 Apr '03  
    AnswerRe: how to get the ppm image from a bitmap? Pinmembertyjiang16:30 30 Jul '08  
    GeneralBMP Image Rotation about its own axes PinmemberVaibhav Sanghavi21:26 24 Apr '02  
    GeneralRe: BMP Image Rotation about its own axes PinmemberTili11:19 28 Sep '02  
    GeneralAlgorithm PinmemberNeil Younusov5:22 28 Feb '02  
    GeneralRe: Algorithm Pinmemberland_lubber8:44 1 Oct '02  
    GeneralRe: Algorithm PinmemberPeter Merrill19:47 14 Jan '03  
    GeneralNice image! PinmemberAlvaro Mendez14:28 21 Aug '01  
    GeneralRe: Nice image! PinmemberAlexandre GRANVAUD3:51 14 Jan '08  
    QuestionCan you publish shrink code??? Pinmemberobjects16:28 30 Mar '01  
    GeneralNon-Rectangular Stretching PinmemberSubbi Iyer0:26 21 Feb '01  
    GeneralRe: Non-Rectangular Stretching Pinmembermsg55511:24 14 Apr '06  
    GeneralRe: Non-Rectangular Stretching Pinmembergslin10:03 3 Nov '06  
    QuestionRelated Paper ?? Pinmemberlooker22:47 25 Jan '01  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Mobile
    Web02 | 2.5.120210.1 | Last Updated 10 Jan 2000
    Article Copyright 2000 by Eran Yariv
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid