Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3978
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail |
|---|---|
| From | "Peter Duniho" <peter.duniho@THRWHITE.remove-dii-this> |
| Subject | Re: Anti-aliasing in imag |
| Message-ID | <op.ufuticmp8jd0ej@petes-computer.local> (permalink) |
| X-Comment-To | comp.lang.java.gui,comp.l |
| Newsgroups | comp.lang.java.gui |
| In-Reply-To | <48a3826d$0$2239$ec3e2dad@news.usenetmonster.com> |
| References | <48a3826d$0$2239$ec3e2dad@news.usenetmonster.com> |
| Content-Type | text/plain; charset=IBM437 |
| Content-Transfer-Encoding | 8bit |
| X-Gateway | time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] |
| Lines | 56 |
| Date | Wed, 27 Apr 2011 15:48:01 GMT |
| NNTP-Posting-Host | 96.60.20.240 |
| X-Complaints-To | news@tds.net |
| X-Trace | newsreading01.news.tds.net 1303919281 96.60.20.240 (Wed, 27 Apr 2011 10:48:01 CDT) |
| NNTP-Posting-Date | Wed, 27 Apr 2011 10:48:01 CDT |
| Organization | TDS.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.gui:3978 |
Show key headers only | View raw
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
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web