Hi Herfried,
It sounds like a lot of work, and it is, but, as it's all being done at
the lowest level possible, it's very fast.
The disadvantage of pixel setting and getting is the travelling up and
down the layers of abstraction from VB through Win Api down to the boys who
are up to their knees in pixels. There's <so much> wrapping that it is, as you
said, really slow. I would imagine that the ratio is huge - several hundred
instructions per pixel.
The folding-of-complete-bitmaps method does more actual work on each
pixel, but with far less running up and down the layers ladder. Once down at
the blitting level, only a few instructions would be required per pixel,
further aided by the code being in the CPU's cache.
[Since writing the above, I went off to do some testing...]
I did some timing tests comparing the setting of a bitmap to a given
colour using FillRectangle versus the same using SetPixel. The differences
depend on the size of the bitmap: At 20x20 the Fill was 17 times quicker. At
100x100 it was 240 times quicker. At 400x400 it was 640 times quicker.
Folding operates on the binary-chop principle, eg 32 wide requires 5
folds, 1024 wide requires only double the effort. Given those figures, on a
largish bitmap folding is likely to be considerably faster and the bigger the
bitmap, the better the ratio.
But, hey, when you can use a Tag to compare two images, lol, both these
methods look very sledgehammer-like
Regards,
Fergus