Revision: 2424
http://sourceforge.net/p/swingme/code/2424
Author: yuranet
Date: 2021-03-18 21:25:46 +0000 (Thu, 18 Mar 2021)
Log Message:
-----------
allow smaller scanlength
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 20:35:01 UTC (rev 2423)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Image.java 2021-03-18 21:25:46 UTC (rev 2424)
@@ -315,6 +315,9 @@
int bitmapDensity = bitmap.getDensity();
int systemDensity = getTargetDensity();
if (bitmapDensity != Bitmap.DENSITY_NONE && bitmapDensity != systemDensity) {
+ if (scanlength < width) {
+ throw new IllegalArgumentException("scanlength ("+scanHeight+") must be >= width ("+width+")");
+ }
x = scaleFromDensity(x, systemDensity, bitmapDensity);
y = scaleFromDensity(y, systemDensity, bitmapDensity);
width = scaleFromDensity(width, systemDensity, bitmapDensity);
@@ -329,6 +332,15 @@
if (y + height == bitmap.getHeight() + 1) {
y = bitmap.getHeight() - height;
}
+
+ if (scanlength < width) {
+ int[] data = new int[width * height];
+ bitmap.getPixels(data, 0, width, x, y, width, height);
+ for (int c = scanlength * scanHeight - 1; c >= 0; c--) {
+ rgb[offset + c] = data[((c / scanlength) * width) + scaleFromDensity(c % scanlength, systemDensity, bitmapDensity)];
+ }
+ return;
+ }
}
}
@@ -338,8 +350,8 @@
int bitmapDensity = bitmap.getDensity();
int systemDensity = getTargetDensity();
if (bitmapDensity != Bitmap.DENSITY_NONE && bitmapDensity != systemDensity) {
- for (int c = offset + scanlength * scanHeight - 1; c >= offset; c--) {
- rgb[c] = rgb[((c / scanlength) * scanlength) + scaleFromDensity(c % scanlength, systemDensity, bitmapDensity)];
+ for (int c = scanlength * scanHeight - 1; c >= 0; c--) {
+ rgb[offset + c] = rgb[offset + ((c / scanlength) * scanlength) + scaleFromDensity(c % scanlength, systemDensity, bitmapDensity)];
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|