// Calculate scale so we only decode what we need
if (desiredWidth && desiredHeight) {
int wdeg = imageWidth / desiredWidth;
int hdeg = imageHeight / desiredHeight;
dec.scale_num = 1;
dec.scale_denom = std::max(1, std::min(std::min(wdeg, hdeg), 8));
}
The code to compute the scaling ratio is:
However, the following article says:
_Just set the desired scaling factor of N/8 (N=1...16) in the djpeg -scale option or via the
scale_num/scale_denom
variables in library application._So I guess you should set the scale_denom to 8, and then compute the
scale_num
so thatimageWidth * scale_num / 8 <= desiredWidth
?