ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to design a game which would use SVG images for sprites. I am using SDL (without openGL) for this in the hopes that I can get it running on Linux, FreeBSD, OS X, and Windows (at least). I want to use SVG so that depending on the resolution/window size that the user chooses, I can re-render all the sprites so that they stay crisp when enlarging them.
My problem is that I cannot find a way to convert an SVG graphic to a raster format while keeping the program cross-platform. I would ideally like to render the SVGs to PNGs (or other raster formats) whenever I need to resize all the images, although it would also work to load straight from SVG to an SDL surface.
I am trying to keep dependencies to a minimum. Does anyone know of a library (or command line program) which exists for all of these platforms that I could use to perform this task?
I don't know of a lib that will help with this and even if there was would it have any benifits? Would the sprites not be the same size no matter what the resolution? ie 32*32 64*64 etc. When you saying you are scaling them could you explain what you mean, when loading to a surface?
SDL_image supports a number of image types:
BMP,PNM,XPM,XCF,PCX,GIF,JPG,TIF,PNG,LBM.
Personally I mainly use bitmaps and load with my own loader.
I forgot to mention before that I would want to be able to use full screen mode as well.
If I wanted, for instance, to have the option to use a resolution of 640x480 as well as 1024x768 (or any other resolution), but to keep the sprites looking about the same size regardless of the resolution chosen, I would have to use a larger sprite for the 1024x768 window (if I enabled full screen mode), correct? And if I were to just make all the sprites really large png's in the beginning and then shrink them to the appropriate sizes, wouldn't rendering a vector image straight to the target size would look better than the shrunken png?
What I want is to have an SVG sprite and be able to say, "draw the sprite as a 64x64 surface" or "draw it as a 128x128 surface", etc. When the user selects a resolution I wanted to be able to render all the SVGs to the size I wanted them to be, so that the could be used later on.
Yeah, that and librsvg (Also for Linux only as far as I know) were the only things I had found. I was just hoping that I was missing something simple, since it seems like an open format like SVG that has been around for five years would have wider support.
I found something on Google that, while not exactly what I was looking for, may be modified to suite my purposes. It's called AGG, for Anti-Grain Geometry - http://www.antigrain.com/. It seems to be a C++ library with no dependencies beyond the standard library (and thus is portable) whose purpose is to render graphics. It comes with a bunch of examples, one of which is an SVG viewer that produces really nice looking results. I haven't looked at it much yet, but my first impressions of it are good. It uses a modified BSD license which claims to be GPL compatible. I may be able to use it to work with my program.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.