diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-28 17:29:33 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-28 17:29:33 +0400 |
commit | b9ff5840a617ec836f2d09bb0f04d60e5c3b8f67 (patch) | |
tree | 8a196777f4ee32e3ee089c12b667caa2c82dec75 /source/blender/editors/screen/glutil.c | |
parent | 1f02209957fc8afde957b48f1be41fc399a725b0 (diff) |
Code refactoring: add unified image buffer functions for doing float => byte,
byte => float, float => float, byte => byte conversions with profile, dither
and predivide. Previously code for this was spread out too much.
There should be no functional changes, this is so the predivide/table/dither
patches can work correctly.
Diffstat (limited to 'source/blender/editors/screen/glutil.c')
-rw-r--r-- | source/blender/editors/screen/glutil.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 0bba9838005..8f04940efd6 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -45,6 +45,9 @@ #include "BIF_gl.h" #include "BIF_glutil.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + #ifndef GL_CLAMP_TO_EDGE #define GL_CLAMP_TO_EDGE 0x812F #endif @@ -563,17 +566,17 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void * void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int UNUSED(row_w), float *rectf, int do_gamma_correct) { unsigned char *rect32; + int profile_from= (do_gamma_correct)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB; + int predivide= 0; /* copy imgw-imgh to a temporal 32 bits rect */ if(img_w<1 || img_h<1) return; rect32= MEM_mallocN(img_w*img_h*sizeof(int), "temp 32 bits"); - if (do_gamma_correct) { - floatbuf_to_srgb_byte(rectf, rect32, 0, img_w, 0, img_h, img_w); - } else { - floatbuf_to_byte(rectf, rect32, 0, img_w, 0, img_h, img_w); - } + IMB_buffer_byte_from_float(rect32, rectf, + 4, 0, IB_PROFILE_SRGB, profile_from, predivide, + img_w, img_h, img_w, img_w); glaDrawPixelsSafe(fx, fy, img_w, img_h, img_w, GL_RGBA, GL_UNSIGNED_BYTE, rect32); |