diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
commit | a42ba82f638e481d7fd3c3ed2ba05c331ef6717e (patch) | |
tree | 81a2b9221799707b49b74a5df8bb3ff964ba78bd /source/blender/imbuf/intern/png.c | |
parent | 7afbdff1b6c348227e652e1c3071ab7ba7c91c44 (diff) | |
parent | a73dd3476e7d180d3320afc04d218ce22f2f3bfc (diff) |
Merged changes in the trunk up to revision 50829.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
Also addressed code inconsistency due to changes in the trunk revision 50628 (color
management with OCIO) and 50806 (UV project material). OCIO-related changes are marked
OCIO_TODO as in some other files modified in revision 50628.
Diffstat (limited to 'source/blender/imbuf/intern/png.c')
-rw-r--r-- | source/blender/imbuf/intern/png.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 92cd9622849..6310d8e105f 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -47,6 +47,9 @@ #include "IMB_metadata.h" #include "IMB_filetype.h" +#include "IMB_colormanagement.h" +#include "IMB_colormanagement_intern.h" + typedef struct PNGReadStruct { unsigned char *data; unsigned int size; @@ -302,7 +305,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return(1); } -ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) +ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; png_structp png_ptr; @@ -317,11 +320,13 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) unsigned char *from, *to; unsigned short *from16; float *to_float; - float tmp[4]; int i, bytesperpixel; if (imb_is_a_png(mem) == 0) return(NULL); + /* both 8 and 16 bit PNGs are default to standard byte colorspace */ + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { @@ -389,10 +394,6 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) if (ibuf) { ibuf->ftype = PNG; - if (bit_depth == 16) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - else - ibuf->profile = IB_PROFILE_SRGB; if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) { int unit_type; @@ -443,37 +444,33 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) switch (bytesperpixel) { case 4: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = from16[0] / 65535.0; - tmp[1] = from16[1] / 65535.0; - tmp[2] = from16[2] / 65535.0; - tmp[3] = from16[3] / 65535.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = from16[0] / 65535.0; + to_float[1] = from16[1] / 65535.0; + to_float[2] = from16[2] / 65535.0; + to_float[3] = from16[3] / 65535.0; to_float += 4; from16 += 4; } break; case 3: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = from16[0] / 65535.0; - tmp[1] = from16[1] / 65535.0; - tmp[2] = from16[2] / 65535.0; - tmp[3] = 1.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = from16[0] / 65535.0; + to_float[1] = from16[1] / 65535.0; + to_float[2] = from16[2] / 65535.0; + to_float[3] = 1.0; to_float += 4; from16 += 3; } break; case 2: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0; - tmp[3] = from16[1] / 65535.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = to_float[1] = to_float[2] = from16[0] / 65535.0; + to_float[3] = from16[1] / 65535.0; to_float += 4; from16 += 2; } break; case 1: for (i = ibuf->x * ibuf->y; i > 0; i--) { - tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0; - tmp[3] = 1.0; - srgb_to_linearrgb_v4(to_float, tmp); + to_float[0] = to_float[1] = to_float[2] = from16[0] / 65535.0; + to_float[3] = 1.0; to_float += 4; from16++; } break; |