In this paper, we present a data hiding scheme that embeds the secret data into the compression codes of the host image. The compression codes are associated with the visual patterns appearing in image blocks and are computed through a histogram analysis of residual blocks of the host image. The hiding capacity for each compressed block is not fixed and varies with its block type. Blocks with low visual activity hide more data than those with high visual activity. Experimental results confirm that the proposed technique can provide high data capacity within the compression file with acceptable image quality of the stego-images.