Ecere SDK/eC Forums • View topic - Scaling Sprites




Ecere SDK/eC Forums

Ecere Developers Community

Scaling Sprites

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.

Scaling Sprites

Postby mothdragon » Fri Jul 27, 2012 9:42 am

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.
--==[[ Mothdragon ]]==--
- - - - - - - - - - - - - - - - -
Everything New is Old, Everything Old is New. Nothing exists, and it's all here.
mothdragon
 
Posts: 28
Joined: Mon Jan 18, 2010 11:56 pm

Re: Scaling Sprites

Postby mothdragon » Fri Jul 27, 2012 10:17 am

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... :oops:
--==[[ Mothdragon ]]==--
- - - - - - - - - - - - - - - - -
Everything New is Old, Everything Old is New. Nothing exists, and it's all here.
mothdragon
 
Posts: 28
Joined: Mon Jan 18, 2010 11:56 pm

Re: Scaling Sprites

Postby jerome » Fri Jul 27, 2012 10:20 am

Good morning Charlie :)

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)


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
jerome
Site Admin
 
Posts: 621
Joined: Sat Jan 16, 2010 11:16 pm


Return to GUI Toolkit & 2D Graphics

Who is online

Users browsing this forum: No registered users and 1 guest

cron