that is the exact program . but this wil give you only basic cosine functions you have to multiply it to you information file by taking 8 bytes of the file at a time then you will get the dct of the file.
this is 2 d DCT . you can use i d DCT by simpling taking out one "for" loop from the 2 "for " loop pairs the in the program