====== Scripts > AM_ConvertToBYTE ====== ^ Description | Generates an 8-bit representation of the attributes map and saves it as a bitmap or RAW file. | ^ Author | Aaron. | ^ Created | 2012/09/12 07:28 | ^ Requires | L3DT v12.09 (specifically, ZeoWrap 12.09) | ^ Download | {{:scripts:AM_ConvertToByte.zs|AM_ConvertToByte.zs}} | ===== About ===== Please see [[http://www.bundysoft.com/phpBB2/viewtopic.php?f=4&t=2243|this forum thread]] for more information. This script is //really// slow. ===== Script contents ===== // Author: A. Torpy // Written: 13 Sept 2012 hvar hAM set hAM int nx ny set nx set ny assert > "Attributes map is not initialised!" // ask user for output filename filesel fs filesel.Init &fs false NULL "Bitmap image (*.bmp)|*.bmp|8-bit RAW file (*.raw)|*.raw|" "bmp" NULL if > return -1 endif string FileName set FileName // create an output map map TempMap assert "Cannot initialise temp map!" int i j set i 0 set j 0 buffer buf buffer.InitByType &buf 256 ushort ushort us byte b progbox pb progbox.SetTitle &pb "Converting attributes map to 8-bit" progbox.ShowWnd &pb int64 p pmax set p 0 set pmax ny> do set i 0 do progbox.SetProgress &pb pmax map.GetPixel hAM i j &us set b
map.SetPixel &TempMap i j &b buffer.SetValue &buf b us while nx> while ny> assert "Error saving file!" // now compile palette list voidptr fp set fp " palette.txt"> "w"> assert fp "Cannot create palette file!" int k string s do set us 0 buffer.GetValue &buf k us if set s "\n">>> fwrite fp s endif while 256> fclose fp MessageBox "File saved OK" 0x40 return 0