Skip to content

Commit

Permalink
调整[分辨率控制]: 游戏内分辨率缩放显示的分辨率始终保持偶数
Browse files Browse the repository at this point in the history
  • Loading branch information
Vera-Firefly committed Oct 15, 2024
1 parent d1c3c18 commit 1d386ac
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void showSeekBarDialog() {
// 因为麻烦
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.HORIZONTAL); // 设置水平排列
layout.setPadding(50, 40, 50, 40);
layout.setPadding(50, 40, 50, 20);
layout.setGravity(Gravity.CENTER);

// 动态创建一个 SeekBar ,用于调整缩放因子
Expand Down Expand Up @@ -113,8 +113,9 @@ private void changeResolutionRatioPreview(int progress, TextView resolutionTextV
boolean isLandscape = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || width > height;

double progressDouble = (double) progress / 100;
int previewWidth = (int) ((isLandscape ? width : height) * progressDouble);
int previewHeight = (int) ((isLandscape ? height : width) * progressDouble);
// 计算要显示的宽高,用Tools现有的方案getDisplayFriendlyRes()确保是偶数
int previewWidth = Tools.getDisplayFriendlyRes(isLandscape ? width : height, (float) progressDouble);
int previewHeight = Tools.getDisplayFriendlyRes(isLandscape ? height : width, (float) progressDouble);

String preview = previewWidth + " x " + previewHeight;
resolutionTextView.setText(preview); // 实时更新TextView中的分辨率
Expand Down

0 comments on commit 1d386ac

Please sign in to comment.