@@ -812,8 +812,36 @@ private void waitForStart() {
812812 GLES20 .glViewport (0 , 0 , mWidth , mHeight );
813813
814814 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+
819+ int bitmapWidth = bitmap .getWidth ();
820+ int bitmapHeight = bitmap .getHeight ();
821+
822+ float mx ;
823+ float my ;
824+
825+ if (fit != null && fit .equals ("fit" )) {
826+ float bitmapMultiplier = (float ) Math .sqrt (2f * mWidth * mHeight / bitmapWidth / bitmapHeight );
827+ mx = (float ) mWidth / bitmapWidth / bitmapMultiplier ;
828+ my = (float ) mHeight / bitmapHeight / bitmapMultiplier ;
829+ } else if (fit != null && fit .equals ("width" )) {
830+ float bitmapMultiplier = ((float ) mWidth ) / bitmapWidth ;
831+ mx = (float ) mWidth / bitmapWidth / 2.0f /bitmapMultiplier ;
832+ my = (float ) mHeight / bitmapHeight / 2.0f /bitmapMultiplier ;
833+ } else if (fit != null && fit .equals ("height" )) {
834+ float bitmapMultiplier = ((float ) mHeight ) / bitmapHeight ;
835+ mx = (float ) mWidth / bitmapWidth / 2.0f / bitmapMultiplier ;
836+ my = (float ) mHeight / bitmapHeight / 2.0f / bitmapMultiplier ;
837+ } else {
838+ // default
839+ mx = ((float ) mWidth / bitmapWidth ) / 2.0f ;
840+ my = ((float ) mHeight / bitmapWidth ) / 2.0f ;
841+ }
842+
843+ Log .i ("python" , String .format ("presplash (fit=%s) mx=%f,my=%f" , fit ,mx , my ));
844+
817845 Matrix .orthoM (mProjMatrix , 0 , -mx , mx , my , -my , 0 , 10 );
818846 int value = bitmap .getPixel (0 , 0 );
819847 Color color = new Color ();
0 commit comments