Image Programming Learning Note 6--Image transpose

Source: Internet
Author: User

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
		}}
	}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.