kopia lustrzana https://github.com/xdsopl/robot36
added toggle for integer or float scaling
rodzic
bd7ec1f0bc
commit
b09bf0632c
|
@ -37,6 +37,7 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
private boolean takeABreak = true, cantTouchThis = true, quitThread = false;
|
||||
private int imageWidth = 320;
|
||||
private int imageHeight = 240;
|
||||
private boolean intScale = false;
|
||||
MainActivity activity;
|
||||
private final SurfaceHolder holder;
|
||||
private final Bitmap bitmap;
|
||||
|
@ -134,6 +135,7 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
thread.start();
|
||||
}
|
||||
|
||||
void toggle_scaling() { intScale ^= true; }
|
||||
void softer_image() { rsDecoder.invoke_incr_blur(); }
|
||||
void sharper_image() { rsDecoder.invoke_decr_blur(); }
|
||||
void debug_sync() { rsDecoder.invoke_debug_sync(); }
|
||||
|
@ -254,18 +256,20 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
}
|
||||
|
||||
void drawBitmap(Canvas canvas) {
|
||||
float sx, sy, px, py;
|
||||
float sx, sy;
|
||||
if (imageWidth * canvasHeight < canvasWidth * bitmap.getHeight()) {
|
||||
sy = (float)canvasHeight / bitmap.getHeight();
|
||||
sx = sy * imageWidth / bitmap.getWidth();
|
||||
px = (canvasWidth - sx * bitmap.getWidth()) / 2.0f;
|
||||
py = 0.0f;
|
||||
} else {
|
||||
sx = (float)canvasWidth / bitmap.getWidth();
|
||||
sy = (float)canvasWidth / imageWidth;
|
||||
px = 0.0f;
|
||||
py = (canvasHeight - sy * bitmap.getHeight()) / 2.0f;
|
||||
}
|
||||
if (intScale) {
|
||||
sx = (float)Math.floor(sx);
|
||||
sy = (float)Math.floor(sy);
|
||||
}
|
||||
float px = (canvasWidth - sx * bitmap.getWidth()) / 2.0f;
|
||||
float py = (canvasHeight - sy * bitmap.getHeight()) / 2.0f;
|
||||
canvas.drawColor(Color.BLACK);
|
||||
canvas.save();
|
||||
canvas.scale(sx, sy, px, py);
|
||||
|
|
|
@ -148,6 +148,9 @@ public class MainActivity extends Activity {
|
|||
case R.id.action_sharper_image:
|
||||
view.sharper_image();
|
||||
return true;
|
||||
case R.id.action_toggle_scaling:
|
||||
view.toggle_scaling();
|
||||
return true;
|
||||
case R.id.action_robot36_mode:
|
||||
view.robot36_mode();
|
||||
return true;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_sharper_image" android:title="@string/action_sharper_image"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_toggle_scaling" android:title="@string/action_toggle_scaling"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_robot36_mode" android:title="@string/action_robot36_mode"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_robot72_mode" android:title="@string/action_robot72_mode"
|
||||
|
|
|
@ -17,5 +17,6 @@
|
|||
<string name="action_wrasseSC2_180_mode">WrasseSC2 180 Mode</string>
|
||||
<string name="action_softer_image">Softer Image</string>
|
||||
<string name="action_sharper_image">Sharper Image</string>
|
||||
<string name="action_toggle_scaling">Toggle Scaling</string>
|
||||
|
||||
</resources>
|
||||
|
|
Ładowanie…
Reference in New Issue