ImBuf: calculate the JPEG DPI with double precision
These were calculated as floats then converted to doubles, loosing precision unnecessarily.
This commit is contained in:
parent
bdbf1871ec
commit
e3b77cf08a
|
@ -546,7 +546,7 @@ bool IMB_initImBuf(ImBuf *ibuf, uint x, uint y, uchar planes, uint flags)
|
|||
/* float option, is set to other values when buffers get assigned. */
|
||||
ibuf->channels = 4;
|
||||
/* IMB_DPI_DEFAULT -> pixels-per-meter. */
|
||||
ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f;
|
||||
ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254;
|
||||
|
||||
if (flags & IB_rect) {
|
||||
if (imb_addrectImBuf(ibuf) == false) {
|
||||
|
|
|
@ -44,4 +44,4 @@
|
|||
# define BIG_LONG SWAP_LONG
|
||||
#endif
|
||||
|
||||
#define IMB_DPI_DEFAULT 72.0f
|
||||
#define IMB_DPI_DEFAULT 72.0
|
||||
|
|
|
@ -421,12 +421,12 @@ static ImBuf *ibJpegImageFromCinfo(
|
|||
/* Density_unit may be 0 for unknown, 1 for dots/inch, or 2 for dots/cm. */
|
||||
if (cinfo->density_unit == 1) {
|
||||
/* Convert inches to meters. */
|
||||
ibuf->ppm[0] = cinfo->X_density / 0.0254f;
|
||||
ibuf->ppm[1] = cinfo->Y_density / 0.0254f;
|
||||
ibuf->ppm[0] = double(cinfo->X_density) / 0.0254;
|
||||
ibuf->ppm[1] = double(cinfo->Y_density) / 0.0254;
|
||||
}
|
||||
else if (cinfo->density_unit == 2) {
|
||||
ibuf->ppm[0] = cinfo->X_density * 100.0f;
|
||||
ibuf->ppm[1] = cinfo->Y_density * 100.0f;
|
||||
ibuf->ppm[0] = double(cinfo->X_density) * 100.0;
|
||||
ibuf->ppm[1] = double(cinfo->Y_density) * 100.0;
|
||||
}
|
||||
|
||||
ibuf->ftype = IMB_FTYPE_JPG;
|
||||
|
|
Loading…
Reference in New Issue