The flaw in the logic is that you've got a single imageBlock
, and you overwrite the data in it several times before calling ForwardDCT(imageBlock)
.
You should change your loop structure to go in grid steps 8x8, then have two more loops that copy the content of the grid into imageBlock
, and call ForwardDCT(imageBlock)
on it rigth away:
for (var blockRow = 0 ; blockRow < rows ; blockRow += 8) {
for (var blockCol = 0 ; blockCol < yLimit ; blockCol += 8) {
for (var r = 0 ; r != 8 ; r++) {
for (var c = 0 ; c != 8 ; c++) {
// Add a check to see that blockRow+r, blockCol+c
// are inside the original image
imageBlock[r][c] = image_array[0].Data[blockRow+r, blockCol+c, 1];
}
}
blockList.Add(ForwardDCT(imageBlock));
}
}