Trying to use rotate_scaled_sprite()... trouble with 'fixed'
peelemachine

I can scale my bitmap, but I need to rotate it too.

The rotate_scaled_sprite() function needs a 'fixed' argument, unlike stretch_sprite() which lets you specify the scaling in width and height. How do i convert width and height into 'fixed' for scaling?

Thanks

HoHo
peelemachine

I know about those, but they don't help.

I need to get two different integers into 1 fixed.

X-G

Not possible. At least not what you seem to want to do.

Kibiz0r

There's no function for what you want to do, you'll have to write the algorithm yourself using some crazy trig I don't care to work out right now. (I'm in class)

Kris Asick

What exactly do you mean by "two different integers"?

If you're trying to combine one integer as the whole value and another as the decimal value, you could try this:

fixed fixed_val = ftofix((float)decimal_int/1000.0f+(float)whole_int);

Though if that's the case, I'd have to question your sanity for keeping track of the two separately in the first place. :P

--- Kris Asick (Gemini)
--- http://www.pixelships.con

peelemachine

All i want to do is rotate and stretch the sprite at the same time, to a specific width and height. I just want to use the function.

Kibiz0r

I believe he wants to keep a sprite bounded by a certain width and height, no matter what the rotation.

Hard Rock
Quote:

What exactly do you mean by "two different integers"?

If you're trying to combine one integer as the whole value and another as the decimal value

Thats not it at all. In fact the question is quite clear.

stretch_sprite() takes two parameters (width, height to stetch) whereas rotate_scaled_sprite() takes one parameter, the scale.

Anyway to try to answer you question, you cant scale an image like you are doing with stretch blit, as scale requires you to do it proportionately. However you can do this:

fixed scale = ftofix( new_sprite_height/actual_sprite_height)

And use that as a parameter, although this assumes you have kept the stretching proportional. If not then you'll either have to write your own function which lets you do exactly what you are asking as it appears stretch_sprite may not have the functionality you require. Or use a more specific approximation (which you should be able to come up with on your own as mentioned a few time).

Kris Asick

Ok, I see what you're getting at.

Well, if you're only going to scale the sprite equally on both axises at the same time, that's simple enough to do. You simply make a multiplier variable and apply that to the rotate_scaled_sprite() function for the scale argument.

However, if you want to stretch both axises independently, like you can with stretch_sprite(), you need to make a few extra steps and an extra bitmap. Do the following:

1: Make an extra bitmap (we'll call it "xbitmap") large enough to fit the largest stretching your sprite will ever reach.

2: When the stretched size of the sprite changes, clear xbitmap to the masked colour for your video mode, (IE: bitmap_mask_color(xbitmap)), and then call stretch_sprite() on your sprite to draw it to the centre of xbitmap.

3: Draw xbitmap to the screen using rotate_sprite().

Does that help? Note that this method will NOT be very fast at all, since it has to detect and skip over all those empty masked pixels in xbitmap, but it's the only thing I can think of off-hand that will give you independent control over height and width. (Using rotate_scaled_sprite(), you control the overall size, not the height and width.)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

gnolam
Quote:

Does that help? Note that this method will NOT be very fast at all, since it has to detect and skip over all those empty masked pixels in xbitmap, but it's the only thing I can think of off-hand that will give you independent control over height and width.

stretch_blit()

peelemachine

Thanks for the help you guys.

I can live with proportional scaling and rotation, so I'll use the ftofix idea. I didn't know what kind of value the 'fixed scale' parameter needed to be, now I understand. Thanks again.

Kris Asick

gnolam: ...with rotation. ;)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

X-G

His point is that it's wasteful to stretch_sprite onto xbitmap, since the background is just going to be magic pink anyway. Using stretch_blit will be faster and produce the same result.

Kris Asick
Quote:

His point is that it's wasteful to stretch_sprite onto xbitmap, since the background is just going to be magic pink anyway. Using stretch_blit will be faster and produce the same result.

...oh yeah! ;D

I think too fast sometimes... ::)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Johan Peitz

[nothing]

Thread #590650. Printed from Allegro.cc