Search code examples
c#jpeglibjpegsteganographydct

height_in_blocks in libJPEG in C#


I Need to access DCT coefficients and apply LSB in

BitMiracle.LibJpeg.Classic.jvirt_array<BitMiracle.LibJpeg.Classic.JBLOCK>[] JBlock = oJpegDecompress.jpeg_read_coefficients();

the problem is i can't access

oJpegDecompress.Comp_info[1].Height_in_blocks

because it's non-public variable.

oJpegDecompress.Comp_info[1].Width_in_blocks 

is accessible. so now how can i iterate through JBlock to manipulate coefficients if i don't have the number of blocks in height???


Solution

  • There will be first 3 array with usable data in JBlock for colored image.wblocks0 and hblocks0 are width and height for first 1 array.wblocks1 and hblocks1 are width and height for 2nd and 3rd array.

            int calh = (int)Math.Ceiling(img.Height / 8.0);
            int calw = (int)Math.Ceiling(img.Width / 8.0);
            int wblocks0 = calw % 2 == 0 ? calw : calw + 1;
            int hblocks0 = calh % 2 == 0 ? calh : calh + 1;
            int wblocks1 = calw % 2 == 0 ? calw / 2 : (calw + 1) / 2;
            int hblocks1 = calh % 2 == 0 ? calh / 2 : (calh + 1) / 2;