diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-26 00:39:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-26 00:39:49 +0400 |
commit | 2b133b14ab1b37f80f94a7a411ee116e095c9b8d (patch) | |
tree | f5651e0b9d13fe68946e0362a69083bd14f3f5f4 /source/blender/blenkernel/intern | |
parent | 8ad3e7396597ffcf56f3ad74c00dfc6fdcd504df (diff) |
mask/image viewer now works with non 1:1 image aspect, editing masks in the image viewer should be generally usable now though still some TODO's left.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 54 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 2 |
2 files changed, 36 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 6d49137d892..d963d46569a 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1494,48 +1494,64 @@ void BKE_mask_unlink(Main *bmain, Mask *mask) mask->id.us = 0; } -void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2]) +void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2]) { - int width, height; - - /* scaling for the clip */ - BKE_movieclip_get_size(clip, user, &width, &height); - - if (width == height) { + if (frame_size[0] == frame_size[1]) { r_co[0] = co[0]; r_co[1] = co[1]; } - else if (width < height) { - r_co[0] = ((co[0] - 0.5f) * ((float)width / (float)height)) + 0.5f; + else if (frame_size[0] < frame_size[1]) { + r_co[0] = ((co[0] - 0.5f) * (frame_size[0] / frame_size[1])) + 0.5f; r_co[1] = co[1]; } - else { /* (width > height) */ + else { /* (frame_size[0] > frame_size[1]) */ r_co[0] = co[0]; - r_co[1] = ((co[1] - 0.5f) * ((float)height / (float)width)) + 0.5f; + r_co[1] = ((co[1] - 0.5f) * (frame_size[1] / frame_size[0])) + 0.5f; } } - -/* as above but divide */ -void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2]) +void BKE_mask_coord_from_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2]) { int width, height; + float frame_size[2]; /* scaling for the clip */ BKE_movieclip_get_size(clip, user, &width, &height); - if (width == height) { + frame_size[0] = (float)width; + frame_size[1] = (float)height; + + BKE_mask_coord_from_frame(r_co, co, frame_size); +} + +/* as above but divide */ +void BKE_mask_coord_to_frame(float r_co[2], const float co[2], const float frame_size[2]) +{ + if (frame_size[0] == frame_size[1]) { r_co[0] = co[0]; r_co[1] = co[1]; } - else if (width < height) { - r_co[0] = ((co[0] - 0.5f) / ((float)width / (float)height)) + 0.5f; + else if (frame_size[0] < frame_size[1]) { + r_co[0] = ((co[0] - 0.5f) / (frame_size[0] / frame_size[1])) + 0.5f; r_co[1] = co[1]; } - else { /* (width > height) */ + else { /* (frame_size[0] > frame_size[1]) */ r_co[0] = co[0]; - r_co[1] = ((co[1] - 0.5f) / ((float)height / (float)width)) + 0.5f; + r_co[1] = ((co[1] - 0.5f) / (frame_size[1] / frame_size[0])) + 0.5f; } } +void BKE_mask_coord_to_movieclip(MovieClip *clip, MovieClipUser *user, float r_co[2], const float co[2]) +{ + int width, height; + float frame_size[2]; + + /* scaling for the clip */ + BKE_movieclip_get_size(clip, user, &width, &height); + + frame_size[0] = (float)width; + frame_size[1] = (float)height; + + BKE_mask_coord_to_frame(r_co, co, frame_size); +} static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[2]) { diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index de367b6b4d0..045f0adaf41 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1074,7 +1074,7 @@ void BKE_movieclip_reload(MovieClip *clip) else clip->source = MCLIP_SRC_SEQUENCE; - clip->lastsize[0] = clip->lastsize[1] = 0; + clip->lastsize[0] = clip->lastsize[1] = IMG_SIZE_FALLBACK; movieclip_load_get_szie(clip); movieclip_calc_length(clip); |