Image Processing
Rotate Pixels  Lab Report
How to Rotate a Bitmap Multiples of 90 degrees with the Pixels Property
The Glyph at the right above was rotated 90 degrees counterclockwise.

Purpose
The purpose of this program, RotatePixels.EXE, is to show how to rotate a bitmap multiples of 90 degrees with the Pixels Property.

Materials and Equipment

Software Requirements
Windows 95
Delphi 3 (to recompile)
RotatePixels.EXE

Hardware Requirements
VGA display

Procedure

  1. Double click on the RotatePixels.EXE icon to start the program.
  2. Select one of the speedbuttons, 0, 90, 180, 270, to rotate the glyph.

Discussion
Rotations that are multiples of 90 degrees can be formed simply by manipulating subscripts with the Pixels property.
See the following table:

Rotation[degrees counterclockwise] Subscript Manipulation using Pixels
0 Out[i, j] = In[i, j]
90 Out[j, Right-i-1] = In[i, j]
180 Out[Right-i-1, Bottom-j-1] = In[i, j]
270 Out[Bottom-j-1,i] = In[i, j]

Conclusions
The Pixels property can be used in Delphi 1-3 to manipulate pixel data, but because of considerable Windows overhead, any use of Pixels will result in fairly slow code for bitmaps of any size.

A bitmap can be rotated much more quickly using the Delphi 3 Scanline property. See the RotateScanline and FlipReverseRotate examples. The FlipReverseRotate example uses the same general ideas as this example.


Keywords
Bitmap Rotation, Pixels property

Download
Delphi 3 Source and EXE (121 KB): RotatePixels.ZIP

Compiles without any changes in D4. D3 EXE is 226 KB, while D4 EXE is 308 KB.


Updated 18 Feb 2002


since 1 Nov 1998