High quality image rotation (rotate by shear)

Rotation sample:

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).

The 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:

  • Provides 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.
Next, 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.

Download template - 4 KB

Download sample command line application - 21 KB



Comments

  • Jordan shoes mentioned Gene to go for the brand, a segment of Nike

    Posted by TaddyGaffic on 04/22/2013 02:35pm

    In focus groups conducted at 80 community-based organizations around the country, Motivational Educational Entertainment of Philadelphia [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] identified disturbing trends among youths ages 16 to 20. The "Just Say No" message of abstinence-only campaigns has been lost on this group of young people, who grew up during an era when the hip-hop sensibility of getting cash and clothes did not incorporate values of conscientious sexual behavior or social responsibility. Rappers who mingle [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] with glamorous-looking half-naked women rarely mention contraception while they're listing the number of compromising sexual situations they've been in lately. There are number of good brands in the market like Adidas, Nike, Reebok, Asics, Brooks, Puma etc. Most of these brands have shoes tailored for professional and amateur tennis players. New advanced technologies have made these shoes more player-friendly. After that, I eventually like to try to get down to the 150-160 range. I not entirely sure if that a healthy number for a gal my height or not, and I haven looked into it. But, I know that when I was 180 I still didn feel that [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] fit, so I think an extra 20 or so will help with that.. Lotto sneakers selling price are generally liable along with using the form of sneakers you choose on. Your Lotto sneakers established fact because of their style along with good quality plus the create. That they create sneakers coming from all varieties much like the loafers,Puma II Shoes, new sandals, sneakers along with task tennis shoes or anything else

    Reply
  • Most lazy coder

    Posted by Legacy on 09/23/2002 12:00am

    Originally posted by: Akash Kava

    No GUI, no facility for direct Bitmap images.. you need to design your code in better way to make it template free, templates are old fasion of designs.

    Reply
  • Bugs

    Posted by Legacy on 04/26/2002 12:00am

    Originally posted by: Grohotov Andrey

    The original code does not work with any colour of a background 
    
    and in function VertSkew one column is lost

    In functions HorizSkew and VertSkew
    1)
    To replace COLORREF pxlOldLeft = clrBack;
    on COLORREF pxlOldLeft = RGB (BYTE ( double (GetRValue (clrBack)) * dWeight ),
    BYTE ( double (GetGValue (clrBack)) * dWeight ),
    BYTE ( double (GetBValue (clrBack)) * dWeight ));
    2)
    To replace
    if (i < sDst.cx)
    {
    // If still in image bounds, put leftovers there
    SetRGB (pDst, sDst, i, uRow, pxlOldLeft);
    }
    on
    if (i < sDst.cx)
    {
    COLORREF pxlLeft = RGB (BYTE ( double (GetRValue (clrBack)) * dWeight ),
    BYTE ( double (GetGValue (clrBack)) * dWeight ),
    BYTE ( double (GetBValue (clrBack)) * dWeight ));
    COLORREF pxlDst = RGB ( GetRValue (clrBack) - ( GetRValue (pxlLeft) - GetRValue (pxlOldLeft) ),
    GetGValue (clrBack) - ( GetGValue (pxlLeft) - GetGValue (pxlOldLeft) ),
    GetBValue (clrBack) - ( GetBValue (pxlLeft) - GetBValue (pxlOldLeft) ));
    SetRGB (pDst, sDst, i, uRow, pxlDst);
    }

    In functions VertSkew
    1)
    To replace
    // Go to bottom point of skew
    i = iYPos;
    on
    // Go to bottom point of skew
    i = iYPos + 1;

    Reply
  • Rotation at the centre of true colour image

    Posted by Legacy on 01/25/2002 12:00am

    Originally posted by: halim

    Could you give examples of rotating about another point in the true colour image (e.g. the center of the image while maintainig the original size of the input image)

    Reply
  • PPM tool

    Posted by Legacy on 07/23/2001 12:00am

    Originally posted by: wrsun0413

    http://cust.nol.at/ppee/SLOWVIEW/dload.html

    Reply
  • How cam i use it in VB

    Posted by Legacy on 07/04/2001 12:00am

    Originally posted by: Kanhai Chhugani

    Hi I would like to use this in VB, can u provide any thing like that....

    such as a VB class file or a COM Dll file etc....

    Thanks

    Kanhai Chhugani

    Reply
  • what is ppm?

    Posted by Legacy on 04/20/2001 12:00am

    Originally posted by: Oh Sun

    What is ppm? Is a graphic file format?
    Where can i get ppm file?

    Reply
  • RotateByShear doesn't work with white background color

    Posted by Legacy on 07/22/1999 12:00am

    Originally posted by: Laurent MOTTAIS

    if you change your code by
    COLORREF *pDst = Rot.AllocAndRotate (
    Src.m_Bits,
    Src.m_Size,
    dAngle,
    &sDst,
    RGB(255,255,255)
    );
    the destination file is not correctly rotate !..

    Reply
  • Where to find MSVCP60.DLL?

    Posted by Legacy on 05/05/1999 12:00am

    Originally posted by: lsteo

    MSVCP60.DLL not found! Where can I get it?
    

    Reply
  • PPM?

    Posted by Legacy on 05/04/1999 12:00am

    Originally posted by: Bill Oatman

    Looks interesting, but how about adding a 'LoadBMP' function to CDIB so bitmaps can be loaded. I still haven't found a graphics package that will save in PPM format.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • You probably have several goals for your patient portal of choice. Is "community" one of them? With a bevy of vendors offering portal solutions, it can be challenging for a hospital to know where to start. Fortunately, YourCareCommunity helps ease the decision-making process. Read this white paper to learn more. "3 Ways Clinicians can Leverage a Patient Portal to Craft a Healthcare Community" is a published document owned by www.medhost.com

  • The exponential growth of data, along with virtualization, is bringing a disruptive level of complexity to your IT infrastructure. Having multiple point solutions for data protection is not the answer, as it adds to the chaos and impedes on your ability to deliver consistent SLAs. Read this white paper to learn how a more holistic view of the infrastructure can help you to unify the data protection schemas by properly evaluating your business needs in order to gain a thorough understanding of the applications …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds