Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31895
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2015-06-30 12:07 -0700 |
| References | <mmuhle$gp1$1@dont-email.me> |
| Message-ID | <228707c4-33ce-4901-9636-97e08cf6ff84@googlegroups.com> (permalink) |
| Subject | Re: Image rotation part 2 |
| From | e.d.programmer@gmail.com |
On Tuesday, June 30, 2015 at 12:56:43 PM UTC-4, Martin Gregorie wrote: > Thanks to help from Knute about five 11 months ago I was able to create > JLabel subclasses that could display vertically aligned text, e.g. > > N > a > m > e > > by using HTML text, e.g. "<html>N<br>a<br>m<br>e</html>" This works well, > except that some of the longer names create very tall instances that use > up more screen than I can really spade (the row of names is near the top > of a matrix which has 50+ lines below it, so it would be nice to avoid as > much scrolling up and down as possible. > > Having noticed that most Monospaced characters are just over half as wide > as they are high, I'm again thinking about somehow standing the character > string on end by rotating it through 90 degrees. I'm successfully > creating a JPG image containing black 10 pt Monospaced text on a > LIGHT_GRAY background within a minimal window (20 pixels high and > s.length() * (fontsize * 7 / 10) wide, whenever I try to rotate it, all > I'm getting is a solid black image thats rotated so its longest dimension > is now vertical. > > The code looks like this: > > BufferedImage im = new BufferedImage(width, > height, > BufferedImage.TYPE_INT_RGB); > > // image created in im > > BufferedImage om = new BufferedImage(height, > width, > BufferedImage.TYPE_INT_RGB); > AffineTransform at = new AffineTransform(); > at.setToQuadrantRotation(-1); > AffineTransformOp aop = new AffineTransformOp(at, > AffineTransformOp.TYPE_BILINEAR); > aop.filter(im, om); > > I've also tried setting the AffineTransformOp to TYPE_BICUBIC but that > also gave a black rectangle. > > I'm obviously doing something stupid or have missed out a vital step, but > what? > > > -- > martin@ | Martin Gregorie > gregorie. | Essex, UK > org | Are you trying to rotate text or an image? Which direction is the original? Which direction did you need it to face after rotating? To rotate an image I just create a new AffineTransform, scale it, rotate it, and pass it into my drawImage method. If it's a perfect square the rotate method should be easy, just pass in the Math.toRadians(drawRotationAngle). If it's a rectangle, not a square, and you want to turn it 90 degrees and squish it to fit the same space you need to calculate a new x/y.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 16:55 +0000
Re: Image rotation part 2 Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-06-30 14:03 -0400
Re: Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 20:04 +0000
Re: Image rotation part 2 Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-06-30 16:20 -0400
Re: Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 20:52 +0000
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-06-30 12:07 -0700
Re: Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 20:18 +0000
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-06-30 19:04 -0400
Re: Image rotation part 2 Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-06-30 16:36 -0700
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-06-30 20:17 -0400
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-06-30 20:09 -0400
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-07-01 06:06 -0700
Re: Image rotation part 2 FredK <fred.l.kleinschmidt@gmail.com> - 2015-07-01 10:57 -0700
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-07-01 18:13 -0400
Re: Image rotation part 2 Arne Vajhøj <arne@vajhoej.dk> - 2015-07-27 22:28 -0400
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-07-28 04:58 -0700
Re: Image rotation part 2 Arne Vajhøj <arne@vajhoej.dk> - 2015-07-28 18:58 -0400
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-07-29 05:35 -0700
csiph-web