Jibble

Author Topic: Scaling in C++ plugins  (Read 867 times)

Scaling in C++ plugins
« on: 16 Apr 2011, 02:15 »
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


Re: Scaling in C++ plugins
« Reply #1 on: 16 Apr 2011, 16:03 »
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.

Re: Scaling in C++ plugins
« Reply #2 on: 16 Apr 2011, 19:54 »
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

  • Long live King Cat!
    • I can help with making music
    • I can help with voice acting
    • Calin Leafshade worked on a game that won an AGS Award!
    •  
    • Calin Leafshade worked on a game that was nominated for an AGS Award!
Re: Scaling in C++ plugins
« Reply #3 on: 16 Apr 2011, 20:06 »
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.

Re: Scaling in C++ plugins
« Reply #4 on: 16 Apr 2011, 23:06 »
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.
« Last Edit: 16 Apr 2011, 23:09 by guanohead »

Calin Leafshade

  • Long live King Cat!
    • I can help with making music
    • I can help with voice acting
    • Calin Leafshade worked on a game that won an AGS Award!
    •  
    • Calin Leafshade worked on a game that was nominated for an AGS Award!
Re: Scaling in C++ plugins
« Reply #5 on: 16 Apr 2011, 23:33 »
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.

Re: Scaling in C++ plugins
« Reply #6 on: 17 Apr 2011, 01:38 »
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.