Transpose (transpose) refers to swapping x, y coordinates, and the transpose of Figure 2.2 is shown in Figure 2.15.
Figure 2.2
Figure 2.15 The transpose of Figure 2.2
Note that the transpose and rotation 900 is different, do not believe you can try: How to rotate, figure 2.2 also can not turn out the figure 2.15来. In addition, the width and height of the image after the transpose is swapped. Transpose the transformation matrix is simple:
(2.12)
The source code of the mirror transformation is as follows, because the program is very similar to the one in which it is rotated, and the notes in the program are simple:
Because a lot of code and previous repetition, so only the main function code (Win32 console program)
void transpose ()
{
int height = bmpinfoheader.biheight;
int width = bmpinfoheader.biwidth;
int imgsize = bmpinfoheader.bisizeimage;
Aspect changed after transpose
bmpinfoheader.biheight = width;
bmpinfoheader.biwidth = height;
memset (pnewbmpdata,0,sizeof (unsigned char) *imgsize);
int linebyte = (Width * 8 + +)/+ * 4; Number of bytes per line of pixels
int newlinebyte = (Height * 8 + +)/4 *; New linebyte for
(int i = 0, i < height; i++)
{for
(int j = 0; J < width; j + +)
{
* (pnewbmp Data + (Width-1-j) *newlinebyte + i) = * (Pbmpdata + (height-1-i) *linebyte + j); Transpose
}}
}