Skip to main content

[JAVA2D] Artifacts when using drawRenderedImage.

4 replies [Last post]
Anonymous

Hi List,
I am exeperiencing a strange problem when working with Java2D. I am
working on small component for showing images using Java2D with
support for zoom and pan. Everything works fine on various machines
but I found a window XP box where zooming in produces an image where
the colors are completely different from the non-zoomed version. I
debugged the code a lot and I found that the problem is actually when
I draw on a Volatile image graphic context as follows

dispGc.drawRenderedImage(offScreenImage,
offScreenToComponentTransform);

applying contextually an affine transform.

I tried to apply the same transform separately by leveraging the
BufferedImageOp subclass and the problem disappeared. At this point I
am quite sure that this is a bug of my version of JDK, I would like to
know if I am right or not or if anyone has a bright idea for solving
this annoying issue.

PS
Machine has Windows Xp sp2 , JDK 1.4.2.09.

Simone.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Dmitri Trembovetski

Hi Simone,

looks like you've run into one of the known problems.

Could you try with jdk5.0? There were a number of fixes in this area
since 1.4.2

Thanks,
Dmitri
Java2D Team

On Tue, Dec 13, 2005 at 12:35:32PM +0100, simone giannecchini wrote:
> Hi List,
> I am exeperiencing a strange problem when working with Java2D. I am
> working on small component for showing images using Java2D with
> support for zoom and pan. Everything works fine on various machines
> but I found a window XP box where zooming in produces an image where
> the colors are completely different from the non-zoomed version. I
> debugged the code a lot and I found that the problem is actually when
> I draw on a Volatile image graphic context as follows
>
> dispGc.drawRenderedImage(offScreenImage,
> offScreenToComponentTransform);
>
> applying contextually an affine transform.
>
> I tried to apply the same transform separately by leveraging the
> BufferedImageOp subclass and the problem disappeared. At this point I
> am quite sure that this is a bug of my version of JDK, I would like to
> know if I am right or not or if anyone has a bright idea for solving
> this annoying issue.
>
> PS
> Machine has Windows Xp sp2 , JDK 1.4.2.09.
>
> Simone.
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

simone giannecchini

Hi Dimitri,
I updated to JDK1.5 but nothing changed, I tried to disable ddraw but
with no luck. I am running out of ideas, hope you can provide some
other hints.

Simone.

On 12/13/05, Dmitri Trembovetski wrote:
> Hi Simone,
>
> looks like you've run into one of the known problems.
>
> Could you try with jdk5.0? There were a number of fixes in this area
> since 1.4.2
>
> Thanks,
> Dmitri
> Java2D Team
>
> On Tue, Dec 13, 2005 at 12:35:32PM +0100, simone giannecchini wrote:
> > Hi List,
> > I am exeperiencing a strange problem when working with Java2D. I am
> > working on small component for showing images using Java2D with
> > support for zoom and pan. Everything works fine on various machines
> > but I found a window XP box where zooming in produces an image where
> > the colors are completely different from the non-zoomed version. I
> > debugged the code a lot and I found that the problem is actually when
> > I draw on a Volatile image graphic context as follows
> >
> > dispGc.drawRenderedImage(offScreenImage,
> > offScreenToComponentTransform);
> >
> > applying contextually an affine transform.
> >
> > I tried to apply the same transform separately by leveraging the
> > BufferedImageOp subclass and the problem disappeared. At this point I
> > am quite sure that this is a bug of my version of JDK, I would like to
> > know if I am right or not or if anyone has a bright idea for solving
> > this annoying issue.
> >
> > PS
> > Machine has Windows Xp sp2 , JDK 1.4.2.09.
> >
> > Simone.
> >
> > ===========================================================================
> > To unsubscribe, send email to listserv@java.sun.com and include in the body
> > of the message "signoff JAVA2D-INTEREST". For general help, send email to
> > listserv@java.sun.com and include in the body of the message "help".
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

simone giannecchini

Hi again,
I found finally how to remove the problem but I am not satisfied at
all by the result.

Let me summarise. Problem was that while drawing on the graphics
created from a VolatileImage using an affine transform I was getting
poor results, low quality and strange color. I updated to jdk1.5, I
disabled the rendering hints for quality that I was using by
commenting them out as follows

// g2D.setRenderingHint(RenderingHints.KEY_RENDERING,
// RenderingHints.VALUE_RENDER_QUALITY);
// g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
// RenderingHints.VALUE_ANTIALIAS_ON);
// g2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
// RenderingHints.VALUE_INTERPOLATION_BILINEAR);

and all problems disappeard. Unfortunately now the quality is poor
since I have no antialiasing. How can I solve this problem while still
having good quality?

Simone.
On 12/14/05, simone giannecchini wrote:
> Hi Dimitri,
> I updated to JDK1.5 but nothing changed, I tried to disable ddraw but
> with no luck. I am running out of ideas, hope you can provide some
> other hints.
>
> Simone.
>
> On 12/13/05, Dmitri Trembovetski wrote:
> > Hi Simone,
> >
> > looks like you've run into one of the known problems.
> >
> > Could you try with jdk5.0? There were a number of fixes in this area
> > since 1.4.2
> >
> > Thanks,
> > Dmitri
> > Java2D Team
> >
> > On Tue, Dec 13, 2005 at 12:35:32PM +0100, simone giannecchini wrote:
> > > Hi List,
> > > I am exeperiencing a strange problem when working with Java2D. I am
> > > working on small component for showing images using Java2D with
> > > support for zoom and pan. Everything works fine on various machines
> > > but I found a window XP box where zooming in produces an image where
> > > the colors are completely different from the non-zoomed version. I
> > > debugged the code a lot and I found that the problem is actually when
> > > I draw on a Volatile image graphic context as follows
> > >
> > > dispGc.drawRenderedImage(offScreenImage,
> > > offScreenToComponentTransform);
> > >
> > > applying contextually an affine transform.
> > >
> > > I tried to apply the same transform separately by leveraging the
> > > BufferedImageOp subclass and the problem disappeared. At this point I
> > > am quite sure that this is a bug of my version of JDK, I would like to
> > > know if I am right or not or if anyone has a bright idea for solving
> > > this annoying issue.
> > >
> > > PS
> > > Machine has Windows Xp sp2 , JDK 1.4.2.09.
> > >
> > > Simone.
> > >
> > > ===========================================================================
> > > To unsubscribe, send email to listserv@java.sun.com and include in the body
> > > of the message "signoff JAVA2D-INTEREST". For general help, send email to
> > > listserv@java.sun.com and include in the body of the message "help".
> >
> > ===========================================================================
> > To unsubscribe, send email to listserv@java.sun.com and include in the body
> > of the message "signoff JAVA2D-INTEREST". For general help, send email to
> > listserv@java.sun.com and include in the body of the message "help".
> >
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Dmitri Trembovetski

Hi Simone,

here's the bug you're running into:
4886732: AffineTransformOp does not work properly for some of the rendering hints

The workaround is not to use RENDER_QUALITY and _BILINEAR hints. I
think you'd get acceptable results w/o the RENDER_QUALITY hint - try
it.

The antialiasing hint should not affect this bug, so you can leave
it on (it doesn't affect rendering of images).

Thank you,
Dmitri

On Wed, Dec 14, 2005 at 01:17:07PM +0100, simone giannecchini wrote:
> Hi again,
> I found finally how to remove the problem but I am not satisfied at
> all by the result.
>
> Let me summarise. Problem was that while drawing on the graphics
> created from a VolatileImage using an affine transform I was getting
> poor results, low quality and strange color. I updated to jdk1.5, I
> disabled the rendering hints for quality that I was using by
> commenting them out as follows
>
> // g2D.setRenderingHint(RenderingHints.KEY_RENDERING,
> // RenderingHints.VALUE_RENDER_QUALITY);
> // g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
> // RenderingHints.VALUE_ANTIALIAS_ON);
> // g2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
> // RenderingHints.VALUE_INTERPOLATION_BILINEAR);
>
> and all problems disappeard. Unfortunately now the quality is poor
> since I have no antialiasing. How can I solve this problem while still
> having good quality?
>
>
> Simone.
> On 12/14/05, simone giannecchini wrote:
> > Hi Dimitri,
> > I updated to JDK1.5 but nothing changed, I tried to disable ddraw but
> > with no luck. I am running out of ideas, hope you can provide some
> > other hints.
> >
> > Simone.
> >
> > On 12/13/05, Dmitri Trembovetski wrote:
> > > Hi Simone,
> > >
> > > looks like you've run into one of the known problems.
> > >
> > > Could you try with jdk5.0? There were a number of fixes in this area
> > > since 1.4.2
> > >
> > > Thanks,
> > > Dmitri
> > > Java2D Team
> > >
> > > On Tue, Dec 13, 2005 at 12:35:32PM +0100, simone giannecchini wrote:
> > > > Hi List,
> > > > I am exeperiencing a strange problem when working with Java2D. I am
> > > > working on small component for showing images using Java2D with
> > > > support for zoom and pan. Everything works fine on various machines
> > > > but I found a window XP box where zooming in produces an image where
> > > > the colors are completely different from the non-zoomed version. I
> > > > debugged the code a lot and I found that the problem is actually when
> > > > I draw on a Volatile image graphic context as follows
> > > >
> > > > dispGc.drawRenderedImage(offScreenImage,
> > > > offScreenToComponentTransform);
> > > >
> > > > applying contextually an affine transform.
> > > >
> > > > I tried to apply the same transform separately by leveraging the
> > > > BufferedImageOp subclass and the problem disappeared. At this point I
> > > > am quite sure that this is a bug of my version of JDK, I would like to
> > > > know if I am right or not or if anyone has a bright idea for solving
> > > > this annoying issue.
> > > >
> > > > PS
> > > > Machine has Windows Xp sp2 , JDK 1.4.2.09.
> > > >
> > > > Simone.
> > > >
> > > > ===========================================================================
> > > > To unsubscribe, send email to listserv@java.sun.com and include in the body
> > > > of the message "signoff JAVA2D-INTEREST". For general help, send email to
> > > > listserv@java.sun.com and include in the body of the message "help".
> > >
> > > ===========================================================================
> > > To unsubscribe, send email to listserv@java.sun.com and include in the body
> > > of the message "signoff JAVA2D-INTEREST". For general help, send email to
> > > listserv@java.sun.com and include in the body of the message "help".
> > >
> >

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".