# Zooming In SDL 2.0

I'm currently working on a project in which I render pictures raw. That is I use simple IMG_LoadTexture(), SDL_RenderCopy(). I want the program to be able to zoom in/out and textures to be scaled to screenwidth/height. I googled it but most of the answers for this question was outdated. Can I achieve this in SDL2. If not what's the way of doing this.

By using SDL_RenderCopy you can do all the zoom in/out or scaling stuff, by using non null values for the srcrect and dstrect parameters.

Here is the prototype of the function :

int SDL_RenderCopy(SDL_Renderer*   renderer,
SDL_Texture*    texture,
const SDL_Rect* srcrect,
const SDL_Rect* dstrect)


So you just need to create two SDL_Rect and setup them accordingly.

• Src rectangle represents the area in your image that you want to show on screen. Dst rectangle is the screen area where you want to show it. Whenever src rect is smaller than your image size you are zooming in. Just test it / read the doc... – VB_overflow Aug 29 '15 at 10:42