Skip to content

Commit

Permalink
Feature/displaymode scale (#176)
Browse files Browse the repository at this point in the history
* Add scale fit display mode

* Update new Kotlin files

Co-authored-by: nonononono <dev@nononono>
  • Loading branch information
hannesa2 and nonononono authored Dec 6, 2021
1 parent 2668e4d commit e265c97
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ abstract class AbstractMjpegView : MjpegView {
protected const val POSITION_LOWER_RIGHT = 6
protected const val SIZE_STANDARD = 1
protected const val SIZE_BEST_FIT = 4
protected const val SIZE_SCALE_FIT = 16
protected const val SIZE_FULLSCREEN = 8
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.github.niqdev.mjpeg

enum class DisplayMode(val value: Int) {
STANDARD(1), BEST_FIT(4), FULLSCREEN(8);
STANDARD(1), BEST_FIT(4), SCALE_FIT(16), FULLSCREEN(8);
}
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,18 @@ private Rect destRect(int bmw, int bmh) {
tempy = (dispHeight / 2) - (bmh / 2);
return new Rect(tempx, tempy, bmw + tempx, bmh + tempy);
}
if (displayMode == MjpegViewDefault.SIZE_SCALE_FIT) {
float bmasp = ((float) bmw / (float) bmh * dispWidth);
tempx = 0;
tempy = 0;
if(bmw < dispWidth){
bmw = dispWidth;
bmh = (int) bmasp;
// set it to the center height
tempy = ((dispWidth - bmh) / 2);
}
return new Rect(tempx, tempy, bmw, bmh + tempy);
}
if (displayMode == MjpegViewDefault.SIZE_FULLSCREEN)
return new Rect(0, 0, dispWidth, dispHeight);
return null;
Expand Down

0 comments on commit e265c97

Please sign in to comment.