Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_ops.c
| Show First 20 Lines • Show All 3,051 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Sample Image Operator | /** \name Sample Image Operator | ||||
| * \{ */ | * \{ */ | ||||
| /* Returns color in linear space, matching ED_space_node_color_sample(). */ | /* Returns color in linear space, matching ED_space_node_color_sample(). */ | ||||
| bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, int mval[2], float r_col[3]) | bool ED_space_image_color_sample( | ||||
| SpaceImage *sima, ARegion *region, int mval[2], float r_col[3], bool *r_is_data) | |||||
| { | { | ||||
| if (r_is_data) { | |||||
| *r_is_data = false; | |||||
| } | |||||
| if (sima->image == NULL) { | if (sima->image == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| float uv[2]; | float uv[2]; | ||||
| UI_view2d_region_to_view(®ion->v2d, mval[0], mval[1], &uv[0], &uv[1]); | UI_view2d_region_to_view(®ion->v2d, mval[0], mval[1], &uv[0], &uv[1]); | ||||
| int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL); | int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL); | ||||
| void *lock; | void *lock; | ||||
| Show All 21 Lines | if (uv[0] >= 0.0f && uv[1] >= 0.0f && uv[0] < 1.0f && uv[1] < 1.0f) { | ||||
| else if (ibuf->rect) { | else if (ibuf->rect) { | ||||
| cp = (uchar *)(ibuf->rect + y * ibuf->x + x); | cp = (uchar *)(ibuf->rect + y * ibuf->x + x); | ||||
| rgb_uchar_to_float(r_col, cp); | rgb_uchar_to_float(r_col, cp); | ||||
| IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace); | IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace); | ||||
| ret = true; | ret = true; | ||||
| } | } | ||||
| } | } | ||||
| if (r_is_data) { | |||||
| *r_is_data = (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) != 0; | |||||
| } | |||||
| ED_space_image_release_buffer(sima, ibuf, lock); | ED_space_image_release_buffer(sima, ibuf, lock); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| void IMAGE_OT_sample(wmOperatorType *ot) | void IMAGE_OT_sample(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Sample Color"; | ot->name = "Sample Color"; | ||||
| ▲ Show 20 Lines • Show All 881 Lines • Show Last 20 Lines | |||||