PDA

View Full Version : Scale Images



JoseMan
04-25-2010, 10:46 AM
Hi and Hello,

1st: ClanLib is pretty cool.
2nd: Sorry, if I post in the wrong Forum.
May question.

I try to load an image, it works fine.
Now, I whant to scale it (resize)!

How I realize this.

I'm using ClanLib 2.1, WindowsXP.

Greez...

Ps.: sorry for my english!

rombust
04-25-2010, 03:51 PM
If you use CL_Image or CL_Sprite use you use both of following options:


image.set_scale(float x, float y);
Example: image.set_scale(2.0f, 2.0f); --> Scale * 2
Then image.draw(gc, xpos, ypos);
or

image.draw(CL_GraphicContext &gc, const CL_Rectf &dest)
Example: image.draw(gc, CL_Rectf(xpos, ypos, CL_Sizef(image.get_width() * 2.0f, image.get_height() * 2.0f))); --> Scale * 2

Aintaer
05-19-2010, 08:22 PM
Can you specify which scaling algorithm to use? Which algorithm is used by default?

rombust
05-19-2010, 09:10 PM
CL_Image or CL_Sprite both default to the "linear" method (smooth scaling).

With CL_Sprite, you can use set_linear_filter(false), to switch to the "nearest" method (closest pixel)

Advanced users can use CL_Texture instead, where you have: set_min_filter() and set_max_filter() for

cl_filter_nearest
cl_filter_linear
cl_filter_nearest_mipmap_nearest
cl_filter_nearest_mipmap_linear
cl_filter_linear_mipmap_nearest
cl_filter_linear_mipmap_linear