when the logic of the ranging scroll is almost written, it is found that the previously written bitmap has some problems with the Code in the display table, therefore, a function is rewritten to get a map directly on bitmap24_ptr Based on the surface size and Input coordinates. The complete code is provided first:
Int pickbitmap (lpdirectdrawsurface7 lpdds, bitmap24_ptr bitmap, long ddswidth, long ddsheight, long CX, long CY) <br/>{< br/> long bitmapwidth = Bitmap-> infoheader. biwidth; <br/> long bitmapheight = Bitmap-> infoheader. biheight; </P> <p> ddsurfacedesc2 ddsd; <br/> ddraw_init_struct (ddsd); <br/> lpdds-> lock (null, & ddsd, expires | ddlock_wait, null); <br/> int mempitch = ddsd. lpitch; <br/> uchar * ddsbuffer = (uchar *) (ddsd. lpsurface); </P> <p> for (long DY = 0, by = Cy; dy <ddsheight; ++ dy, ++) <br/> {<br/> memcpy (ddsbuffer + dy * mempitch, bitmap-> buffer + cx * 4 + by * bitmapwidth * 4, 4 * ddswidth ); <br/>}</P> <p> // displaymemory (ddsbuffer, mempitch * ddsheight); </P> <p> lpdds-> unlock (null ); </P> <p> return 1; <br/>}
This function was called to complete the unit test for one afternoon ~ Ah, there is no way to achieve low IQ.
This is also the first debugging of large-scale memory content after I switched to C/C ++. I still don't know what tools are available, so I wrote a plug-in first, the displaymemory function annotated in the above Code. The Code is as follows:
Char hextable [16] = {'0', '1', '2', '3', '4', '5', '6', '7 ', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F '}; </P> <p> void displaymemory (uchar * buffer, Long SIZE) <br/>{< br/> char * MSG = (char *) malloc (size * 3 + 1); </P> <p> for (long I = 0; I <size; ++ I) <br/>{< br/> char C1, C2, C3; <br/> C1 = hextable [(INT) (buffer [I])/16]; <br/> C2 = hextable [(INT) (buffer [I]) % 16]; <br/> C3 = ''; <br/> MSG [I * 3] = C1; <br/> MSG [I * 3 + 1] = c2; <br/> MSG [I * 3 + 2] = C3; <br/>}< br/> MSG [size * 3] = '/0 '; </P> <p> MessageBox (null, MSG, "Memory", mb_ OK); </P> <p> free (MSG); <br/>}
After the problem is solved, you can have a good sleep.