freelanceprogrammers.org Forum Index » Java
Image flipping
Joined: 17 Apr 2004
Posts: 28
Image flipping
I found the error in my previous post(s) about figuring out why my
sprites wouldn`t paint: There was a `/` missing from my absolute
address variable. I fixed it. Now I need to know if there`s an easy
way in Java to flip an image. I don`t know if `flip` is the right term
for it. Okay, say there`s a sprite of a person that`s facing right. I
need to make the same sprite face left, preferably using the same image
file for both sprites. Is it possible, and if so, how can I do it?
-Michael Sullivan-
Joined: 10 Apr 2004
Posts: 19
Image flipping
Check out Graphics2D.rotate(double theta, double x, double y). That should do
what you need it to do. It first translates, then rotates, then translates
back. That should achieve a flip effect.
Dustin
Michael Sullivan <michael@...> wrote:
I found the error in my previous post(s) about figuring out why my
sprites wouldn`t paint: There was a `/` missing from my absolute
address variable. I fixed it. Now I need to know if there`s an easy
way in Java to flip an image. I don`t know if `flip` is the right term
for it. Okay, say there`s a sprite of a person that`s facing right. I
need to make the same sprite face left, preferably using the same image
file for both sprites. Is it possible, and if so, how can I do it?
-Michael Sullivan-
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/beginnersclub/
To unsubscribe from this group, send an email to:
beginnersclub-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
[Non-text portions of this message have been removed]
Joined: 17 Apr 2004
Posts: 28
Image flipping
I looked it up in the Java API reference, but I don`t understand. How
can I use this to manipulate images. Can you give me an example?
-Michael Sullivan-
On Sat, 2004-04-24 at 19:56, Dustin Metzgar wrote:
> Check out Graphics2D.rotate(double theta, double x, double y). That should do
what you need it to do. It first translates, then rotates, then translates
back. That should achieve a flip effect.
>
> Dustin
>
>
> Michael Sullivan <michael@...> wrote:
> I found the error in my previous post(s) about figuring out why my
> sprites wouldn`t paint: There was a `/` missing from my absolute
> address variable. I fixed it. Now I need to know if there`s an easy
> way in Java to flip an image. I don`t know if `flip` is the right term
> for it. Okay, say there`s a sprite of a person that`s facing right. I
> need to make the same sprite face left, preferably using the same image
> file for both sprites. Is it possible, and if so, how can I do it?
> -Michael Sullivan-
>
>
>
> ---------------------------------
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/beginnersclub/
>
> To unsubscribe from this group, send an email to:
> beginnersclub-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Photos: High-quality 4x6 digital prints for 25
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
Joined: 10 Apr 2004
Posts: 19
Image flipping
Actually, forget what I originally said, it`s much easier than I thought. You
can draw an image using the following:
public void paint(Graphics g) {
...
g.drawImage(img, 100, 100, 164, 164, 0, 0, 64, 64, null);
...
}
Where img is an Image object and the image is 64x64. All you have to do to flip
is change the corners for the source rectangle like so:
g.drawImage(img, 100, 100, 164, 164, 64, 0, 0, 64, null);
Dustin
Michael Sullivan <michael@...> wrote:
I looked it up in the Java API reference, but I don`t understand. How
can I use this to manipulate images. Can you give me an example?
-Michael Sullivan-
On Sat, 2004-04-24 at 19:56, Dustin Metzgar wrote:
> Check out Graphics2D.rotate(double theta, double x, double y). That should do
what you need it to do. It first translates, then rotates, then translates
back. That should achieve a flip effect.
>
> Dustin
>
>
> Michael Sullivan <michael@...> wrote:
> I found the error in my previous post(s) about figuring out why my
> sprites wouldn`t paint: There was a `/` missing from my absolute
> address variable. I fixed it. Now I need to know if there`s an easy
> way in Java to flip an image. I don`t know if `flip` is the right term
> for it. Okay, say there`s a sprite of a person that`s facing right. I
> need to make the same sprite face left, preferably using the same image
> file for both sprites. Is it possible, and if so, how can I do it?
> -Michael Sullivan-
>
>
>
---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
[Non-text portions of this message have been removed]
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







