Scaling in C++ plugins

Started by violgamba, Sat 16/04/2011 02:15:00

Previous topic - Next topic

violgamba

Hi everyone.  I'm a longtime fan, player and developer of AGS, though I barely ever post (or finish any projects :P).  I've finally hit a development wall that I can't seem to forum-search my way over, so I'm breaking the silence.
Hi.  :D
I'm working with the C++ plugin system at the moment and am trying to scale a BITMAP object.  I've found that you can blit, translucent-blit, and rotate-blit BITMAPs around, but the functionality to scale-blit seems to be a glaring ommision.  Am I missing something?  I sure hope so.  I really need to be able to scale the virtual screen to a BITMAP buffer and visa-versa.

Thanks for any help you can provide.
-Jon


violgamba

Also, a related question, if I may ;D:
The "BlitSpriteRotated" allows for 255 points of rotation.  Is there any way to get a finer grain of rotational control?  I'm trying to do a subtle, continuous rotation on a sin wave and it comes out looking reeally choppy as each integer of rotation leaps forward from the last.

Rocco

Theres a module from Krish, dont know if this is exactly what you are looking for, but maybe you should look into it.
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41649.0

Calin Leafshade

To scale a bitmap in C++ you'll have to make a new bitmap of the correct size and blit the old sprite to the new sprite at the new size.

violgamba

#4
Hi Rocco.  Thanks for the link.  I'm trying to do this as a plugin (in C++, rather than an AGS module) for maximum speedage, though it might not prove to be the best route to follow.  I don't know that I could easily use the module you've sent me with this method.

"To scale a bitmap in C++ you'll have to make a new bitmap of the correct size and blit the old sprite to the new sprite at the new size."

Hmm.  Yeah, that's pretty much what I thought.  I guess I'm looking for is a way to accomplish "blit the old sprite to the new sprite at the new size" part.  It doesn't seem as though I can scale with the 3 blit functions that I've found:

 // draw a bitmap to the active screen
 AGSIFUNC(void) BlitBitmap (int32 x, int32 y, BITMAP *, int32 masked);
 // draw a translucent bitmap to the active screen
 AGSIFUNC(void)   BlitSpriteTranslucent(int32 x, int32 y, BITMAP *, int32 trans);
 // draw a sprite to the screen, but rotated around its centre
 AGSIFUNC(void)   BlitSpriteRotated(int32 x, int32 y, BITMAP *, int32 angle);

The only extra info is a "masked" flag, a transparancy value and an angle value, respectively.

I'm wondering if the plugin info that I'm using is out of date, and there are more functions than what I'm seeing in agsplugin.h.
Alternately, perhaps I should be directly referencing the DirectDraw surfaces via GetBitmapSurface?  That would certainly give me enough power to do whatever I want, though it'd mean needing to download the dx5sdk, I think.

Calin Leafshade

well you can get the bitmap surface directly which is just a 2d array. So then you can scale the array with whatever algorithm you like. But there is no built in ags function  to do it as far as i know.

violgamba

Ah, ok.  I guess that's what I needed to know. :-\
Probably the same story to get finer grained control of the rotational blitting too, huh?
Thanks for letting me know.  It's time to roll up my programmer sleeves and write me some algorithm. :)
Shader support'd be perfect for this sort of thing.

SMF spam blocked by CleanTalk