Rotate bitmap

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
104
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,094
Reaction score
365
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

Would be nice to pick color code that is not exclusively for message event
The Ace attorney series are so great games... But at the same time such a travesty.
Made a video showcasing a plugin (by Lanza) that adds 5 more weather effects to our MV games. :LZYsmile: Namely:
Ash-dust,
bloodrain,
Cherry Blossom Petals,
Hail,
and bubbles.

Forum statistics

Threads
103,239
Messages
998,301
Members
134,729
Latest member
Takufy
Top