2016-02-18 2 views
2

je besoin d'accéder à des coefficients TCD et appliquer LSBheight_in_blocks à Libjpeg en C#

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

le problème est que je ne peux pas accéder

oJpegDecompress.Comp_info[1].Height_in_blocks 

parce qu'elle est variable non-publique.

oJpegDecompress.Comp_info[1].Width_in_blocks 

est accessible. alors maintenant comment puis-je itérer à travers JBlock pour manipuler les coefficients si je n'ai pas le nombre de blocs en hauteur ???

Répondre

2

Il y aura 3 premiers tableaux avec des données utilisables dans JBlock pour l'image colorée. Wblocks0 et hblocks0 sont la largeur et la hauteur pour le premier array.wblocks1 et hblocks1 sont largeur et hauteur pour les tableaux 2nd et 3rd.

 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;