The Tricky Blits
Our PixBlt Method works fine when the source and destination regions do not overlap.
But, when these two regions do overlap we need to take special care to avoid copying
the wrong pixels. The best way to handle this situation is by changing the iteration direction of
the copy loops to avoid problems.
|
The iteration direction must always be opposite of the direction of the block's movement
for each axis. You could write a fancy loop which handles all four cases. However, this code is
usually so critical to system performace that, generally, code is written for all 4 cases and
called based on a test of the source and destination origins. In fact the code is usually unrolled.
|
|