2 Copyright (C) 1999-2007 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 char pic_prefix[1024];
26 extern char *g_outputDir;
37 int flags, value, contents;
40 byte buffer[256 * 256];
41 unsigned bufferl[256 * 256];
43 unsigned *destl, *sourcel;
48 float scale_x, scale_y;
50 GetScriptToken( false );
51 strcpy( lumpname, token );
53 GetScriptToken( false );
55 GetScriptToken( false );
57 GetScriptToken( false );
59 GetScriptToken( false );
66 if ( ( w & 7 ) || ( h & 7 ) ) {
67 Error( "line %i: miptex sizes must be multiples of 8", scriptline );
76 scale_x = scale_y = 0.5;
78 if ( TrueColorImage ) {
79 sprintf( filename, "%spics/%s/%s.m32", g_outputDir, pic_prefix, lumpname );
81 return; // textures are only released by $maps
87 if ( xl >= longimagewidth || xh > longimagewidth ||
88 yl >= longimageheight || yh > longimageheight ) {
89 Error( "line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,longimagewidth,longimageheight );
92 sourcel = longimage + ( yl * longimagewidth ) + xl;
94 linedelta = ( longimagewidth - w );
96 for ( y = yl ; y < yh ; y++ )
98 for ( x = xl ; x < xh ; x++ )
100 *destl++ = *sourcel++; // RGBA
102 sourcel += linedelta;
105 qtex32 = CreateMip32( bufferl, w, h, &size, false );
107 qtex32->flags |= LittleLong( flags );
108 qtex32->contents = contents;
109 qtex32->value = value;
110 qtex32->scale_x = scale_x;
111 qtex32->scale_y = scale_y;
112 sprintf( qtex32->name, "%s/%s", pic_prefix, lumpname );
114 sprintf( qtex32->animname, "%s/%s", pic_prefix, animname );
120 printf( "writing %s\n", filename );
121 SaveFile( filename, (byte *)qtex32, size );
127 sprintf( filename, "%spics/%s/%s.m8", g_outputDir, pic_prefix, lumpname );
129 return; // textures are only released by $maps
135 if ( xl >= byteimagewidth || xh > byteimagewidth ||
136 yl >= byteimageheight || yh > byteimageheight ) {
137 Error( "line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,byteimagewidth,byteimageheight );
140 source = byteimage + yl * byteimagewidth + xl;
142 linedelta = byteimagewidth - w;
144 for ( y = yl ; y < yh ; y++ )
146 for ( x = xl ; x < xh ; x++ )
153 qtex = CreateMip( buffer, w, h, lbmpalette, &size, false );
156 qtex->contents = contents;
158 sprintf( qtex->name, "%s/%s", pic_prefix, lumpname );
160 sprintf( qtex->animname, "%s/%s", pic_prefix, animname );
166 printf( "writing %s\n", filename );
167 SaveFile( filename, (byte *)qtex, size );
179 void Cmd_Picdir( void ){
182 GetScriptToken( false );
183 strcpy( pic_prefix, token );
184 // create the directory if needed
185 sprintf( filename, "%sPics", g_outputDir );
187 sprintf( filename, "%sPics/%s", g_outputDir, pic_prefix );