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


Groups > comp.lang.java.programmer > #27962

Re: Mirror an image

From Wanja Gayk <brixomatic@yahoo.com>
Newsgroups comp.lang.java.programmer
Subject Re: Mirror an image
Date 2014-04-06 20:18 +0200
Organization Netfront http://www.netfront.net/
Message-ID <MPG.2da540be1aa5795117@202.177.16.121> (permalink)
References <2299213c-18fc-4e55-ab39-22dce863b255@googlegroups.com> <jt2mj9t2uv0jdos76t4otlb8lgfoc1udnn@4ax.com>

Show all headers | View raw


In article <jt2mj9t2uv0jdos76t4otlb8lgfoc1udnn@4ax.com>, Roedy Green 
(see_website@mindprod.com.invalid) says...
> 
> On Tue, 1 Apr 2014 07:44:03 -0700 (PDT), pgmbento93@gmail.com wrote,
> quoted or indirectly quoted someone who said :
> 
> >dont pay attention to the the comments.. what can i do? im new in java and =
> >i dont know what to do
> 
> The trick I suspect is to use an Affine transform to map each point to
> its corresponding new position.
> 
> See http://mindprod.com/jgloss/affinetransform.html

Mirroring is actually much easier: Just use a negative width or height 
for the Graphics#drawImage method.

Without any test, this would be my first, rough idea:

The image:
+-----+
+AAAAA+
+BBBBB+
+CCCCC+
+DDDDD+
+-----+

public void paintComponent(Graphics _g){
 final Graphics2D g = (Graphics2D)_g;
 g.setClip( /* upper half, covering lines A and B */)
 g.drawImage( image, 0, 0 , width, height); //height > 0!
 g.setClip( /* lower half, covering lines C and D */)
 g.drawImage( image, bottomLeftCorner, width, -height); //height < 0!
}

Should result in:
+-----+
+AAAAA+
+BBBBB+
+BBBBB+
+AAAAA+
+-----+

Not sure if that's bottom half corner or middle left, but that's just 
one attempt away, if it doesn't work as expected.

Have fun.

Kind regards,
-Wanja-

-- 
..Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Mirror an image pgmbento93@gmail.com - 2014-04-01 07:44 -0700
  Re: Mirror an image Jeff Higgins <jeff@invalid.invalid> - 2014-04-01 11:09 -0400
    Re: Mirror an image Jeff Higgins <jeff@invalid.invalid> - 2014-04-01 11:15 -0400
  Re: Mirror an image Roedy Green <see_website@mindprod.com.invalid> - 2014-04-01 11:56 -0700
    Re: Mirror an image Wanja Gayk <brixomatic@yahoo.com> - 2014-04-06 20:18 +0200
      Re: Mirror an image Jeff Higgins <jeff@invalid.invalid> - 2014-04-06 18:01 -0400
        Re: Mirror an image Wanja Gayk <brixomatic@yahoo.com> - 2014-04-13 15:57 +0200
          Re: Mirror an image Jeff Higgins <jeff@invalid.invalid> - 2014-04-13 10:21 -0400

csiph-web