Commit 0468a80d by Drew Hill

just use original plane width to calculate width proportion to use later as size…

just use original plane width to calculate width proportion to use later as size and keep aspect ratio for height
parent 8804ecde
...@@ -90,8 +90,6 @@ public class Cue { ...@@ -90,8 +90,6 @@ public class Cue {
* <p> * <p>
* For horizontal text and {@link #lineType} equal to {@link #LINE_TYPE_FRACTION}, this is the * For horizontal text and {@link #lineType} equal to {@link #LINE_TYPE_FRACTION}, this is the
* fractional vertical position relative to the top of the viewport. * fractional vertical position relative to the top of the viewport.
* <p>
* If {@link #bitmap} is not null then this value is used to indicate the top position
*/ */
public final float line; public final float line;
/** /**
...@@ -126,8 +124,6 @@ public class Cue { ...@@ -126,8 +124,6 @@ public class Cue {
* For horizontal text, this is the horizontal position relative to the left of the viewport. Note * For horizontal text, this is the horizontal position relative to the left of the viewport. Note
* that positioning is relative to the left of the viewport even in the case of right-to-left * that positioning is relative to the left of the viewport even in the case of right-to-left
* text. * text.
* <p>
* If {@link #bitmap} is not null then this value is used to indicate the left position
*/ */
public final float position; public final float position;
/** /**
...@@ -143,23 +139,15 @@ public class Cue { ...@@ -143,23 +139,15 @@ public class Cue {
/** /**
* The size of the cue box in the writing direction specified as a fraction of the viewport size * The size of the cue box in the writing direction specified as a fraction of the viewport size
* in that direction, or {@link #DIMEN_UNSET}. * in that direction, or {@link #DIMEN_UNSET}.
* <p>
* If {@link #bitmap} is not null then this value is used to indicate the width
*/ */
public final float size; public final float size;
/** /**
* The height size of the cue box when a {@link #bitmap} is set specified as a fraction of the
* viewport size in that direction, or {@link #DIMEN_UNSET}.
*/
public final float size_height;
/**
* *
*/ */
public Cue(Bitmap bitmap, float left, float top, float size, float size_height) { public Cue(Bitmap bitmap, float left, float top, int plane_width) {
this(null, null, top, LINE_TYPE_FRACTION, TYPE_UNSET, left, TYPE_UNSET, size, size_height, this(null, null, top, LINE_TYPE_FRACTION, ANCHOR_TYPE_START, left, ANCHOR_TYPE_START,
bitmap); (float) bitmap.getWidth() / plane_width, bitmap);
} }
/** /**
...@@ -184,8 +172,7 @@ public class Cue { ...@@ -184,8 +172,7 @@ public class Cue {
*/ */
public Cue(CharSequence text, Alignment textAlignment, float line, @LineType int lineType, public Cue(CharSequence text, Alignment textAlignment, float line, @LineType int lineType,
@AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size) { @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size) {
this(text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, size, this(text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, size, null);
DIMEN_UNSET, null);
} }
/** /**
* @param text See {@link #text}. * @param text See {@link #text}.
...@@ -196,12 +183,11 @@ public class Cue { ...@@ -196,12 +183,11 @@ public class Cue {
* @param position See {@link #position}. * @param position See {@link #position}.
* @param positionAnchor See {@link #positionAnchor}. * @param positionAnchor See {@link #positionAnchor}.
* @param size See {@link #size}. * @param size See {@link #size}.
* @param size_height See {@link #size_height}.
* @param bitmap See {@link #bitmap}. * @param bitmap See {@link #bitmap}.
*/ */
private Cue(CharSequence text, Alignment textAlignment, float line, @LineType int lineType, private Cue(CharSequence text, Alignment textAlignment, float line, @LineType int lineType,
@AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size, @AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size,
float size_height, Bitmap bitmap) { Bitmap bitmap) {
this.text = text; this.text = text;
this.textAlignment = textAlignment; this.textAlignment = textAlignment;
this.line = line; this.line = line;
...@@ -210,7 +196,6 @@ public class Cue { ...@@ -210,7 +196,6 @@ public class Cue {
this.position = position; this.position = position;
this.positionAnchor = positionAnchor; this.positionAnchor = positionAnchor;
this.size = size; this.size = size;
this.size_height = size_height;
this.bitmap = bitmap; this.bitmap = bitmap;
} }
......
...@@ -77,7 +77,6 @@ import com.google.android.exoplayer2.util.Util; ...@@ -77,7 +77,6 @@ import com.google.android.exoplayer2.util.Util;
@Cue.AnchorType @Cue.AnchorType
private int cuePositionAnchor; private int cuePositionAnchor;
private float cueSize; private float cueSize;
private float cueSizeHeight;
private boolean applyEmbeddedStyles; private boolean applyEmbeddedStyles;
private int foregroundColor; private int foregroundColor;
private int backgroundColor; private int backgroundColor;
...@@ -192,7 +191,6 @@ import com.google.android.exoplayer2.util.Util; ...@@ -192,7 +191,6 @@ import com.google.android.exoplayer2.util.Util;
this.cuePosition = cue.position; this.cuePosition = cue.position;
this.cuePositionAnchor = cue.positionAnchor; this.cuePositionAnchor = cue.positionAnchor;
this.cueSize = cue.size; this.cueSize = cue.size;
this.cueSizeHeight = cue.size_height;
this.applyEmbeddedStyles = applyEmbeddedStyles; this.applyEmbeddedStyles = applyEmbeddedStyles;
this.foregroundColor = style.foregroundColor; this.foregroundColor = style.foregroundColor;
this.backgroundColor = style.backgroundColor; this.backgroundColor = style.backgroundColor;
...@@ -224,8 +222,9 @@ import com.google.android.exoplayer2.util.Util; ...@@ -224,8 +222,9 @@ import com.google.android.exoplayer2.util.Util;
int parentHeight = parentBottom - parentTop; int parentHeight = parentBottom - parentTop;
int x = parentLeft + (int) ((float) parentWidth * cuePosition); int x = parentLeft + (int) ((float) parentWidth * cuePosition);
int y = parentTop + (int) ((float) parentHeight * cueLine); int y = parentTop + (int) ((float) parentHeight * cueLine);
bitmapRect = new Rect(x,y, int width = (int) (parentWidth * cueSize);
x + (int)((float) parentWidth * cueSize),y + (int)((float) parentHeight * cueSizeHeight)); int height = (int) (width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth()));
bitmapRect = new Rect(x, y, x + width, y + height);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment