Well let's start with a little simple math...the outer loop runs 32 * 20 = 640 times, and each of those times the inner loop also runs 640 times...so that leads to 640 * 640 = 409,600 iterations of the code. This is not going to be fast, unless your operations are extremely simple (even then, it might not me).
My recommendation is this: find a way to cut down on the number of iterations. I don't fully understand what you're trying to do here, but there's a big red flag I see: the BlockList. You should only hit upon each block at most once.
However, if I am understanding your code and description, the fix should be fairly simple: replace
i++
with
i += ID.BlockSize
(and the same with
j
), because at most you should only need to check the pixel in every 32nd row and column (or whatever the block size is). If might seem a little weird at first, but if you think about it this would hit every block once and only once. Then you should be able to remove the BlockList completely (every call to BlockList.Contains can take as many comparisons as there are items in the list, this will slow you down even more).
If you feel you must still use the BlockList (or I'm completely misunderstanding what's going on), at least use a
HashSet[
^] instead of a List, it should be much faster at look-ups.