Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

drawImage bug on MacOX/jdk1.3.1



Hello list!

I'm here to report a bug I found during the port of a commercial java =
application (MoreFX) from Win to MacOS X.
Due to the nature of the application (graphics/animation), I make large =
use of int[] argb offscreen graphics in the form of BufferedImages.

Since the following code works on Win32 but not on MacOS X, I suspect =
that the jdk1.3.1 implementation of MacOS X does not take into account =
BufferedImages with scanline strides different from the image's width. =
Please everyone note that this kind of BufferedImages are _required_ in =
order to unpack single animation frames from a movie with QTJava. Well, =
they also are useful for scanline-based lowlevel pixel access, video =
field handling ans so on.

OK. Here's the code from my test case.

/////////////////////////////////////////////////////////////////////////=
//////////////
This code creates an INT_ARGB BufferedImage with a customscanline stride =
(ints per row)
/////////////////////////////////////////////////////////////////////////=
//////////////

// utility: create a new INT_ARGB bufferedimage with rowints support
public static final BufferedImage createBufferedImage(int[] pixels, int =
width, int height, int rowints, int pixoffset)
{
// the RGBA color masks
int[] bm =3D new int[] { 0x00FF0000, 0x0000FF00, 0x000000FF, =
0xFF000000 };
// the colormodel
ColorModel cm =3D new DirectColorModel(32, bm[0], bm[1], bm[2], =
bm[3]);
// allocate bitmap data
DataBufferInt db =3D new DataBufferInt(pixels, pixels.length, =
pixoffset);
WritableRaster wr =3D WritableRaster.createPackedRaster(db, width, =
height, rowints, bm, null);
// create the image
return new BufferedImage(cm, wr, false, null);
}


/////////////////////////////////////////////////////////////////////
With this code I create a BufferedImage with a custom scanline stride
then I fill the image with a colorfade and a yellow grid.
/////////////////////////////////////////////////////////////////////

public void oSXdrawImageBug_Initialize()
{
// the bitmap extra ints padding
int EXTRA_STRIDE =3D 10;

// create the pixel buffer
int width =3D 320;
int height =3D 255;
int scanline_stride =3D width + EXTRA_STRIDE;
int[] pix =3D new int[width * scanline_stride];
for (int i =3D 0; i < pix.length; i++)
pix[i] =3D 0xFFFF0000;

// create the buffered image
bi =3D createBufferedImage(pix, width, height, scanline_stride, 0);
java.awt.Graphics2D g2 =3D (java.awt.Graphics2D) bi.getGraphics();

// draw some graphics by directly accessing the pixels
for (int y =3D 0; y < height; y++)
{
for (int x =3D 0; x < width; x++)
{
// the pixel color
int c =3D y;
if (x % 32 =3D=3D 0 || y % 32 =3D=3D 0)
c =3D 0xFFFF00;

// plot the pixel
pix[x + y * scanline_stride] =3D 0xFF000000 | c;
}
}

return;
}

/////////////////////////////////////////////////////////////////////


In the attached executable jar I've enclosed the full source code of the =
test case.
I hope someone helps me to find a workaround // share the same =
experience.
Could someone please test it also on MacOS X // jdk1.4.1 ?

Cheers,

Mik of ClassX
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
> ClassX Development Italy Via Francesca, 463 I-56030 Montecalvoli =
(PI) <
> Tel.(+39)-0587-749206 Fax.(+39)-0587-749206 WEB: =
http://www.classx.it <
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

[demime 0.98b removed an attachment of type application/octet-stream which had a name of imagebug.jar]
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.