|
From: Kenny S. <ke...@pe...> - 2007-03-23 00:39:56
|
This fixes a bug where we want to draw a subregion from the larger =
image.
I just dropped the error checking, but I'm not sure if it is correct or =
not.
--- ./core/src/org/microemu/device/j2se/J2SEDisplayGraphics.java.orig =
2007-03-22 17:23:59.000000000 -0700
+++ ./core/src/org/microemu/device/j2se/J2SEDisplayGraphics.java =
2007-03-22 17:30:07.000000000 -0700
@@ -429,19 +429,19 @@
if (rgbData =3D=3D null)
throw new NullPointerException();
=20
- int l =3D rgbData.length;
- =20
- if (width <=3D 0 || height <=3D 0 || offset < 0 || offset =
>=3D l ||
- (scanlength < 0 && scanlength * (height-1) < 0) ||
- (scanlength >=3D 0 && scanlength * (height-1) + =
width-1 >=3D l))
- throw new ArrayIndexOutOfBoundsException();
- =20
- int [] rgb =3D new int[l - offset];
+ int area =3D width * height;
+
+ int [] rgb =3D new int[area];
// this way we dont create yet another array in createImage
int transparencyMask =3D processAlpha? 0 : 0xff000000;
- =20
- for(int i =3D 0; offset < l; offset++, i++)
- rgb[i] =3D rgbData[offset] | transparencyMask;
+
+ int i =3D 0;
+ for(int iy =3D 0; iy < height; ++iy) {
+ for (int ix =3D 0; ix < width; ++ix) {
+ rgb[i++] =3D rgbData[offset + =
ix] | transparencyMask;
+ }
+ offset +=3D scanlength;
+ }
=20
// help gc
rgbData =3D null;
-Kenny
|