Click here to Skip to main content
15,881,715 members
Articles / Desktop Programming / MFC
Article

High quality image rotation (rotate by shear)

Rate me:
Please Sign up or sign in to vote.
4.53/5 (12 votes)
9 Jan 2000 254.1K   10K   84   29
Rotating images using shear
  • 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


    Written By
    United States United States
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralSpeed optimized version Pin
    antontreskunov24-Apr-03 15:03
    antontreskunov24-Apr-03 15:03 
    GeneralRe: Speed optimized version Pin
    yyt_yyt8-Jul-03 22:20
    yyt_yyt8-Jul-03 22:20 
    GeneralRe: Speed optimized version Pin
    Anonymous12-Jul-03 8:39
    Anonymous12-Jul-03 8:39 
    GeneralRe: Speed optimized version Pin
    pmidd17-Oct-03 9:23
    pmidd17-Oct-03 9:23 
    GeneralRe: Speed optimized version Pin
    antontreskunov21-Oct-03 6:55
    antontreskunov21-Oct-03 6:55 
    GeneralRe: Speed optimized version Pin
    Alexandre GRANVAUD14-Jan-08 2:52
    Alexandre GRANVAUD14-Jan-08 2:52 

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

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