Home » Eclipse Projects » Technology Project and PMC » SWT Image ... Speed
|
Re: SWT Image ... Speed [message #30173 is a reply to message #30103] |
Mon, 07 October 2002 13:27 |
Scott Stanchfield Messages: 263 Registered: July 2009 |
Senior Member |
|
|
Here's what I'm using for AWT -> SWT image conversion. Seems to work quite
well w/o the JPEG intermediary. (I used to do the JPEG path as well...).
Note that the error processing needs work -- this is still a rough version
so I could get the "real stuff" in my GUI builder to work...
I haven't done any timings (ironically, I don't have time to time it ;) If
you time this let me know how it does...
java.awt.Image awtImage = ...;
int[] pixels = new int[c.getWidth() * c.getHeight()];
PixelGrabber pg = new PixelGrabber(awtImage, 0, 0, c.getWidth(),
c.getHeight(), pixels, 0, c.getWidth());
try {
pg.grabPixels();
}
catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels!");
return;
}
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
System.err.println("image fetch aborted or errored");
return;
}
ImageData dest = new ImageData(c.getWidth(), c.getHeight(), 32, new
PaletteData(0xFF0000,0xFF00,0xFF));
byte[] data = dest.data;
for (int i = 0, index = 0; i < c.getWidth() * c.getHeight(); i++, index+=4)
{
int pixel = pixels[i];
data[index] = (byte)((pixel >> 24) & 0xFF);
data[index + 1] = (byte)((pixel >> 16) & 0xFF);
data[index + 2] = (byte)((pixel >> 8) & 0xFF);
data[index + 3] = (byte)(pixel & 0xFF);
}
Image swtImage = new Image(null, dest);
-- Scott
============================================================ ==
Scott Stanchfield scott@javadude.com http://javadude.com
Lead author of "Effective VisualAge for Java, Version 3"
http://javadude.com/evaj
VisualAge for Java Tips and Tricks http://javadude.com/vaj
Visit for Java Enlightenment! http://www.jguru.com
============================================================ ==
"Justin Kilimnik" <justink@au.ibm.com> wrote in message
news:anqore$vbb$1@rogue.oti.com...
> I have been doing a lot of work lately with the Eclipse workbench and
> modifications to it, and a lot of work with SWT.
>
> One major problem I have noticed with SWT is the Image class. Doing a
> image read (1600x1200 JPEG) from the file system takes:
>
> 500ms in C++/Intel JPEG Graphics Lib
> ~1200ms in C# with .NET classes
> ~2000ms in Java using BufferedImageReader
> ~4000ms in SWT using the Image class and filename name constuctor
>
> There seems to be no way to convert the standard Java Images to SWT images
> so I am stuck with the bad performance of swt.Image. Is there anyway to
> speed this up? One of the features with the Intel Graphics lib is that you
> can (in simple terms) read the image size before loading the image fully
> and decide if you wish to only read every 2nd, 4th, 8th, 16th pixel from
> the file (which is a great feature when you are generating Thumbnails from
> large images.
>
> Is there someone out there on the SWT team that can help with any of this?
> (I am prepared to get involved with this myself as well)
>
|
|
|
Re: SWT Image ... Speed [message #30562 is a reply to message #30173] |
Mon, 07 October 2002 23:18 |
Justin Kilimnik Messages: 12 Registered: July 2009 |
Junior Member |
|
|
Thanks Scott,
I will test this out as soon as possible. With all the Java2D libs out
there it seems like we need some sort of bridge in this area....
Justin
Scott Stanchfield wrote:
> Here's what I'm using for AWT -> SWT image conversion. Seems to work quite
> well w/o the JPEG intermediary. (I used to do the JPEG path as well...).
> Note that the error processing needs work -- this is still a rough version
> so I could get the "real stuff" in my GUI builder to work...
> I haven't done any timings (ironically, I don't have time to time it ;) If
> you time this let me know how it does...
> java.awt.Image awtImage = ...;
> int[] pixels = new int[c.getWidth() * c.getHeight()];
> PixelGrabber pg = new PixelGrabber(awtImage, 0, 0, c.getWidth(),
> c.getHeight(), pixels, 0, c.getWidth());
> try {
> pg.grabPixels();
> }
> catch (InterruptedException e) {
> System.err.println("interrupted waiting for pixels!");
> return;
> }
> if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
> System.err.println("image fetch aborted or errored");
> return;
> }
> ImageData dest = new ImageData(c.getWidth(), c.getHeight(), 32, new
> PaletteData(0xFF0000,0xFF00,0xFF));
> byte[] data = dest.data;
> for (int i = 0, index = 0; i < c.getWidth() * c.getHeight(); i++, index+=4)
> {
> int pixel = pixels[i];
> data[index] = (byte)((pixel >> 24) & 0xFF);
> data[index + 1] = (byte)((pixel >> 16) & 0xFF);
> data[index + 2] = (byte)((pixel >> 8) & 0xFF);
> data[index + 3] = (byte)(pixel & 0xFF);
> }
> Image swtImage = new Image(null, dest);
> -- Scott
> ============================================================ ==
> Scott Stanchfield scott@javadude.com http://javadude.com
> Lead author of "Effective VisualAge for Java, Version 3"
> http://javadude.com/evaj
> VisualAge for Java Tips and Tricks http://javadude.com/vaj
> Visit for Java Enlightenment! http://www.jguru.com
> ============================================================ ==
> "Justin Kilimnik" <justink@au.ibm.com> wrote in message
> news:anqore$vbb$1@rogue.oti.com...
> > I have been doing a lot of work lately with the Eclipse workbench and
> > modifications to it, and a lot of work with SWT.
> >
> > One major problem I have noticed with SWT is the Image class. Doing a
> > image read (1600x1200 JPEG) from the file system takes:
> >
> > 500ms in C++/Intel JPEG Graphics Lib
> > ~1200ms in C# with .NET classes
> > ~2000ms in Java using BufferedImageReader
> > ~4000ms in SWT using the Image class and filename name constuctor
> >
> > There seems to be no way to convert the standard Java Images to SWT images
> > so I am stuck with the bad performance of swt.Image. Is there anyway to
> > speed this up? One of the features with the Intel Graphics lib is that you
> > can (in simple terms) read the image size before loading the image fully
> > and decide if you wish to only read every 2nd, 4th, 8th, 16th pixel from
> > the file (which is a great feature when you are generating Thumbnails from
> > large images.
> >
> > Is there someone out there on the SWT team that can help with any of this?
> > (I am prepared to get involved with this myself as well)
> >
|
|
|
Re: SWT Image ... Speed [message #584205 is a reply to message #30103] |
Mon, 07 October 2002 13:27 |
Scott Stanchfield Messages: 263 Registered: July 2009 |
Senior Member |
|
|
Here's what I'm using for AWT -> SWT image conversion. Seems to work quite
well w/o the JPEG intermediary. (I used to do the JPEG path as well...).
Note that the error processing needs work -- this is still a rough version
so I could get the "real stuff" in my GUI builder to work...
I haven't done any timings (ironically, I don't have time to time it ;) If
you time this let me know how it does...
java.awt.Image awtImage = ...;
int[] pixels = new int[c.getWidth() * c.getHeight()];
PixelGrabber pg = new PixelGrabber(awtImage, 0, 0, c.getWidth(),
c.getHeight(), pixels, 0, c.getWidth());
try {
pg.grabPixels();
}
catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels!");
return;
}
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
System.err.println("image fetch aborted or errored");
return;
}
ImageData dest = new ImageData(c.getWidth(), c.getHeight(), 32, new
PaletteData(0xFF0000,0xFF00,0xFF));
byte[] data = dest.data;
for (int i = 0, index = 0; i < c.getWidth() * c.getHeight(); i++, index+=4)
{
int pixel = pixels[i];
data[index] = (byte)((pixel >> 24) & 0xFF);
data[index + 1] = (byte)((pixel >> 16) & 0xFF);
data[index + 2] = (byte)((pixel >> 8) & 0xFF);
data[index + 3] = (byte)(pixel & 0xFF);
}
Image swtImage = new Image(null, dest);
-- Scott
============================================================ ==
Scott Stanchfield scott@javadude.com http://javadude.com
Lead author of "Effective VisualAge for Java, Version 3"
http://javadude.com/evaj
VisualAge for Java Tips and Tricks http://javadude.com/vaj
Visit for Java Enlightenment! http://www.jguru.com
============================================================ ==
"Justin Kilimnik" <justink@au.ibm.com> wrote in message
news:anqore$vbb$1@rogue.oti.com...
> I have been doing a lot of work lately with the Eclipse workbench and
> modifications to it, and a lot of work with SWT.
>
> One major problem I have noticed with SWT is the Image class. Doing a
> image read (1600x1200 JPEG) from the file system takes:
>
> 500ms in C++/Intel JPEG Graphics Lib
> ~1200ms in C# with .NET classes
> ~2000ms in Java using BufferedImageReader
> ~4000ms in SWT using the Image class and filename name constuctor
>
> There seems to be no way to convert the standard Java Images to SWT images
> so I am stuck with the bad performance of swt.Image. Is there anyway to
> speed this up? One of the features with the Intel Graphics lib is that you
> can (in simple terms) read the image size before loading the image fully
> and decide if you wish to only read every 2nd, 4th, 8th, 16th pixel from
> the file (which is a great feature when you are generating Thumbnails from
> large images.
>
> Is there someone out there on the SWT team that can help with any of this?
> (I am prepared to get involved with this myself as well)
>
|
|
|
Re: SWT Image ... Speed [message #584378 is a reply to message #30173] |
Mon, 07 October 2002 23:18 |
Justin Kilimnik Messages: 12 Registered: July 2009 |
Junior Member |
|
|
Thanks Scott,
I will test this out as soon as possible. With all the Java2D libs out
there it seems like we need some sort of bridge in this area....
Justin
Scott Stanchfield wrote:
> Here's what I'm using for AWT -> SWT image conversion. Seems to work quite
> well w/o the JPEG intermediary. (I used to do the JPEG path as well...).
> Note that the error processing needs work -- this is still a rough version
> so I could get the "real stuff" in my GUI builder to work...
> I haven't done any timings (ironically, I don't have time to time it ;) If
> you time this let me know how it does...
> java.awt.Image awtImage = ...;
> int[] pixels = new int[c.getWidth() * c.getHeight()];
> PixelGrabber pg = new PixelGrabber(awtImage, 0, 0, c.getWidth(),
> c.getHeight(), pixels, 0, c.getWidth());
> try {
> pg.grabPixels();
> }
> catch (InterruptedException e) {
> System.err.println("interrupted waiting for pixels!");
> return;
> }
> if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
> System.err.println("image fetch aborted or errored");
> return;
> }
> ImageData dest = new ImageData(c.getWidth(), c.getHeight(), 32, new
> PaletteData(0xFF0000,0xFF00,0xFF));
> byte[] data = dest.data;
> for (int i = 0, index = 0; i < c.getWidth() * c.getHeight(); i++, index+=4)
> {
> int pixel = pixels[i];
> data[index] = (byte)((pixel >> 24) & 0xFF);
> data[index + 1] = (byte)((pixel >> 16) & 0xFF);
> data[index + 2] = (byte)((pixel >> 8) & 0xFF);
> data[index + 3] = (byte)(pixel & 0xFF);
> }
> Image swtImage = new Image(null, dest);
> -- Scott
> ============================================================ ==
> Scott Stanchfield scott@javadude.com http://javadude.com
> Lead author of "Effective VisualAge for Java, Version 3"
> http://javadude.com/evaj
> VisualAge for Java Tips and Tricks http://javadude.com/vaj
> Visit for Java Enlightenment! http://www.jguru.com
> ============================================================ ==
> "Justin Kilimnik" <justink@au.ibm.com> wrote in message
> news:anqore$vbb$1@rogue.oti.com...
> > I have been doing a lot of work lately with the Eclipse workbench and
> > modifications to it, and a lot of work with SWT.
> >
> > One major problem I have noticed with SWT is the Image class. Doing a
> > image read (1600x1200 JPEG) from the file system takes:
> >
> > 500ms in C++/Intel JPEG Graphics Lib
> > ~1200ms in C# with .NET classes
> > ~2000ms in Java using BufferedImageReader
> > ~4000ms in SWT using the Image class and filename name constuctor
> >
> > There seems to be no way to convert the standard Java Images to SWT images
> > so I am stuck with the bad performance of swt.Image. Is there anyway to
> > speed this up? One of the features with the Intel Graphics lib is that you
> > can (in simple terms) read the image size before loading the image fully
> > and decide if you wish to only read every 2nd, 4th, 8th, 16th pixel from
> > the file (which is a great feature when you are generating Thumbnails from
> > large images.
> >
> > Is there someone out there on the SWT team that can help with any of this?
> > (I am prepared to get involved with this myself as well)
> >
|
|
|
Goto Forum:
Current Time: Sat Nov 09 02:28:29 GMT 2024
Powered by FUDForum. Page generated in 0.06048 seconds
|