Revision: 2425
http://sourceforge.net/p/swingme/code/2425
Author: yuranet
Date: 2021-03-18 22:20:06 +0000 (Thu, 18 Mar 2021)
Log Message:
-----------
omg this is driving me nuts
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Image.java 2021-03-18 21:25:46 UTC (rev 2424)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Image.java 2021-03-18 22:20:06 UTC (rev 2425)
@@ -172,6 +172,11 @@
if (bitmap==null) {
throw new OutOfMemoryError("Bitmap.createBitmap returned null for w="+width+" h="+height+" config="+config+" error="+error );
}
+
+ if (bitmap.getDensity() != Bitmap.DENSITY_NONE && bitmap.getDensity() != getTargetDensity()) {
+ System.err.println("unexpected new bitmap density=" + bitmap.getDensity() + " (system=" + getTargetDensity()+")");
+ }
+
return new Image(bitmap);
}
@@ -263,14 +268,18 @@
* @see android.graphics.drawable.Drawable#resolveDensity(Resources, int)
*/
static int getTargetDensity() {
- // since we keep images around from startup, better to use stable density if we can
- // also on API-26 and API-30 the current density does not seem to match bitmaps density
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- return DisplayMetrics.DENSITY_DEVICE_STABLE;
- }
- Resources res = AndroidMeApp.getContext().getResources();
- final int densityDpi = res.getDisplayMetrics().densityDpi;
- return densityDpi == 0 ? DisplayMetrics.DENSITY_DEFAULT : densityDpi;
+ // on API-29 this returns total rubbish, even on the emulator (display.dpi=480 display.stableDensity=320)
+ //if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ //return DisplayMetrics.DENSITY_DEVICE_STABLE;
+ //}
+
+ // since we keep images around from startup, better to use density from startup
+ return Integer.parseInt(System.getProperty("display.dpi"));
+
+ // on API-26 and API-30 the current density does not seem to match bitmaps density
+ //Resources res = AndroidMeApp.getContext().getResources();
+ //final int densityDpi = res.getDisplayMetrics().densityDpi;
+ //return densityDpi == 0 ? DisplayMetrics.DENSITY_DEFAULT : densityDpi;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|