How to compute Discrete Cosine Transform
You don't need to split image into blocks. The DCT equation can be applied to the whole image. The block division has been chosen for JPEG standard partly because DCT was costly to compute in the past (but that's not the only reason).

You can choose any size of block (including the single block, which is the image itself), then split image into the blocks and apply DCT for every block separately.

After applying DCT on, say 8x8 block (matrix), you get another 8x8 block, but with DCT coefficients (not pixel values). You normalize them, quantize them and then encode. The coefficients in the bottom right corner of the block (I think) can be stripped off to achieve compression (the article about JPEG describes this well).

It is very similar to DFT, which uses sine and cosine bases. The DCT uses cosine bases only. The DC component is located in the top-left corner of transformed image/block and in DFT the DC component is in the middle of the image/block.