Rotate bitmap

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
99
Reaction score
20
First Language
Italian
Hi,

 I need to rotate a bitmap and store the result (keeping the original intact). I tried to do what written in this topic http://forums.rpgmakerweb.com/index.php?/topic/48225-how-to-rotate-bitmap/ 

but the image i want to rotate has the alpha and when the code redraws it after the rotation the old bitmap and the new rotate one overlay eachother. It would be even better to mirror the bitmap but having both funcitons would be handy

basically what i need is something like this:

var bitmap = new Bitmap(w, h);bitmap = ImageManager.loadSprite('file path');// BITMAP ROTATIONvar rotatedBitmap = new Bitmap(w, h);rotatedBitmap = bitmap.rotate(90); //I want the rotate method to retrun a value, not modify the source image// BITMAP MIRRORING (EVEN BETTER FOR ME)var mirroredBitmap = new Bitmap(w, h);rotatedBitmap = bitmap.mirror(axis);For now I just need 90 degrees rotations and horizontal or vertical flips only, but a code that works with every kind of rotation / mirror axis inclination would be good.

Any idea how to write "Bitmap.rotate()" and "Bitmap.mirror()"?

Thank you
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,033
Reaction score
338
First Language
indonesian
in my plugin EST - GRAPHIC SHIFT EVO...

(link in my signature)

i hijack Sprite_Character to modify how the bitmap drawn...

so maybe using sprite would be better.

since inside sprite object...

this.scale.x = -this.scale.x;

will flip the image horizontally

this.scale.y = -this.scale.y;

will flip the image vertically

this.rotation = 90 * Math.PI / 180;

will rotate graphic 90 degrees...

hope this help.

you could also revert your bitmap back by changing the value inside sprite object... since your actual bitmap is not modified...
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Free RPG Maker Ready Charging Up Animation

Enjoy -No Credit Needed But Appreciated -
Download it at https://lvgames.itch.io/free-charging-up-pixel-animation-fx-rpg-maker-ready
:/ .... so, thought I’d go to the park to sit in the cool breeze and get out of the house a little. Nope, guess that’s quarantined too. Ok...
How do you do when you want to work on projects but the game companies make so many games available for free because of the quarantine?
Kes
I have just stepped down from being a Mod, so please don't send me any more pm's with Mod questions. Thanks
Made a brief video showcasing early game play... Got a copyright claim by BIG UP! (https://big-up.style/) for using music I bought from here (Future Steam Punk Pack). Now I wonder if I should strip any purchased music from here out of my game. :LZSskeptic:

Forum statistics

Threads
95,486
Messages
929,499
Members
125,726
Latest member
Truvirian
Top