News
About
RSS
Export latest
Forums
Gallery
Project Alexandria
Subject:
SDL, images, and saving!
<p>Last night, after several days of steady hair loss, I finally managed to release the first version of my library that allows SDL_Surfaces to be saved, either to files or SDL_RWops, as jpeg or png data. This self-imposed torture<sup>1</sup> was needed because, while there are several ways to get images into SDL - SDL_image being the most commonly used and widely recognised library for doing this - support for actually saving from SDL surfaces to files is, at best, poor. SDL itself provides a function to save surfaces as BMP files, but if you want to save in any sane format, you're basically stuck with rolling your own.</p> <p>The save code I have written is in its early stages: as it stands, it supports writing as png and jpeg, as those are the formats I need <em>right now</em>. I have plans in the works to add TGA, TIFF, and possibly PCX (although the latter is a long, long way down the priorities), but supporting saving to other formats that SDL_image supports<sup>2</sup> is not really something I have any interest in as they are all of questionable utility in real situations.</p> <p>I have designed the library such that the code needed to save each format is nearly encapsulated in its own file, and with naming schemes that betray a deeper motive: once I have more formats (TGA and TIFF at least) added, and have tested the code more thoroughly, I will be looking into making a major patch against SDL_image, and contacting the maintainer of that library to try and get my code rolled into it. The lack of save facility has been a deficiency in the library for a long time, and hopefully I can start to address that properly. I can at least try, anyway!</p> <p>Anyway, the release message can be read <a href="http://forums.starforge.co.uk/viewtopic.php?p=296#p296">here</a>. There you will find links to downloads, git repository links, bug reporting facilities, and more. Now I go to start integrating this into a Real Program...</p> <p><span style="font-size: 85%; line-height: 116%"><sup>1</sup> Seriously, what is it with image library developers and documentation? They appear to be decent enough at writing conversational introductions to the use of the library, but if you want actual API docs, with full explanations of function purposes, arguments, and return values? Aahahah, no. <br /> <sup>2</sup>CUR, GIF, ICO, ILBM, PNM, XCF, XPM, XV</span></p> <div style="text-align: center; width: 100%"><div style="border: 1px solid black;">Originally posted at <a href="http://forums.starforge.co.uk/viewtopic.php?f=15&t=120">http://forums.starforge.co.uk/viewtopic.php?f=15&t=120</a><br/> Comment there or here...</div></div>