Rotate bitmap

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
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,309
Reaction score
531
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 Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top