I thought I remembered at one time having come across some kind of scaling function for Bitmap Objects, but I can't seem to find it now... Is there a scaling function (either up or down) that can be used when displaying a Bitmap, or a portion of the Bitmap(ie sprite)?
What I want to do is to take a sprite from my spritesheet and make it smaller at various points.
Scaling Sprites
-
- Posts: 28
- Joined: Mon Jan 18, 2010 11:56 pm
Scaling Sprites
--==[[ Mothdragon ]]==--
- - - - - - - - - - - - - - - - -
Everything New is Old, Everything Old is New. Nothing exists, and it's all here.
- - - - - - - - - - - - - - - - -
Everything New is Old, Everything Old is New. Nothing exists, and it's all here.
-
- Posts: 28
- Joined: Mon Jan 18, 2010 11:56 pm
Re: Scaling Sprites
Oh I found it. Its the Stretch() method in the Surface Object. Guess I was looking in the wrong spot, I had been looking at the Bitmap Object...
--==[[ Mothdragon ]]==--
- - - - - - - - - - - - - - - - -
Everything New is Old, Everything Old is New. Nothing exists, and it's all here.
- - - - - - - - - - - - - - - - -
Everything New is Old, Everything Old is New. Nothing exists, and it's all here.
Re: Scaling Sprites
Good morning Charlie
Yes, there is Surface::Stretch. It works just like Surface::Blit, except it takes 2 sets of coordinates.
Destination x, y
Source x, y
Destination w, h
Source w, h
So you tell the function which portion (a rectangle) of your source bitmap should be used to stretch over a rectangular area of your destination surface.
There is also Filter() which takes the exact same parameters as Stretch, but will do bilinear filtering so the result will generally look nicer (at a performance cost in a non-accelerated driver). Stretch() will pixelize.
Regards,
Jerome
Yes, there is Surface::Stretch. It works just like Surface::Blit, except it takes 2 sets of coordinates.
Code: Select all
void Stretch(Bitmap src, int dx, int dy, int sx, int sy, int w, int h, int sw, int sh)
Source x, y
Destination w, h
Source w, h
So you tell the function which portion (a rectangle) of your source bitmap should be used to stretch over a rectangular area of your destination surface.
There is also Filter() which takes the exact same parameters as Stretch, but will do bilinear filtering so the result will generally look nicer (at a performance cost in a non-accelerated driver). Stretch() will pixelize.
Regards,
Jerome