sometimes it would be nice to scale preview pictures to max available space without black borders.
this patch implements a "overstretch" option for this:
this patch implements a "overstretch" option for this:
Index: src/actionscript/org/flowplayer/model/MediaSize.as
===================================================================
--- src/actionscript/org/flowplayer/model/MediaSize.as (revision 334)
+++ src/actionscript/org/flowplayer/model/MediaSize.as (working copy)
@@ -29,6 +29,7 @@
public static const HALF_FROM_ORIGINAL:MediaSize = new MediaSize("half");
public static const ORIGINAL:MediaSize = new MediaSize("orig");
public static const FILLED_TO_AVAILABLE_SPACE:MediaSize = new MediaSize("scale");
+ public static const FILL_MAX_SPACE:MediaSize = new MediaSize("overstretch");
public static var ALL_VALUES:Dictionary = new Dictionary();
{
@@ -36,6 +37,7 @@
ALL_VALUES[HALF_FROM_ORIGINAL._value] = HALF_FROM_ORIGINAL;
ALL_VALUES[ORIGINAL._value] = ORIGINAL;
ALL_VALUES[FILLED_TO_AVAILABLE_SPACE._value] = FILLED_TO_AVAILABLE_SPACE;
+ ALL_VALUES[FILL_MAX_SPACE._value] = FILL_MAX_SPACE;
}
private static var enumCreated:Boolean;
Index: src/actionscript/org/flowplayer/view/MediaResizer.as
===================================================================
--- src/actionscript/org/flowplayer/view/MediaResizer.as (revision 334)
+++ src/actionscript/org/flowplayer/view/MediaResizer.as (working copy)
@@ -56,6 +56,8 @@
resized = resizeToHalfAvailableSize();
} else if (sizingOption == MediaSize.ORIGINAL) {
resized = resizeToOrig(force);
+ } else if (sizingOption == MediaSize.FILL_MAX_SPACE) {
+ resized = resizeToMaxFill();
} else if (sizingOption == MediaSize.FILLED_TO_AVAILABLE_SPACE) {
resized = resizeToMax();
}
@@ -80,6 +82,23 @@
return true;
}
+ private function resizeToMaxFill():Boolean {
+ if (origHeight == 0 || origHeight == 0) {
+ log.warn("resizeToFit: original sizes not available, will not resize");
+ return false;
+ }
+ log.debug("resize to fill max");
+
+ var xRatio:Number = _maxWidth / origWidth;
+
+ if (xRatio * origHeight <= _maxHeight) {
+ scale(_maxHeight / origHeight);
+ } else {
+ scale(xRatio);
+ }
+ return true;
+ }
+
public function scale(scalingFactor:Number):void {
resize(scalingFactor * origWidth, scalingFactor * origHeight);
}