Click here to Skip to main content
Click here to Skip to main content

High quality image rotation (rotate by shear)

, 9 Jan 2000
Rate this:
Please Sign up or sign in to vote.
Rotating images using shear
  • Download demo project - 21 Kb
  • Download source files - 4 Kb

    Sample Image - RotateByShear.gif

    <!-- Article Starts -->

    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

    Share

    About the Author

    Eran Yariv

    United States United States
    No Biography provided

    Comments and Discussions

     
    GeneralMy vote of 1 Pinmembersujeshsasi5-Mar-09 19:57 
    Generalhave bugs in the demo PinmemberWeiHua zhang24-Oct-07 19:06 
    if you set back color with white color, destinition bitmap have many black lines in the non-bitmap region.
    Generala show stopper bug PinmemberXiaotian Guo7-Jul-03 21:12 
    GeneralRe: a show stopper bug PinmemberJim the Bad11-Aug-05 7:06 
    GeneralRotation of BMP PinmemberSandeep11_163-Jun-03 5:21 
    GeneralSpeed optimized version Pinmemberantontreskunov24-Apr-03 16:03 
    GeneralRe: Speed optimized version Pinmemberyyt_yyt8-Jul-03 23:20 
    GeneralRe: Speed optimized version PinsussAnonymous12-Jul-03 9:39 
    GeneralRe: Speed optimized version Pinmemberpmidd17-Oct-03 10:23 
    GeneralRe: Speed optimized version Pinmemberantontreskunov21-Oct-03 7:55 
    GeneralRe: Speed optimized version PinmemberAlexandre GRANVAUD14-Jan-08 3:52 
    Questionhow to get the ppm image from a bitmap? PinmemberAlanShen19-Apr-03 18:11 
    AnswerRe: how to get the ppm image from a bitmap? Pinmembertyjiang30-Jul-08 16:30 
    GeneralBMP Image Rotation about its own axes PinmemberVaibhav Sanghavi24-Apr-02 21:26 
    GeneralRe: BMP Image Rotation about its own axes PinmemberTili28-Sep-02 11:19 
    GeneralAlgorithm PinmemberNeil Younusov28-Feb-02 5:22 
    GeneralRe: Algorithm Pinmemberland_lubber1-Oct-02 8:44 
    GeneralRe: Algorithm PinmemberPeter Merrill14-Jan-03 19:47 
    GeneralRe: Algorithm PinmemberMember 1122794523-Nov-14 2:56 
    GeneralNice image! PinmemberAlvaro Mendez21-Aug-01 14:28 
    GeneralRe: Nice image! PinmemberAlexandre GRANVAUD14-Jan-08 3:51 
    QuestionCan you publish shrink code??? Pinmemberobjects30-Mar-01 16:28 
    GeneralNon-Rectangular Stretching PinmemberSubbi Iyer21-Feb-01 0:26 
    GeneralRe: Non-Rectangular Stretching Pinmembermsg55514-Apr-06 11:24 
    GeneralRe: Non-Rectangular Stretching Pinmembergslin3-Nov-06 10:03 

    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.

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