LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-26-2006, 06:12 PM   #1
andrewmatta
LQ Newbie
 
Registered: Sep 2005
Location: Westminster, CO
Distribution: Ubuntu 8.04 - KDE4
Posts: 7

Rep: Reputation: 0
Cross-platform C/C++ SVG render/convert


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?

Thanks!
 
Old 08-26-2006, 06:54 PM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
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.
 
Old 08-27-2006, 01:15 AM   #3
andrewmatta
LQ Newbie
 
Registered: Sep 2005
Location: Westminster, CO
Distribution: Ubuntu 8.04 - KDE4
Posts: 7

Original Poster
Rep: Reputation: 0
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.

Thanks
 
Old 08-27-2006, 06:02 AM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
I never knew there was a plugin for svg's, but a quick search of the SDL site gave this: http://www.linuxmotors.com/SDL_svg/ but it seems only available for linux.
SDL library link

Last edited by dmail; 08-27-2006 at 06:05 AM.
 
Old 08-27-2006, 01:56 PM   #5
andrewmatta
LQ Newbie
 
Registered: Sep 2005
Location: Westminster, CO
Distribution: Ubuntu 8.04 - KDE4
Posts: 7

Original Poster
Rep: Reputation: 0
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.

Thanks for your replies
 
Old 08-28-2006, 09:19 PM   #6
andrewmatta
LQ Newbie
 
Registered: Sep 2005
Location: Westminster, CO
Distribution: Ubuntu 8.04 - KDE4
Posts: 7

Original Poster
Rep: Reputation: 0
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.
 
  


Reply

Tags
c++, crossplatform, svg, vector


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cross platform c++ nyomon Programming 6 07-03-2005 03:24 PM
cross platform filesystem z9_87 Linux - Hardware 5 03-20-2005 06:49 PM
Cross-Platform LibAO Ross Clement Programming 0 03-05-2005 05:19 AM
Maya render on linux platform... lazlow69 Linux - Software 0 05-09-2004 03:36 PM
Cross Platform biggiefatts Linux - Software 4 06-04-2002 03:00 PM


All times are GMT -5. The time now is 09:30 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration