JPEG_PlotScaled anomaly
Chris Johnson (125) 825 posts |
I was recently passed some ‘problem’ jpegs to investigate. These jpegs loaded and displayed in some RISC OS apps eg DPlngScan, but caused other apps to either freeze the machine, eg OvationPro, or the apps exited ignominiously eg Draw which exited with a ‘divide by zero’ error. Examination of these JPEGs showed them to be in JFIF format with standard headers. I came to the conclusion that the root cause was (a) the app was using the OS SWI JPEG_PlotScaled or related (I know OPro does, DPScan doesn’t) and (b) the dot density in the jpeg was specified as dots per cm, rather than dots per inch. The JFIF header contains a) a single byte flag for image density units. Values are 0 for ‘use hardware default’, 1 for dpi, and 2 for dpcm. b) two two byte ints for the x density and y density values. The ‘bad jpegs’ had the image density specified as 37 dpcm, which is about 93 dpi. Using Zap in ‘byte’ edit mode, it was possible to overwrite the appropriate three bytes in the header to change 37 dpcm to 90 or 96 dpi. The jpeg then displayed normally in eg !Draw. The reverse could also be done, i.e. take a ‘normal’ 90 dpi jpeg which displayed without problem, and change the image density to 37 dpcm, whereupon Draw crashed with the divide by zero error on attempting to load the modified jpeg file. It looks to me as if the OS jpeg plotting routines are doing something wrong when the image density is specified in dots per cm. All the tests I did were on ARMX6 or RapidO IGEPv5 hardware running recent RISC OS 5, The user who received the files initially used ARMini, and Has anyone else come across this problem? |
Steve Pampling (1551) 8172 posts |
Never been able to pin the reason down like you but I’ve seen various files that cause some applications to go base over apex but work perfectly in other apps. Just an observation, but do you think that the jpeg plotting routines are possibly using just the lower bit? i.e. it treats the 00 as 0, 01 as 1 and 10 as 0 instead of 0, 1, 2 respectively. |
Ronald May (387) 407 posts |
Has anyone else come across this problem? In the approximate subject, JFIF headers do not work in Postscript2 and have to be stripped. |