Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3977 > unrolled thread

Anti-aliasing in image cl

Started by"Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this>
First post2011-04-27 15:48 +0000
Last post2011-04-27 15:48 +0000
Articles 12 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Anti-aliasing in image cl "Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
      Re: Anti-aliasing in imag "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: Anti-aliasing in imag "Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
      Re: Anti-aliasing in imag "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000

#3977 — Anti-aliasing in image cl

From"Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectAnti-aliasing in image cl
Message-ID<48a3826d$0$2239$ec3e2dad@news.usenetmonster.com>
  To: comp.lang.java.gui,comp.l
I've got a simple problem that I'm sure someone in this group can help me 
with.  Let me say what I'm currently doing first. 

I have an image that has some transparent portions and I want to cut a 
circle out of the image.  So first I trim it down to a square subimage 
and then I go through it pixel by pixel and set the alpha channel to 
clear for those pixels outside a circle with the sub-image's diameter. 

This works great.  I get close to exactly what I want.  The customer has 
added a new requirement that I need to deal with now.  The sub-image 
should have an anti-aliased border.  That is, the pixels on the outside 
of the circle shouldn't simply be on or off, but they should have an 
alpha channel value that would most look the sub-image like a circle.  

This is what you get when you use drawOval().  

My thought is to use drawOval() to create a mask for the image, but I'm 
not sure how to combine the mask with the image.  I can't simply set the 
alpha channel of the sub image to be the same as the alpha channel of my 
mask since the image may have some transparency in it too.  I'm quite 
sure that Java has a way to combine these images.  So how is it done?

Thanks.

-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
http://www.electricsenator.net

  The only two things that are infinite in size are the universe 
  and human stupidity. And I'm not completely sure about the universe.   
        -- Albert Einstein

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#3978 — Re: Anti-aliasing in imag

From"Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<op.ufuticmp8jd0ej@petes-computer.local>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 17:55:10 -0700, Kenneth P. Turvey  
<kt-usenet@squeakydolphin.com> wrote:

> I've got a simple problem that I'm sure someone in this group can help me
> with.  Let me say what I'm currently doing first.
>
> I have an image that has some transparent portions and I want to cut a
> circle out of the image.

Do you want to remove a circular area from inside the image?  Or do you  
want to use only a ciruclar area from inside the image as your new image?

That is, the transformed image, will it be the original image with a hole  
in it?  Or will it be the original image with everything outside the  
circular area excluded?

This description:

> So first I trim it down to a square subimage
> and then I go through it pixel by pixel and set the alpha channel to
> clear for those pixels outside a circle with the sub-image's diameter.

Makes me think you're taking a circular subset of the image, but other  
parts of your message seem to contradict that.  I'm a bit confused.

If I have understood the goal correctly, then it seems to me that the  
easiest way to transform your original image is to draw it into a new  
image, clipping to the circular shape you want.

For example, here's some code that works when just drawing into the  
Graphics2D passed to the paintComponent() method:

     // Where x, y, width, and height describe your circular area and image  
is a reference
     // to the image you want to clip

     Area areaOval = new Area(new Arc2D.Double(x, y, width, height, 0, 360,  
Arc2D.PIE));
     Shape shapeClipSave = gfx2.getClip();

     gfx2.setClip(areaOval);
     gfx2.drawImage(image, 0, 0, null);
     gfx2.setClip(shapeClipSave);

You should be able to use basically the same thing drawing into a  
Graphics2D instance you get from a new BufferedImage instance.  Just make  
sure you've enabled anti-aliased rendering, and when the image is drawn  
clipped into the new BufferedImage, the edges should wind up anti-aliased.

Pete

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3979 — Re: Anti-aliasing in imag

From"Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<48a39fd0$0$2158$ec3e2dad@news.usenetmonster.com>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 19:07:14 -0700, Peter Duniho wrote:

> On Wed, 13 Aug 2008 17:55:10 -0700, Kenneth P. Turvey
> <kt-usenet@squeakydolphin.com> wrote:
> 
>> I've got a simple problem that I'm sure someone in this group can help
>> me with.  Let me say what I'm currently doing first.
>>
>> I have an image that has some transparent portions and I want to cut a
>> circle out of the image.
> 
> Do you want to remove a circular area from inside the image?  Or do you
> want to use only a ciruclar area from inside the image as your new
> image?
> 
> That is, the transformed image, will it be the original image with a
> hole in it?  Or will it be the original image with everything outside
> the circular area excluded?
> 
> This description:
> 
>> So first I trim it down to a square subimage and then I go through it
>> pixel by pixel and set the alpha channel to clear for those pixels
>> outside a circle with the sub-image's diameter.
> 
> Makes me think you're taking a circular subset of the image, but other
> parts of your message seem to contradict that.  I'm a bit confused.
> 
> If I have understood the goal correctly, then it seems to me that the
> easiest way to transform your original image is to draw it into a new
> image, clipping to the circular shape you want.
> 
> For example, here's some code that works when just drawing into the
> Graphics2D passed to the paintComponent() method:
> 
>      // Where x, y, width, and height describe your circular area and
>      image
> is a reference
>      // to the image you want to clip
> 
>      Area areaOval = new Area(new Arc2D.Double(x, y, width, height, 0,
>      360,
> Arc2D.PIE));
>      Shape shapeClipSave = gfx2.getClip();
> 
>      gfx2.setClip(areaOval);
>      gfx2.drawImage(image, 0, 0, null);
>      gfx2.setClip(shapeClipSave);
> 
> You should be able to use basically the same thing drawing into a
> Graphics2D instance you get from a new BufferedImage instance.  Just
> make sure you've enabled anti-aliased rendering, and when the image is
> drawn clipped into the new BufferedImage, the edges should wind up
> anti-aliased.
> 
> Pete

I tried what you suggested, but with disappointing results.  Here's the 
altered method:

   private void clearOutsideCircle() {
        assert image.getWidth() == image.getHeight() : "Image should be 
square"; 
        int radius = image.getWidth() / 2; 
        Area areaOval = new Area(new Arc2D.Double(0, 0, image.getWidth(), 
                image.getHeight(), 0, 360, Arc2D.PIE));
        BufferedImage newImage = new BufferedImage(image.getWidth(), 
                image.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); 
        Graphics2D graphics = newImage.createGraphics();
        graphics.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, 
                RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); 
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
                RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.setClip(areaOval);
        graphics.drawImage(image, 0, 0, null); 
        image = newImage; 
    }

After this the image still doesn't look anti-aliased.  It seems like the 
clipping region is either on or off.  

Do you see anything in the code that might be the problem?  Any other 
suggestions?





-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
http://www.electricsenator.net

  Unix gives you just enough rope to hang yourself -- and then a couple
  of more feet, just to be sure.
        -- Eric Allman

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3981 — Re: Anti-aliasing in imag

From"John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<nospam-A15874.23181413082008@aioe.org>
In reply to#3979
  To: comp.lang.java.gui,comp.l
In article <48a39fd0$0$2158$ec3e2dad@news.usenetmonster.com>,
 "Kenneth P. Turvey" <kt-usenet@squeakydolphin.com> wrote:

> On Wed, 13 Aug 2008 19:07:14 -0700, Peter Duniho wrote:
> 
> > On Wed, 13 Aug 2008 17:55:10 -0700, Kenneth P. Turvey
> > <kt-usenet@squeakydolphin.com> wrote:
> > 
> >> I've got a simple problem that I'm sure someone in this group can help
> >> me with.  Let me say what I'm currently doing first.
> >>
> >> I have an image that has some transparent portions and I want to cut a
> >> circle out of the image.
> > 
> > Do you want to remove a circular area from inside the image?  Or do you
> > want to use only a ciruclar area from inside the image as your new
> > image?
> > 
> > That is, the transformed image, will it be the original image with a
> > hole in it?  Or will it be the original image with everything outside
> > the circular area excluded?
> > 
> > This description:
> > 
> >> So first I trim it down to a square subimage and then I go through it
> >> pixel by pixel and set the alpha channel to clear for those pixels
> >> outside a circle with the sub-image's diameter.
> > 
> > Makes me think you're taking a circular subset of the image, but other
> > parts of your message seem to contradict that.  I'm a bit confused.
> > 
> > If I have understood the goal correctly, then it seems to me that the
> > easiest way to transform your original image is to draw it into a new
> > image, clipping to the circular shape you want.
> > 
> > For example, here's some code that works when just drawing into the
> > Graphics2D passed to the paintComponent() method:
> > 
> >      // Where x, y, width, and height describe your circular area and
> >      image
> > is a reference
> >      // to the image you want to clip
> > 
> >      Area areaOval = new Area(new Arc2D.Double(x, y, width, height, 0,
> >      360,
> > Arc2D.PIE));
> >      Shape shapeClipSave = gfx2.getClip();
> > 
> >      gfx2.setClip(areaOval);
> >      gfx2.drawImage(image, 0, 0, null);
> >      gfx2.setClip(shapeClipSave);
> > 
> > You should be able to use basically the same thing drawing into a
> > Graphics2D instance you get from a new BufferedImage instance.  Just
> > make sure you've enabled anti-aliased rendering, and when the image is
> > drawn clipped into the new BufferedImage, the edges should wind up
> > anti-aliased.
> > 
> > Pete
> 
> I tried what you suggested, but with disappointing results.  Here's the 
> altered method:
> 
>    private void clearOutsideCircle() {
>         assert image.getWidth() == image.getHeight() : "Image should be 
> square"; 
>         int radius = image.getWidth() / 2; 
>         Area areaOval = new Area(new Arc2D.Double(0, 0, image.getWidth(), 
>                 image.getHeight(), 0, 360, Arc2D.PIE));
>         BufferedImage newImage = new BufferedImage(image.getWidth(), 
>                 image.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); 
>         Graphics2D graphics = newImage.createGraphics();
>         graphics.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, 
>                 RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); 
>         graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
>                 RenderingHints.VALUE_ANTIALIAS_ON);
>         graphics.setClip(areaOval);
>         graphics.drawImage(image, 0, 0, null); 
>         image = newImage; 
>     }
> 
> After this the image still doesn't look anti-aliased.  It seems like the 
> clipping region is either on or off.  
> 
> Do you see anything in the code that might be the problem?  Any other 
> suggestions?

Some implementations do better than others at honoring the hints. Try 
this with any .jpg:

import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;

public class Clip extends JPanel {

    private BufferedImage image;
    private Ellipse2D.Double border = new Ellipse2D.Double();

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Clip();
            }
        });
    }

    public Clip() {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(this);    
        try {
            image = ImageIO.read(new File("clip.jpg"));
        } catch (IOException ioe) {
            System.err.println(ioe);
            System.exit(1);
        }
        frame.setSize(new Dimension(
            image.getWidth(), image.getHeight()));
        frame.setVisible(true);
    }

    public void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

        int width = getWidth();
        int height = getHeight();
        g2d.setPaint(Color.BLUE);
        g2d.fillRect(0, 0, width, height);
        border.setFrame(0, 0, width, height);
        g2d.setClip(border);
        g2d.drawImage(image, 0, 0, width, height, this);
    }
}
-- 
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3980 — Re: Anti-aliasing in imag

From"Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<48a3a031$0$2158$ec3e2dad@news.usenetmonster.com>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 19:07:14 -0700, Peter Duniho wrote:

> On Wed, 13 Aug 2008 17:55:10 -0700, Kenneth P. Turvey
> <kt-usenet@squeakydolphin.com> wrote:
> 
>> I've got a simple problem that I'm sure someone in this group can help
>> me with.  Let me say what I'm currently doing first.
>>
>> I have an image that has some transparent portions and I want to cut a
>> circle out of the image.
> 
> Do you want to remove a circular area from inside the image?  Or do you
> want to use only a ciruclar area from inside the image as your new
> image?
> 
> That is, the transformed image, will it be the original image with a
> hole in it?  Or will it be the original image with everything outside
> the circular area excluded?
> 
> This description:
> 
>> So first I trim it down to a square subimage and then I go through it
>> pixel by pixel and set the alpha channel to clear for those pixels
>> outside a circle with the sub-image's diameter.
> 
> Makes me think you're taking a circular subset of the image, but other
> parts of your message seem to contradict that.  I'm a bit confused.
> 
> If I have understood the goal correctly, then it seems to me that the
> easiest way to transform your original image is to draw it into a new
> image, clipping to the circular shape you want.
> 
> For example, here's some code that works when just drawing into the
> Graphics2D passed to the paintComponent() method:
> 
>      // Where x, y, width, and height describe your circular area and
>      image
> is a reference
>      // to the image you want to clip
> 
>      Area areaOval = new Area(new Arc2D.Double(x, y, width, height, 0,
>      360,
> Arc2D.PIE));
>      Shape shapeClipSave = gfx2.getClip();
> 
>      gfx2.setClip(areaOval);
>      gfx2.drawImage(image, 0, 0, null);
>      gfx2.setClip(shapeClipSave);
> 
> You should be able to use basically the same thing drawing into a
> Graphics2D instance you get from a new BufferedImage instance.  Just
> make sure you've enabled anti-aliased rendering, and when the image is
> drawn clipped into the new BufferedImage, the edges should wind up
> anti-aliased.
> 
> Pete

I could go pixel by pixel through the image and use the minimum alpha of 
the mask and the image itself.  That would be pretty close to what I 
want, but it seems ugly.  Isn't there a way to combine an image with an 
alpha mask in an easy way?  

Thanks.





-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
http://www.electricsenator.net

  If you pick up a starving dog and make him prosperous, he will not
  bite you.  This is the principal difference between a man and a dog.
        -- Mark Twain

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3982 — Re: Anti-aliasing in imag

From"Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<op.ufu3mmsn8jd0ej@petes-computer.local>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 20:00:32 -0700, Kenneth P. Turvey  
<kt-usenet@squeakydolphin.com> wrote:

> [...]
> After this the image still doesn't look anti-aliased.  It seems like the
> clipping region is either on or off.
>
> Do you see anything in the code that might be the problem?  Any other
> suggestions?

Nope.  Your code looks fine to me (not sure why you want ABGR instead of  
ARGB, but either works fine on my computer).

Using basically the same code here, it generates an anti-aliased circular  
subset of the original image, just as intended.

Java 5, Mac OS 10.4.11

My best guess: you are either using some Java implementation that has poor  
or non-existent anti-aliasing support, or you're just mistaken about  
whether the results are anti-aliased or not.  I admit, by default I'd  
assume that neither is the case, but given that the code is simple and it  
works fine here, I've got to assume one or the other is actually the case  
after all.  :)

If you're not using an up-to-date, mainstream Java implementation, then  
you should try the same code on one that is.  If you already are (or if  
doing so produces the same results), then maybe you can post an example  
image that's been processed by your code somewhere that we can download  
and look at it.

Pete

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3984 — Re: Anti-aliasing in imag

From"Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<48a3e6df$0$2232$ec3e2dad@news.usenetmonster.com>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 22:59:01 -0700, Knute Johnson wrote:

> Peter Duniho wrote:
>> On Wed, 13 Aug 2008 20:00:32 -0700, Kenneth P. Turvey
>> <kt-usenet@squeakydolphin.com> wrote:
>> 
>>> [...]
>>> After this the image still doesn't look anti-aliased.  It seems like
>>> the clipping region is either on or off.
>>>
>>> Do you see anything in the code that might be the problem?  Any other
>>> suggestions?
>> 
>> Nope.  Your code looks fine to me (not sure why you want ABGR instead
>> of ARGB, but either works fine on my computer).
>> 
>> Using basically the same code here, it generates an anti-aliased
>> circular subset of the original image, just as intended.
>> 
>> Java 5, Mac OS 10.4.11
>> 
>> My best guess: you are either using some Java implementation that has
>> poor or non-existent anti-aliasing support, or you're just mistaken
>> about whether the results are anti-aliased or not.  I admit, by default
>> I'd assume that neither is the case, but given that the code is simple
>> and it works fine here, I've got to assume one or the other is actually
>> the case after all.  :)
>> 
>> If you're not using an up-to-date, mainstream Java implementation, then
>> you should try the same code on one that is.  If you already are (or if
>> doing so produces the same results), then maybe you can post an example
>> image that's been processed by your code somewhere that we can download
>> and look at it.
>> 
>> Pete
> 
> Graphics2D.clip() does not anti-alias.

Any ideas on how to do this then?





-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
http://www.electricsenator.net

  What is a gun toting economist on drugs?

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3985 — Re: Anti-aliasing in imag

From"Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<op.ufu5bvoi8jd0ej@petes-computer.local>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 22:59:01 -0700, Knute Johnson  
<nospam@rabbitbrush.frazmtn.com> wrote:

> Graphics2D.clip() does not anti-alias.

It does on my Mac.  YMMV.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3986 — Re: Anti-aliasing in imag

From"Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<48a3e73b$0$2232$ec3e2dad@news.usenetmonster.com>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 23:22:33 -0700, Peter Duniho wrote:

> On Wed, 13 Aug 2008 22:59:01 -0700, Knute Johnson
> <nospam@rabbitbrush.frazmtn.com> wrote:
> 
>> Graphics2D.clip() does not anti-alias.
> 
> It does on my Mac.  YMMV.

I'm not seeing it here either.  Let me take a closer look.  I should be 
able to see the anti-aliasing even on a simple mat background shouldn't I?





-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
http://www.electricsenator.net

  Luge strategy?  Lie flat and try not to die.
        -- Tim Steeves

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3987 — Re: Anti-aliasing in imag

From"Kenneth P. Turvey" <kenneth.p..turvey@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<48a3e91c$0$2232$ec3e2dad@news.usenetmonster.com>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Wed, 13 Aug 2008 20:57:55 -0700, Knute Johnson wrote:

> I just answered this post in comp.lang.gui and now I see the back and
> forth.  If all you want is an anti-aliased mask use the code below.
> Don't mess with your image, it's just too much work.  If you want a
> fancier matte around the image see the other post.
> 
> import java.awt.*;
> import java.awt.event.*;
[Snip]

Thanks.  I can create the alpha mask.  I understand how to do that.  The 
problem I'm having is that I have an image with some alpha in it and now 
I want to apply the mask to the image.  The idea is to get an image that 
is circular, where everything outside the circle is blank, and where the 
edges of the image are anti-aliased so when it is placed on top of a 
background, it looks like a neat circle without jagged edges. 

I'd like to be able to do this without going through the image pixel by 
pixel, but that might be the best way to accomplish it, I guess.





-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
http://www.electricsenator.net

  A computer lets you make more mistakes faster than any invention in
  human history with the possible exceptions of handguns and tequila.
        -- Mitch Ratliffe, Technology Review, April, 1992

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3989 — Re: Anti-aliasing in imag

From"Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<op.ufvc9wbm8jd0ej@petes-computer.local>
In reply to#3977
  To: comp.lang.java.gui,comp.l
On Thu, 14 Aug 2008 01:05:15 -0700, Kenneth P. Turvey  
<kt-usenet@squeakydolphin.com> wrote:

> On Wed, 13 Aug 2008 23:22:33 -0700, Peter Duniho wrote:
>
>> On Wed, 13 Aug 2008 22:59:01 -0700, Knute Johnson
>> <nospam@rabbitbrush.frazmtn.com> wrote:
>>
>>> Graphics2D.clip() does not anti-alias.
>>
>> It does on my Mac.  YMMV.
>
> I'm not seeing it here either.  Let me take a closer look.  I should be
> able to see the anti-aliasing even on a simple mat background shouldn't  
> I?

I'm not entirely sure what you mean.  Did you mean "matte background", as  
in a single-color background?

If so, then assuming the background is a different color than that on  
which you're viewing the transformed (clipped) version, yes...I'd think  
you should be able to note the anti-aliasing, if it's happening.

Now, that said...spurred by yours and Knute's comments, I tried  
_disabling_ anti-aliasing in my code, and I still get anti-aliased  
rendering.  This makes me suspect that the anti-aliasing is being done at  
the platform level, not under the control of the Java run-time itself.

So, I guess the best answer I can provide is "run your code on a Mac".  :)

As a solution to your immediate problem, you may find that overkill.  I  
can't say that I'd disagree.  But it's all I can come up with at the  
moment.  :)

Pete

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3990 — Re: Anti-aliasing in imag

From"John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: Anti-aliasing in imag
Message-ID<nospam-6EC9E6.10343614082008@aioe.org>
In reply to#3989
  To: comp.lang.java.gui,comp.l
In article <op.ufvc9wbm8jd0ej@petes-computer.local>,
 "Peter Duniho" <NpOeStPeAdM@nnowslpianmk.com> wrote:

> On Thu, 14 Aug 2008 01:05:15 -0700, Kenneth P. Turvey  
> <kt-usenet@squeakydolphin.com> wrote:
> 
> > On Wed, 13 Aug 2008 23:22:33 -0700, Peter Duniho wrote:
> >
> >> On Wed, 13 Aug 2008 22:59:01 -0700, Knute Johnson
> >> <nospam@rabbitbrush.frazmtn.com> wrote:
> >>
> >>> Graphics2D.clip() does not anti-alias.
> >>
> >> It does on my Mac.  YMMV.
[...]
> Now, that said...spurred by yours and Knute's comments, I tried  
> _disabling_ anti-aliasing in my code, and I still get anti-aliased  
> rendering.

I get the same effect, looking with Pixie at high magnification. 

> This makes me suspect that the anti-aliasing is being done at the 
> platform level, not under the control of the Java run-time itself.

I think so. Setting -Dapple.awt.graphics.UseQuartz=false prevents the 
anti-aliasing even when the hint is on.

[...]

-- 
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web