void Cmd_TextureMix() { miptex32_t *qtex32; char filename[1024]; int size; InitVars(); GetScriptToken (false); strcpy(root, token); RemoveExt(root); RemoveLeading(root); strcpy(filename, ExpandPathAndArchive(token)); if (SetVars(filename)) { // Create combined texture percent = ((TotalArea() * 100) / (out.w * out.h)); printf("Total area consumed : %d%%\n", percent); printf("Texture resolution : %dx%d pixels.\n", xcharsize, ycharsize); CreateMain(); // Save image as m32 sprintf (filename, "%spics/misc/%s.m32", gamedir, out.name); qtex32 = CreateMip32((unsigned *)outpixels, out.w, out.h, &size, false); qtex32->contents = 0; qtex32->value = 0; qtex32->scale_x = 1.0; qtex32->scale_y = 1.0; sprintf (qtex32->name, "misc/%s", out.name); printf ("\n\nwriting %s\n", filename); SaveFile (filename, (byte *)qtex32, size); free (qtex32); // Save out script file sprintf (filename, "%spics/misc/%s.fnt", gamedir, outscript); printf("Writing %s as script file\n", filename); if (!SaveScript(filename)) { printf("Unable to save output script.\n"); } } printf("Everythings groovy.\n"); Cleanup(); }
void Cmd_Pic( void ){ int xl,yl,xh,yh,w,h; byte *dest, *source; int flags, value, contents; char lumpname[128]; char animname[128]; byte buffer[256 * 256]; unsigned bufferl[256 * 256]; char filename[1024]; unsigned *destl, *sourcel; int linedelta, x, y; int size; miptex_t *qtex; miptex32_t *qtex32; float scale_x, scale_y; GetScriptToken( false ); strcpy( lumpname, token ); GetScriptToken( false ); xl = atoi( token ); GetScriptToken( false ); yl = atoi( token ); GetScriptToken( false ); w = atoi( token ); GetScriptToken( false ); h = atoi( token ); total_x += w; total_y += h; total_textures++; if ( ( w & 7 ) || ( h & 7 ) ) { Error( "line %i: miptex sizes must be multiples of 8", scriptline ); } flags = 0; contents = 0; value = 0; animname[0] = 0; scale_x = scale_y = 0.5; if ( TrueColorImage ) { sprintf( filename, "%spics/%s/%s.m32", g_outputDir, pic_prefix, lumpname ); if ( g_release ) { return; // textures are only released by $maps } xh = xl + w; yh = yl + h; if ( xl >= longimagewidth || xh > longimagewidth || yl >= longimageheight || yh > longimageheight ) { Error( "line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,longimagewidth,longimageheight ); } sourcel = longimage + ( yl * longimagewidth ) + xl; destl = bufferl; linedelta = ( longimagewidth - w ); for ( y = yl ; y < yh ; y++ ) { for ( x = xl ; x < xh ; x++ ) { *destl++ = *sourcel++; // RGBA } sourcel += linedelta; } qtex32 = CreateMip32( bufferl, w, h, &size, false ); qtex32->flags |= LittleLong( flags ); qtex32->contents = contents; qtex32->value = value; qtex32->scale_x = scale_x; qtex32->scale_y = scale_y; sprintf( qtex32->name, "%s/%s", pic_prefix, lumpname ); if ( animname[0] ) { sprintf( qtex32->animname, "%s/%s", pic_prefix, animname ); } // // write it out // printf( "writing %s\n", filename ); SaveFile( filename, (byte *)qtex32, size ); free( qtex32 ); } else { sprintf( filename, "%spics/%s/%s.m8", g_outputDir, pic_prefix, lumpname ); if ( g_release ) { return; // textures are only released by $maps } xh = xl + w; yh = yl + h; if ( xl >= byteimagewidth || xh > byteimagewidth || yl >= byteimageheight || yh > byteimageheight ) { Error( "line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,byteimagewidth,byteimageheight ); } source = byteimage + yl * byteimagewidth + xl; dest = buffer; linedelta = byteimagewidth - w; for ( y = yl ; y < yh ; y++ ) { for ( x = xl ; x < xh ; x++ ) { *dest++ = *source++; } source += linedelta; } qtex = CreateMip( buffer, w, h, lbmpalette, &size, false ); qtex->flags = flags; qtex->contents = contents; qtex->value = value; sprintf( qtex->name, "%s/%s", pic_prefix, lumpname ); if ( animname[0] ) { sprintf( qtex->animname, "%s/%s", pic_prefix, animname ); } // // write it out // printf( "writing %s\n", filename ); SaveFile( filename, (byte *)qtex, size ); free( qtex ); } }