Pixel-level processing of images

Source: Internet
Author: User
You can use some methods of the tbitmaputil class to process bitmaps in pixels. Including:
Void begin (const tpoint & aposition): Set the current pixel location to be processed and lock the heap.
Void end (): Unlock the heap.
Void setpos (const tpoint & aposition): Change the current pixel position to aposition.
Void incxpos (): Auto-increment the current X coordinate by 1.
Void decxpos (): Subtract the current X coordinate from 1.
Void incypos (): Increase the current y coordinate by 1.
Void decypos (): Subtract the current y coordinate from 1.
Tuint32 getpixel () const: Obtain the RGB value of the current pixel.
Void setpixel (tuint32 avalue): Sets the RGB value of the current pixel.
The following describes how to use the tbitmaputil class by reversing a bitmap and writing it into another bitmap.
Use the previously generated and read bitmap: cfbsbitmap * iimage1 and cfbsbitmap * iimage2. Here, the length and width of iimage2 are greater than that of iimage1.
First, associate the bitmap to be operated:
Tbitmaputil bitmap1util (ibitmap1 );
Tbitmaputil bitmap2util (ibitmap2 );
Next, start bitmap operations and set the initial point to (0, 0 ):
Bitmap1util. Begin (tpoint (0, 0 ));
Bitmap2util. Begin (tpoint (0, 0 ));
The following code reads from ibitmap1 pixel by pixel and writes it to ibitmap2:
Tsize insize = ibitmap1-> sizeinpixels ();
Tint xpos;
For (tint ypos = 0; ypos <insize. iheight; ypos ++)
{
Bitmap1util. setpos (tpoint (0, ypos ));
Bitmap2util. setpos (tpoint (ypos, 0 ));
For (xpos = 0; xpos <insize. iwidth; xpos ++)
{
Bitmap2util. setpixel (bitmap1util );
Bitmap1util. incxpos ();
Bitmap2util. incypos ();
}
}
End the operation and clear the stack.
Bitmap1util. End ();
Bitmap2util. End ();

In this way, we have completed the work of reversing iimage1 and writing it into iimage2.

 

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.