add ED_space_image_get_size_fl, ED_space_clip_get_size_fl

This commit is contained in:
2012-07-26 11:47:47 +00:00
parent fec872ef9c
commit f39a21c36f
7 changed files with 24 additions and 18 deletions

View File

@@ -53,6 +53,7 @@ int ED_space_clip_maskedit_poll(struct bContext *C);
int ED_space_clip_maskedit_mask_poll(bContext *C);
void ED_space_clip_get_size(const struct bContext *C, int *width, int *height);
void ED_space_clip_get_size_fl(const struct bContext *C, float size[2]);
void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy);
void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy);

View File

@@ -52,6 +52,7 @@ void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock);
int ED_space_image_has_buffer(struct SpaceImage *sima);
void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height);
void ED_space_image_get_size_fl(struct SpaceImage *sima, float size[2]);
void ED_space_image_get_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);

View File

@@ -110,13 +110,10 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
}
case SPACE_IMAGE:
{
int width, height;
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size(sima, &width, &height);
frame_size[0] = width;
frame_size[1] = height;
ED_space_image_get_size_fl(sima, frame_size);
ED_image_mouse_pos(sima, ar, event, co);
BKE_mask_coord_from_frame(co, co, frame_size);
break;
@@ -155,13 +152,10 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
break;
case SPACE_IMAGE:
{
int width, height;
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size(sima, &width, &height);
frame_size[0] = width;
frame_size[1] = height;
ED_space_image_get_size_fl(sima, frame_size);
ED_image_point_pos(sima, ar, x, y, &co[0], &co[1]);
BKE_mask_coord_from_frame(co, co, frame_size);
break;
@@ -203,13 +197,10 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr,
break;
case SPACE_IMAGE:
{
int width, height;
float frame_size[2];
SpaceImage *sima = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
ED_space_image_get_size(sima, &width, &height);
frame_size[0] = width;
frame_size[1] = height;
ED_space_image_get_size_fl(sima, frame_size);
co[0] = x;
co[1] = y;

View File

@@ -136,6 +136,14 @@ void ED_space_clip_get_size(const bContext *C, int *width, int *height)
}
}
void ED_space_clip_get_size_fl(const bContext *C, float size[2])
{
int size_i[2];
ED_space_clip_get_size(C, &size_i[0], &size_i[1]);
size[0] = size_i[0];
size[1] = size_i[1];
}
void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy)
{
ARegion *ar = CTX_wm_region(C);

View File

@@ -192,6 +192,14 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
ED_space_image_release_buffer(sima, lock);
}
void ED_space_image_get_size_fl(SpaceImage *sima, float size[2])
{
int size_i[2];
ED_space_image_get_size(sima, &size_i[0], &size_i[1]);
size[0] = size_i[0];
size[1] = size_i[1];
}
void ED_image_get_aspect(Image *ima, float *aspx, float *aspy)
{
*aspx = *aspy = 1.0;

View File

@@ -1452,12 +1452,9 @@ void calculateCenterCursor2D(TransInfo *t)
if (cursor) {
if (t->options & CTX_MASK) {
float co[2];
int width, height;
float frame_size[2];
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
ED_space_image_get_size(sima, &width, &height);
frame_size[0] = width;
frame_size[1] = height;
ED_space_image_get_size_fl(sima, frame_size);
BKE_mask_coord_from_frame(co, cursor, frame_size);

View File

@@ -295,8 +295,8 @@ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist
ED_space_image_get_size(sima, &width, &height);
}
else {
width = 256;
height = 256;
width = IMG_SIZE_FALLBACK;
height = IMG_SIZE_FALLBACK;
}
dist[0] = pixeldist / width;