#1 DS sample DPI/resampling bug

Nik medved

Function FreeImage_ConvertTo24Bits resets DPI of dib to some constant value (indepndent of source image DPI), like 72 for me (current GDI device (monitor) resolution?). Noticed that during extending sample ds to provide arbitary images (thru OpenFileDialog), and getting very long resampling times (for 300 dpi from 2000x3000 -> 8000x1000 is a big piece of work).

solved easily by moving GetDotsPerMeterX/Y (together with new size calculations, anyway they are independent of DPI) before Convert call.


  • Nik medved

    Nik medved - 2009-02-08

    and, by the way, these resize calculations (to follow DPI settings) are affected by awesome rounding error:
    WORD unNewWidth = WORD(m_nSourceWidth /(WORD)((float)res/39.37 + 0.5)* m_fXResolution);

    (WORD)((float)res/39.37 + 0.5) gets the original DPI as integer (word) number, so we divide original resolution (integer) by DPI (integer) and in worse case we can get up to round("original DPI") error in size calculation.
    I'm not sure, if this by design or not, but looks strange ;)

  • Jim Watters

    Jim Watters - 2009-06-12
    • assigned_to: nobody --> fharju
  • Rich Taylor

    Rich Taylor - 2011-06-07

    Found this (the hard way...) - FreeImage_ConvertTo24Bits resolution handling appears to be fixed in FreeImage v3.15.0 (though there is no mention in the FI change log)


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks