Revision: 2431
http://sourceforge.net/p/swingme/code/2431
Author: yuranet
Date: 2021-03-31 15:16:59 +0000 (Wed, 31 Mar 2021)
Log Message:
-----------
fix for drawing screenshot to incorrect density bitmap
Modified Paths:
--------------
AndroidME/src_Android/net/yura/android/AndroidMeApp.java
AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java
Modified: AndroidME/src_Android/net/yura/android/AndroidMeApp.java
===================================================================
--- AndroidME/src_Android/net/yura/android/AndroidMeApp.java 2021-03-28 16:56:41 UTC (rev 2430)
+++ AndroidME/src_Android/net/yura/android/AndroidMeApp.java 2021-03-31 15:16:59 UTC (rev 2431)
@@ -113,6 +113,9 @@
}
}
+ /**
+ * @see NotificationChannel#DEFAULT_CHANNEL_ID
+ */
public static final String CHANNEL_ID = "default-notification-channel";
private void createNotificationChannel() {
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java 2021-03-28 16:56:41 UTC (rev 2430)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java 2021-03-31 15:16:59 UTC (rev 2431)
@@ -147,11 +147,18 @@
// in targetAPI 28+ android seems to have stopped respecting the density of the bitmap for app resources
// this is probably a bug: https://issuetracker.google.com/issues/181887424
- // we cant compare image with canvas.getDensity() as that seems to just return 0, and we also cant set it
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && Image.getTargetDensity() != image.getBitmap().getDensity()) {
+ // we cant compare image with canvas.getDensity() as that seems to just return 0 in HW mode, and we also cant set it
+ // when drawing to a bitmap, we can not trust canvas.getDensity() as some Samsungs return an incorrect value
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && (
+ // if the image density does not match system (e.g. mdpi resource image)
+ (image.getBitmap().getDensity() != Bitmap.DENSITY_NONE && image.getBitmap().getDensity() != Image.getTargetDensity()) ||
+ // if canvas density does not match system (e.g. screenshot to bitmap)
+ (canvas.getDensity() != Bitmap.DENSITY_NONE && canvas.getDensity() != Image.getTargetDensity())
+ )) {
canvas.drawBitmap(image.getBitmap(),null, new Rect(x, y, x + image.getWidth(), y + image.getHeight()), paint);
}
else {
+ // CAREFUL! THIS METHOD DOES AUTOMATIC SCALING SOMETIMES
canvas.drawBitmap(image.getBitmap(), x, y, paint);
}
paint.setAlpha(a);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|