Smoothly zoom a big Image with SDL - c++

I need to smoothly zoom in/out and pan an image (for a slideshow) with the sdl library.
I've tried rotozoom from the SDL GFX library but it's far away from smooth.
What would be the best approach here?

If "vanilla" SDL seems too slow for you I'd suggest switching your drawing code to OpenGL. That way you'll get hardwareaccelleration and your issues should go away:)
Using OpenGL coupled with SDL is very easy and there are lots of tutorials on how to do it.

Related

Drawing a videostream using wxWidgets

I have a relatively simple application which currently utilizes OpenCV to grab an image from a camera using cv::VideoCapture and view the resulting image in a window using imshow() running on OS X El Capitan.
In between I'm doing some basic image modification but this is not crucial to my problem.
Since the GUI implemented by OpenCV is pretty basic I decided to redo it using wxWidgets. I got it basically running similarly to the implementation linked in the tutorial section of wxWidgets. (Updated it to C++11 etc. but the idea is pretty much identical. Code is located on github.)
Now heres my problem: In best cases I get half the framerate as I get with the OpenCV only solution. OpenCV uses qt underneath. But when I look into the stack trace it comes down to similar function calls using CoreGraphics.
So my question boils down to: What is the best way do draw an image to a window with a framerate > 20fps using wxWidgets on OS X? Currently I use the DrawBitmap() function.
Bonus question: when I have the window on my Macbooks internal Retina screen the framerate gets even worse. Is there maybe any preprocessing/scaling on the picture I should do to take off load from the GUI-process?
The fastest is probably to use OpenGL (although I'm less sure about this under OS X which is not very OpenGL-friendly AFAIK), but I'm not really sure if the bottleneck is really DrawBitmap(), it could be the code doing the conversion to wxBitmap in the first place: if you don't use raw bitmap access, it could be quite slow.

What is Renderer and Texture in SDL2, conceptually?

I was moving from SDL to SDL2, and was confused of the 'render & texture' system introduced.
Back in SDL, the most frequent operation was creating Surface's and BlitSurface them onto screen. Now there seems a trend of using renderers and textures. However, this is extremely slow (in terms of coding overhead) from my point. Why can't I just load_BMP and BlitSurface as before? What good can be introduced from this whole window-renderer-texture thing?
I have read a couple threads What is a SDL renderer? but still a little confusing.
So..
Will the old Surface way work in SDL2?
What is the point in Renderer & Texture? (could be about hardware-accelaration according to a little googling, but not sure what that means)
You might want to take a look at the migration guide for SDL2, it provides information on the new way of dealing with 2D graphics.
The point of using textures instead of surfaces is that textures works on the GPU and get loaded into video memory and surfaces works in system memory with the CPU and since GPUs are much better suited than CPU for handling graphics it will be faster. Also, the renderer hides the underlying system used (it could be D3D, OpenGL, or something else).
You can still load surfaces, but you'll have to convert them to textures before rendering them or use the SDL_UpdateWindowSurface and SDL_GetWindowSurface functions; the latter link includes an example on how to use them.
As for the SDL2 approach being slow, as you assert, I don't agree with you, you set up the window and renderer once, load your textures much like you loaded surfaces, copy them to the renderer instead of blitting and finally use SDL_RenderPresent instead of SDL_Flip. Not that different really :)
But, take a look at the migration guide, it has the information you're looking for.

Regulating SDL Sprite Speed C++

How do I regulate the SDL sprite speed in C++, I know it's something to do with the framerate, but I'm not 100% sure. I know how to do it in PyGame, but SDL & C++ are slightly different.
Recommend following the lazyfoo tutorial on this.

Fast C++ Graphics (as in programming time)

I've played around with GLUT, but I've also read about SDL and one or two other graphics libraries. All I want to do at this point is 2D work. For what I'm doing right now, pixel by pixel plotting is all I need (say, plot(x,y,color) or something of the sort), but in the future I would appreciate the use of sprites. I've given point plotting a go with GLUT but it's rather non-intuitive coming from a B.A.S.I.C. background.
I work on both Ubuntu and Windows, so solutions for both systems are welcome.
SDL is probably a good choice; another option to look at would be Qt (just subclass a QWidget and override its paintEvent() method and do your pixel plotting inside that). Qt can also provide windowing/infrastructure support for OpenGL graphics if that's your preference.

Blitting zoomed images using SDL

Is there any way to Blit a zoomed (in) version of a certain image/sprite using SDL? (Besides manually saving a zoomed version of the image..)
Thanks :-)
Not with the SDL API itself.
I think there exist libraries (for SDL) who support zooming (so called resizing).
EDIT: http://www.ferzkopp.net/joomla/content/view/19/14/
Generally speaking, SDL isn't suitable for graphics that require real-time rotations and zooming. For that, you'd need an library based around an accelerated API such as DirectX or OpenGL. I understand that SFML meets this requirement.