Learning Java: Part 28: Image Rotation

preview_player
Показать описание

I had to reupload this tutorial due to the lack of zoom or focus! My apologies! In this tutorial I will be altering our RectangleImage class to support the rotation of images. This has many applications, especially in the gaming world.

Thanks for watching!

Discuss this video and see the source code:
Рекомендации по теме
Комментарии
Автор

I saw this tutoruial once, and didn't understand it.
Now, about one year and a half later, I the temporary fix I found wasn't just enough, and found this tutorial again.
It's the ONLY ONE over the ENTIRE internet, that actually does what it should do !!
also, if you extend the blank Canvas by like 20 pixels, you can rotate the big square around in the middle of it without it being clipped !

axelallmighty
Автор

One doesn't simply rotate an image in java.

miraknroll
Автор

the only tutorial on the internet that can explain this properly, thanks a lot :D

Reviews
Автор

I once made an image rotating project in java where I actually got the location of the pixel and calculated the new location using trigonometry. The image actually came out rotated but there were holes on it because we had to convert floating point numbers to integers. that's probably why the quality got diminished.

JackLe
Автор

I favorite this video :) I'm actually making a Java video game layout. I have implemented direction movement, top-down movement and animation. I want to be able to rotate an image with the direction system I built. I am also working on a path finding algorithm! Keep the good tutorials because they are amazing :3

lesavaria
Автор

Stuff like this is what I like learning!

Eevvsislluft
Автор

If you need to spread out boundaries, try this:

BufferedImage blankCanvas = new BufferedImage(originalWidth*2, originalHeight*2, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = (Graphics2D) blankCanvas.getGraphics();
g2.rotate(Math.toRadians(degreesTest++), originalWidth, originalHeight);
g2.drawImage(original, (int) originalWidth/2, (int) originalHeight/2, null);
rotated = blankCanvas;

aunmag
Автор

Thank you very much for all your videos.

milanjuranic
Автор

Thanks for tutorial. Did you manage to rotate the rectangle? Because I didnt :( How to do that?

MartiniiKn
Автор

in my way to school i was thinking about the game i'm working on and i actually tought that i need to learn image rotation (i want to make a 2d CastleDefender-Platformer where you would make a castle and after like 1-2 minutes the monsters are coming and you would swing your sword shoot your bow, cannon and more stuff)

AndreiXd
Автор

Please upload video for how to convert image into matrix value

vishalirajan
Автор

Instead of using getGraphics() and casting to g2d you can use createGraphics() which does the same thing but with g2d, in fact getGraphics() calls createGraphics() and returns its value, automatically casting it to Graphics from Graphics2D.

augustas
Автор

What Java editor are you using. I can't find one.

WhatsRagePlaying
visit shbcf.ru