diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-20 19:34:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-20 19:34:40 +0400 |
commit | 0198df7956125180d5b9c50638a0778a3236d88f (patch) | |
tree | aab6bbacff4d047039c5fa408eac68006928c8f9 /source/blender/editors/space_image | |
parent | b3938cee638101df97e056cdf19891be84340142 (diff) | |
parent | 172685322638f92906ef3baf39d92399903bdfb3 (diff) |
svn merge ^/trunk/blender -r43554:43564
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 40 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 8 |
2 files changed, 28 insertions, 20 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 41fc861f8e4..9ec9c5ef0e0 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -111,7 +111,8 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) } /* used by node view too */ -void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4], int *zp, float *zpf) +void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y, + const unsigned char cp[4], const float fp[4], int *zp, float *zpf) { char str[256]; float dx= 6; @@ -211,39 +212,46 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int /* color rectangle */ if (channels==1) { - if (fp) + if (fp) { col[0] = col[1] = col[2] = fp[0]; - else if (cp) + } + else if (cp) { col[0] = col[1] = col[2] = (float)cp[0]/255.0f; - else + } + else { col[0] = col[1] = col[2] = 0.0f; + } + col[3] = 1.0f; } else if (channels==3) { - if (fp) + if (fp) { copy_v3_v3(col, fp); + } else if (cp) { - col[0] = (float)cp[0]/255.0f; - col[1] = (float)cp[1]/255.0f; - col[2] = (float)cp[2]/255.0f; + rgb_uchar_to_float(col, cp); } - else + else { zero_v3(col); + } + col[3] = 1.0f; } else if (channels==4) { if (fp) copy_v4_v4(col, fp); else if (cp) { - col[0] = (float)cp[0]/255.0f; - col[1] = (float)cp[1]/255.0f; - col[2] = (float)cp[2]/255.0f; - col[3] = (float)cp[3]/255.0f; + rgba_uchar_to_float(col, cp); } - else + else { zero_v4(col); + } } + else { + BLI_assert(0); + zero_v4(col); + } + if (color_manage) { - linearrgb_to_srgb_v3_v3(finalcol, col); - finalcol[3] = col[3]; + linearrgb_to_srgb_v4(finalcol, col); } else { copy_v4_v4(finalcol, col); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 2a8a5b3452f..1ac5ba56145 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1780,12 +1780,12 @@ typedef struct ImageSampleInfo { int x, y; int channels; - char col[4]; + unsigned char col[4]; float colf[4]; int z; float zf; - char *colp; + unsigned char *colp; float *colfp; int *zp; float *zfp; @@ -1820,7 +1820,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { float *fp; - char *cp; + unsigned char *cp; int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); CLAMP(x, 0, ibuf->x-1); @@ -1837,7 +1837,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->zfp= NULL; if(ibuf->rect) { - cp= (char *)(ibuf->rect + y*ibuf->x + x); + cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x); info->col[0]= cp[0]; info->col[1]= cp[1]; |