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