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.