Revision: 2426
http://sourceforge.net/p/swingme/code/2426
Author: yuranet
Date: 2021-03-19 06:42:46 +0000 (Fri, 19 Mar 2021)
Log Message:
-----------
fix for screenshots not being drawn correctly
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java 2021-03-18 22:20:06 UTC (rev 2425)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java 2021-03-19 06:42:46 UTC (rev 2426)
@@ -143,7 +143,7 @@
// 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 && canvas.getDensity() == Bitmap.DENSITY_NONE && Image.getTargetDensity() != image.getBitmap().getDensity()) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && getTargetDensity() != image.getBitmap().getDensity()) {
canvas.drawBitmap(image.getBitmap(),null, new Rect(tx+ax, ty+ay, tx+ax + image.getWidth(), ty+ay + image.getHeight()), paint);
}
else {
@@ -152,6 +152,14 @@
paint.setAlpha(a);
}
+ private int getTargetDensity() {
+ int density = canvas.getDensity();
+ if (density == Bitmap.DENSITY_NONE) {
+ return Image.getTargetDensity();
+ }
+ return density;
+ }
+
public void drawLine(int x1, int y1, int x2, int y2) {
if (x1 > x2) {
x1++;
@@ -430,7 +438,7 @@
paint.setAlpha(0xFF); // we do not support alpha when drawing images
int bitmapDensity = src.getBitmap().getDensity();
- int currentDensity = Image.getTargetDensity();
+ int currentDensity = getTargetDensity();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && currentDensity != bitmapDensity) {
srcRect.set(Image.scaleFromDensity(srcRect.left, currentDensity, bitmapDensity),
Image.scaleFromDensity(srcRect.top, currentDensity, bitmapDensity),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|