From 2c8d3a969d11a5a40d34d51b5c0545267e7b6e90 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Mar 2013 07:16:53 +0000 Subject: patch [#34604] Add DPI read write for BMP and OpenEXR format --- source/blender/imbuf/intern/bmp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/imbuf/intern/bmp.c') diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index f19714dcd26..d850153f16e 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -126,6 +126,7 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char co int x, y, depth, skip, i; unsigned char *bmp, *rect; unsigned short col; + double xppm, yppm; (void)size; /* unused */ @@ -145,6 +146,8 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char co x = LITTLE_LONG(bmi.biWidth); y = LITTLE_LONG(bmi.biHeight); depth = LITTLE_SHORT(bmi.biBitCount); + xppm = LITTLE_LONG(bmi.biXPelsPerMeter); + yppm = LITTLE_LONG(bmi.biYPelsPerMeter); #if 0 printf("skip: %d, x: %d y: %d, depth: %d (%x)\n", skip, x, y, @@ -200,6 +203,8 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char co } if (ibuf) { + ibuf->ppm[0] = xppm; + ibuf->ppm[1] = yppm; ibuf->ftype = BMP; } @@ -251,8 +256,8 @@ int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags) putShortLSB(24, ofile); putIntLSB(0, ofile); putIntLSB(bytesize + BMP_FILEHEADER_SIZE + sizeof(infoheader), ofile); - putIntLSB(0, ofile); - putIntLSB(0, ofile); + putIntLSB((int)(ibuf->ppm[0] + 0.5), ofile); + putIntLSB((int)(ibuf->ppm[1] + 0.5), ofile); putIntLSB(0, ofile); putIntLSB(0, ofile); -- cgit v1.2.3