Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use metadata to select a fitting method for the presplash screen #408

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/src/org/renpy/android/SDLSurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,36 @@ private void waitForStart() {
GLES20.glViewport(0, 0, mWidth, mHeight);

if (bitmap != null) {
float mx = ((float)mWidth / bitmap.getWidth()) / 2.0f;
float my = ((float)mHeight / bitmap.getHeight()) / 2.0f;
String fit = (String) ai.metaData.get("presplash-fit");

Log.i("python","presplash-fit is "+fit);

int bitmapWidth = bitmap.getWidth();
int bitmapHeight = bitmap.getHeight();

float mx;
float my;

if (fit != null && fit.equals("fit")) {
float bitmapMultiplier = (float) Math.sqrt(2f * mWidth * mHeight / bitmapWidth / bitmapHeight);
mx = (float) mWidth / bitmapWidth / bitmapMultiplier;
my = (float) mHeight / bitmapHeight / bitmapMultiplier;
} else if (fit != null && fit.equals("width")) {
float bitmapMultiplier = ((float) mWidth) / bitmapWidth;
mx = (float) mWidth / bitmapWidth / 2.0f /bitmapMultiplier;
my = (float) mHeight / bitmapHeight / 2.0f /bitmapMultiplier;
} else if (fit != null && fit.equals("height")) {
float bitmapMultiplier = ((float) mHeight) / bitmapHeight;
mx = (float) mWidth / bitmapWidth / 2.0f / bitmapMultiplier;
my = (float) mHeight / bitmapHeight / 2.0f / bitmapMultiplier;
} else {
// default
mx = ((float) mWidth / bitmapWidth) / 2.0f;
my = ((float) mHeight / bitmapWidth) / 2.0f;
}

Log.i("python", String.format("presplash (fit=%s) mx=%f,my=%f", fit,mx, my));

Matrix.orthoM(mProjMatrix, 0, -mx, mx, my, -my, 0, 10);
int value = bitmap.getPixel(0, 0);
Color color = new Color();
Expand Down