@@ -812,8 +812,37 @@ private void waitForStart() {
812
812
GLES20 .glViewport (0 , 0 , mWidth , mHeight );
813
813
814
814
if (bitmap != null ) {
815
- float mx = ((float )mWidth / bitmap .getWidth ()) / 2.0f ;
816
- float my = ((float )mHeight / bitmap .getHeight ()) / 2.0f ;
815
+ String fit = (String ) ai .metaData .get ("presplash-fit" );
816
+
817
+ Log .i ("python" ,"presplash-fit is " +fit );
818
+ // WARNING: The presplash-fit api is unstable and may be changed
819
+
820
+ int bitmapWidth = bitmap .getWidth ();
821
+ int bitmapHeight = bitmap .getHeight ();
822
+
823
+ float mx ;
824
+ float my ;
825
+
826
+ if (fit != null && fit .equals ("fit" )) {
827
+ float bitmapMultiplier = (float ) Math .sqrt (2f * mWidth * mHeight / bitmapWidth / bitmapHeight );
828
+ mx = (float ) mWidth / bitmapWidth / bitmapMultiplier ;
829
+ my = (float ) mHeight / bitmapHeight / bitmapMultiplier ;
830
+ } else if (fit != null && fit .equals ("width" )) {
831
+ float bitmapMultiplier = ((float ) mWidth ) / bitmapWidth ;
832
+ mx = (float ) mWidth / bitmapWidth / 2.0f /bitmapMultiplier ;
833
+ my = (float ) mHeight / bitmapHeight / 2.0f /bitmapMultiplier ;
834
+ } else if (fit != null && fit .equals ("height" )) {
835
+ float bitmapMultiplier = ((float ) mHeight ) / bitmapHeight ;
836
+ mx = (float ) mWidth / bitmapWidth / 2.0f / bitmapMultiplier ;
837
+ my = (float ) mHeight / bitmapHeight / 2.0f / bitmapMultiplier ;
838
+ } else {
839
+ // default
840
+ mx = ((float ) mWidth / bitmapWidth ) / 2.0f ;
841
+ my = ((float ) mHeight / bitmapWidth ) / 2.0f ;
842
+ }
843
+
844
+ Log .i ("python" , String .format ("presplash (fit=%s) mx=%f,my=%f" , fit ,mx , my ));
845
+
817
846
Matrix .orthoM (mProjMatrix , 0 , -mx , mx , my , -my , 0 , 10 );
818
847
int value = bitmap .getPixel (0 , 0 );
819
848
Color color = new Color ();
0 commit comments