2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 byte *byteimage, *lbmpalette;
26 int byteimagewidth, byteimageheight;
28 qboolean TrueColorImage;
30 int longimagewidth, longimageheight;
32 char pic_prefix[1024];
33 extern char *g_outputDir;
45 int flags, value, contents;
49 unsigned bufferl[256*256];
51 unsigned *destl, *sourcel;
56 float scale_x, scale_y;
58 GetScriptToken (false);
59 strcpy (lumpname, token);
61 GetScriptToken (false);
63 GetScriptToken (false);
65 GetScriptToken (false);
67 GetScriptToken (false);
74 if ( (w & 7) || (h & 7) )
75 Error ("line %i: miptex sizes must be multiples of 8", scriptline);
83 scale_x = scale_y = 0.5;
87 sprintf (filename, "%spics/%s/%s.m32", g_outputDir, pic_prefix, lumpname);
89 return; // textures are only released by $maps
94 if (xl >= longimagewidth || xh > longimagewidth ||
95 yl >= longimageheight || yh > longimageheight)
97 Error ("line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,longimagewidth,longimageheight);
100 sourcel = longimage + (yl*longimagewidth) + xl;
102 linedelta = (longimagewidth - w);
104 for (y=yl ; y<yh ; y++)
106 for (x=xl ; x<xh ; x++)
108 *destl++ = *sourcel++; // RGBA
110 sourcel += linedelta;
113 qtex32 = CreateMip32(bufferl, w, h, &size, false);
115 qtex32->flags |= LittleLong(flags);
116 qtex32->contents = contents;
117 qtex32->value = value;
118 qtex32->scale_x = scale_x;
119 qtex32->scale_y = scale_y;
120 sprintf (qtex32->name, "%s/%s", pic_prefix, lumpname);
122 sprintf (qtex32->animname, "%s/%s", pic_prefix, animname);
127 printf ("writing %s\n", filename);
128 SaveFile (filename, (byte *)qtex32, size);
134 sprintf (filename, "%spics/%s/%s.m8", g_outputDir, pic_prefix, lumpname);
136 return; // textures are only released by $maps
141 if (xl >= byteimagewidth || xh > byteimagewidth ||
142 yl >= byteimageheight || yh > byteimageheight)
144 Error ("line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,byteimagewidth,byteimageheight);
147 source = byteimage + yl*byteimagewidth + xl;
149 linedelta = byteimagewidth - w;
151 for (y=yl ; y<yh ; y++)
153 for (x=xl ; x<xh ; x++)
160 qtex = CreateMip(buffer, w, h, lbmpalette, &size, false);
163 qtex->contents = contents;
165 sprintf (qtex->name, "%s/%s", pic_prefix, lumpname);
167 sprintf (qtex->animname, "%s/%s", pic_prefix, animname);
172 printf ("writing %s\n", filename);
173 SaveFile (filename, (byte *)qtex, size);
185 void Cmd_Picdir (void)
189 GetScriptToken (false);
190 strcpy (pic_prefix, token);
191 // create the directory if needed
192 sprintf (filename, "%sPics", g_outputDir);
194 sprintf (filename, "%sPics/%s", g_outputDir, pic_prefix);