Click here to Skip to main content
6,822,613 members and growing! (19,511 online)
Email Password   helpLost your password?
Multimedia » General Graphics » General     Intermediate

High quality image rotation (rotate by shear)

By Eran Yariv

Rotating images using shear
VC6, MFC, Dev
Posted:9 Jan 2000
Views:147,838
Bookmarked:64 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
25 votes for this article.
Popularity: 6.04 Rating: 4.32 out of 5
1 vote, 14.3%
1

2
1 vote, 14.3%
3

4
5 votes, 71.4%
5
  • 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


    Member

    Location: United States United States

    Other popular General Graphics articles:

    • A flexible charting library for .NET
      Looking for a way to draw 2D line graphs with C#? Here's yet another charting class library with a high degree of configurability, that is also easy to use.
    • CxImage
      CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
    • 3D Pie Chart
      A class library for drawing 3D pie charts.
    • Barcode Image Generation Library
      This library was designed to give an easy class for developers to use when they need to generate barcode images from a string of data.
    • ImageStone
      An article on a library for image manipulation.
    Article Top
    You must Sign In to use this message board.
    FAQ FAQ 
     
    Noise Tolerance  Layout  Per page   
     Msgs 1 to 25 of 27 (Total in Forum: 27) (Refresh)FirstPrevNext
    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  
    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  
    Generalhow to get the ppm image from a bitmap? PinmemberAlanShen18:11 19 Apr '03  
    GeneralRe: 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  
    GeneralCan 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  
    GeneralRelated Paper ?? Pinmemberlooker22:47 25 Jan '01  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

    PermaLink | Privacy | Terms of Use
    Last Updated: 9 Jan 2000
    Editor: Chris Maunder
    Copyright 2000 by Eran Yariv
    Everything else Copyright © CodeProject, 1999-2010
    Web20 | Advertise on the Code Project