Click here to Skip to main content
11,575,921 members (57,444 online)
Click here to Skip to main content

High quality image rotation (rotate by shear)

, 9 Jan 2000 209.2K 8.1K 79
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

    You may also be interested in...

    Comments and Discussions

     
    GeneralMy vote of 1 Pin
    sujeshsasi5-Mar-09 18:57
    membersujeshsasi5-Mar-09 18:57 
    Generalhave bugs in the demo Pin
    WeiHua zhang24-Oct-07 18:06
    memberWeiHua zhang24-Oct-07 18:06 
    Generala show stopper bug Pin
    Xiaotian Guo7-Jul-03 20:12
    memberXiaotian Guo7-Jul-03 20:12 
    GeneralRe: a show stopper bug Pin
    Jim the Bad11-Aug-05 6:06
    memberJim the Bad11-Aug-05 6:06 
    GeneralRe: a show stopper bug Pin
    John Smith26-Apr-15 2:51
    memberJohn Smith26-Apr-15 2:51 
    GeneralRotation of BMP Pin
    Sandeep11_163-Jun-03 4:21
    memberSandeep11_163-Jun-03 4:21 
    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 Pin
    antontreskunov24-Apr-03 15:03
    memberantontreskunov24-Apr-03 15:03 
    GeneralRe: Speed optimized version Pin
    yyt_yyt8-Jul-03 22:20
    memberyyt_yyt8-Jul-03 22:20 
    GeneralRe: Speed optimized version Pin
    Anonymous12-Jul-03 8:39
    sussAnonymous12-Jul-03 8:39 
    GeneralRe: Speed optimized version Pin
    pmidd17-Oct-03 9:23
    memberpmidd17-Oct-03 9:23 
    GeneralRe: Speed optimized version Pin
    antontreskunov21-Oct-03 6:55
    memberantontreskunov21-Oct-03 6:55 
    GeneralRe: Speed optimized version Pin
    Alexandre GRANVAUD14-Jan-08 2:52
    memberAlexandre GRANVAUD14-Jan-08 2:52 
    Questionhow to get the ppm image from a bitmap? Pin
    AlanShen19-Apr-03 17:11
    memberAlanShen19-Apr-03 17:11 
    AnswerRe: how to get the ppm image from a bitmap? Pin
    tyjiang30-Jul-08 15:30
    membertyjiang30-Jul-08 15:30 
    GeneralBMP Image Rotation about its own axes Pin
    Vaibhav Sanghavi24-Apr-02 20:26
    memberVaibhav Sanghavi24-Apr-02 20:26 
    GeneralRe: BMP Image Rotation about its own axes Pin
    Tili28-Sep-02 10:19
    memberTili28-Sep-02 10:19 
    GeneralAlgorithm Pin
    Neil Younusov28-Feb-02 4:22
    memberNeil Younusov28-Feb-02 4:22 
    GeneralRe: Algorithm Pin
    land_lubber1-Oct-02 7:44
    memberland_lubber1-Oct-02 7:44 
    GeneralRe: Algorithm Pin
    Peter Merrill14-Jan-03 18:47
    memberPeter Merrill14-Jan-03 18:47 
    GeneralRe: Algorithm Pin
    Member 1122794523-Nov-14 1:56
    memberMember 1122794523-Nov-14 1:56 
    GeneralNice image! Pin
    Alvaro Mendez21-Aug-01 13:28
    memberAlvaro Mendez21-Aug-01 13:28 
    GeneralRe: Nice image! Pin
    Alexandre GRANVAUD14-Jan-08 2:51
    memberAlexandre GRANVAUD14-Jan-08 2:51 
    QuestionCan you publish shrink code??? Pin
    objects30-Mar-01 15:28
    memberobjects30-Mar-01 15:28 
    GeneralNon-Rectangular Stretching Pin
    Subbi Iyer20-Feb-01 23:26
    memberSubbi Iyer20-Feb-01 23:26 
    GeneralRe: Non-Rectangular Stretching Pin
    msg55514-Apr-06 10:24
    membermsg55514-Apr-06 10:24 

    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.150603.1 | Last Updated 10 Jan 2000
    Article Copyright 2000 by Eran Yariv
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid