// Write single color 16x16 Targa file to disk // // Used to create preview swatches for my color search engine. // Largely replaced by draw commands, but useful for folks // who are interested in writing out Targas // // Written By Sean Hyde-Moyer (Copywrite 1995-2003) // This program is released to the public under the terms of the // GNU GENERAL PUBLIC LICENSE // See http://www.gnu.org/copyleft/gpl.txt // For the full text of the license agreement //__________________________________________________WriteOut TGA Color Previews_______________________ tgaSwatch: Rdec,Gdec,Bdec,prenum,direc //___Send it a decimal RGB value, an image number, and a directory to write the image { filename = string(direc,"temp-",prenum,".tga"); //_____Writes out filename in format "temp-##.tga" if(fileexists(filename)) filedelete(filename); temptga = File(filename,"wb"); //________________________________________________________Write TGA header temptga.writeByte(0); //____ID Length (Ignored) temptga.writeByte(0); //____ColorMapType (Ignored) temptga.writeByte(2); //____Image Type 2: Truecolor Image for(i = 1; i <= 9; ++i) { temptga.writeByte(0); } temptga.writeByte(16); //____x width 16 pixels temptga.writeByte(0); temptga.writeByte(16); //____y height 16 pixels temptga.writeByte(0); temptga.writeByte(24); //____bit-depth 24 temptga.writeByte(0); //_______________________________________________Write RGB data___________________ for(j = 1; j <= 256; ++j) { temptga.writeByte(Bdec); temptga.writeByte(Gdec); temptga.writeByte(Rdec); } flag = 1; return(flag); }