High quality image rotation (rotate by shear)
Posted
by Eran Yariv
on May 1st, 1999
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.

Comments
Most lazy coder
Posted by Legacy on 09/23/2002 12:00amOriginally 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.
ReplyBugs
Posted by Legacy on 04/26/2002 12:00amOriginally posted by: Grohotov Andrey
Reply
Rotation at the centre of true colour image
Posted by Legacy on 01/25/2002 12:00amOriginally 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)
ReplyPPM tool
Posted by Legacy on 07/23/2001 12:00amOriginally posted by: wrsun0413
http://cust.nol.at/ppee/SLOWVIEW/dload.html
ReplyHow cam i use it in VB
Posted by Legacy on 07/04/2001 12:00amOriginally 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
Replywhat is ppm?
Posted by Legacy on 04/20/2001 12:00amOriginally posted by: Oh Sun
What is ppm? Is a graphic file format?
ReplyWhere can i get ppm file?
RotateByShear doesn't work with white background color
Posted by Legacy on 07/22/1999 12:00amOriginally posted by: Laurent MOTTAIS
if you change your code by
ReplyCOLORREF *pDst = Rot.AllocAndRotate (
Src.m_Bits,
Src.m_Size,
dAngle,
&sDst,
RGB(255,255,255)
);
the destination file is not correctly rotate !..
Where to find MSVCP60.DLL?
Posted by Legacy on 05/05/1999 12:00amOriginally posted by: lsteo
ReplyPPM?
Posted by Legacy on 05/04/1999 12:00amOriginally 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