we don't really need simpledisplay's glfinish flag, as we do no rendering in window...
[dd2d.git] / vga2png.d
blob4af19bb2a36e55b34054518f1b9c847397eca0fd
1 /* DooM2D: Midnight on the Firing Line
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 module vga2png is aliced;
20 private:
21 import iv.glbinds;
22 import glutils;
23 import console;
24 import wadarc;
26 import iv.vfs;
28 import d2dimage;
31 // ////////////////////////////////////////////////////////////////////////// //
32 import arsd.color;
33 import arsd.png;
36 // ////////////////////////////////////////////////////////////////////////// //
37 int main (string[] args) {
38 if (args.length < 2 || args.length > 3) {
39 conwriteln("usage: vga2png infile.vga [outfile.png]");
40 return -1;
43 string ifname = args[1];
44 string ofname;
45 if (args.length == 3) {
46 ofname = args[2];
47 } else {
48 import std.algorithm : endsWith;
49 if (ifname.endsWith(".vga")) {
50 ofname = ifname[0..$-4]~".png";
51 } else {
52 ofname = ifname~".png";
56 if (ifname.length == 0) {
57 conwriteln("image name?");
58 return -1;
60 if (ifname[0] != '/') ifname = "./"~ifname;
62 static void setDP () {
63 /*version(rdmd) {
64 setDataPath("data");
65 } else*/ {
66 import std.file : thisExePath;
67 import std.path : dirName;
68 setDataPath(thisExePath.dirName~"/data");
70 addPak(getDataPath~"base.pk3");
73 setDP();
75 try {
76 loadD2DPalette();
77 auto img = new D2DImage(ifname);
78 conwriteln("writing image '", ofname, "'");
79 img.savePng(ofname);
80 } catch (Exception e) {
81 import std.stdio : stderr;
82 stderr.writeln("FUUUUUUUUUUUU\n", e.toString);
83 return -1;
85 return 0;