| 27 | 
   | 
     procedure btn_saveClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 28 | 
   | 
     procedure btn_loadClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 29 | 
   | 
     procedure btn_replaceClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 | 30 | 
 + | 
     procedure Splitter1Moved(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
   | 
   private | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 | 
   | 
     OniImage_Old: TOniImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 33 | 
   | 
     OniImage_New: TOniImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 | 
   | 
 procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 | 
   | 
 var | 
 
 
 
 
 
 
 
 
 
 | 49 | 
 – | 
   mem:  TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 | 
   | 
   fadingbyte, depthbyte, storebyte: Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | 
   | 
   fileid := fileinfo.ID; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 57 | 
   | 
   OniImage_Old.LoadFromTXMP(ConnectionID, fileid); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 | 
   | 
   old_size := OniImage_Old.GetImageSize(True); | 
 
 
 
 
 
 
 
 
 
 
 
 | 59 | 
 < | 
   OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 2); | 
 
 
 
 
 
 
 
 
 
 | 59 | 
 > | 
   OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 1); | 
 
 
 
 
 
 
 
 
 
 
 
 | 60 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 61 | 
   | 
   check_fading.Checked := OniImage_Old.HasMipMaps; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 62 | 
   | 
 //  check_transparency.Checked := (depthbyte and $04) > 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 66 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 67 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 68 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 69 | 
 + | 
 procedure TForm_TxmpReplace.Splitter1Moved(Sender: TObject); | 
 
 
 
 
 
 
 
 
 | 70 | 
 + | 
 begin | 
 
 
 
 
 
 
 
 
 | 71 | 
 + | 
   inherited; | 
 
 
 
 
 
 
 
 
 | 72 | 
 + | 
   image_txmppreview.Picture.Assign(nil); | 
 
 
 
 
 
 
 
 
 | 73 | 
 + | 
   image_bmppreview.Picture.Assign(nil); | 
 
 
 
 
 
 
 
 
 | 74 | 
 + | 
   if Length(OniImage_Old.Images) > 0 then | 
 
 
 
 
 
 
 
 
 | 75 | 
 + | 
     OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 1); | 
 
 
 
 
 
 
 
 
 | 76 | 
 + | 
   if Length(OniImage_New.Images) > 0 then | 
 
 
 
 
 
 
 
 
 | 77 | 
 + | 
     OniImage_New.DrawOnCanvas(image_bmppreview.Canvas, 1); | 
 
 
 
 
 
 
 
 
 | 78 | 
 + | 
 end; | 
 
 
 
 
 
 
 
 
 | 79 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | 
   | 
 procedure TForm_TxmpReplace.btn_loadClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 | 70 | 
 – | 
 var | 
 
 
 
 
 
 
 
 
 
 | 71 | 
 – | 
   mem:   TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
   | 
   if opend.Execute then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 83 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 | 
   | 
   datbyte: Word; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 | 
   | 
   mem: TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 100 | 
   | 
   new_storetype: Byte; | 
 
 
 
 
 
 
 
 
 | 101 | 
 + | 
   i: Integer; | 
 
 
 
 
 
 
 
 
 | 102 | 
 + | 
 const | 
 
 
 
 
 
 
 
 
 | 103 | 
 + | 
   powers: array[0..8] of Integer = (1, 2, 4, 8, 16, 32, 64, 128, 256); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 104 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 105 | 
   | 
   if filelist.ItemIndex >= 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 106 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 | 
   | 
     else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 111 | 
   | 
       ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 112 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 113 | 
 + | 
     if (OniImage_New.Width[1] > 256) or (OniImage_New.Height[1] > 256) then | 
 
 
 
 
 
 
 
 
 | 114 | 
 + | 
     begin | 
 
 
 
 
 
 
 
 
 | 115 | 
 + | 
       ShowMessage('Widht and height have to be smaller than or equal to 256.'); | 
 
 
 
 
 
 
 
 
 | 116 | 
 + | 
       Exit; | 
 
 
 
 
 
 
 
 
 | 117 | 
 + | 
     end; | 
 
 
 
 
 
 
 
 
 | 118 | 
 + | 
     for i := 0 to High(powers) do | 
 
 
 
 
 
 
 
 
 | 119 | 
 + | 
       if OniImage_New.Width[1] = powers[i] then | 
 
 
 
 
 
 
 
 
 | 120 | 
 + | 
         Break; | 
 
 
 
 
 
 
 
 
 | 121 | 
 + | 
     if i = Length(powers) then | 
 
 
 
 
 
 
 
 
 | 122 | 
 + | 
     begin | 
 
 
 
 
 
 
 
 
 | 123 | 
 + | 
       ShowMessage('Width has to be a power of 2 (1, 2, 4, 8, 16 ...)'); | 
 
 
 
 
 
 
 
 
 | 124 | 
 + | 
       Exit; | 
 
 
 
 
 
 
 
 
 | 125 | 
 + | 
     end; | 
 
 
 
 
 
 
 
 
 | 126 | 
 + | 
     for i := 0 to High(powers) do | 
 
 
 
 
 
 
 
 
 | 127 | 
 + | 
       if OniImage_New.Height[1] = powers[i] then | 
 
 
 
 
 
 
 
 
 | 128 | 
 + | 
         Break; | 
 
 
 
 
 
 
 
 
 | 129 | 
 + | 
     if i = Length(powers) then | 
 
 
 
 
 
 
 
 
 | 130 | 
 + | 
     begin | 
 
 
 
 
 
 
 
 
 | 131 | 
 + | 
       ShowMessage('Height has to be a power of 2 (1, 2, 4, 8, 16 ...)'); | 
 
 
 
 
 
 
 
 
 | 132 | 
 + | 
       Exit; | 
 
 
 
 
 
 
 
 
 | 133 | 
 + | 
     end; | 
 
 
 
 
 
 
 
 
 | 134 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 135 | 
   | 
     if (OniImage_Old.Width[1] <> OniImage_New.Width[1]) or | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 136 | 
   | 
       (OniImage_Old.Height[1] <> OniImage_New.Height[1]) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 137 | 
   | 
     begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 | 
   | 
     mem := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 151 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 152 | 
   | 
     case OniImage_New.Format of | 
 
 
 
 
 
 
 
 
 | 153 | 
 + | 
       ifX1R5G5B5: new_storetype := 1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 154 | 
   | 
       ifA1R5G5B5: new_storetype := 2; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 155 | 
   | 
       ifA4R4G4B4: new_storetype := 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 156 | 
   | 
       ifA8R8G8B8: | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 161 | 
   | 
       ifX8R8G8B8: new_storetype := 8; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 162 | 
   | 
       ifDXT1: new_storetype := 9; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 163 | 
   | 
     else | 
 
 
 
 
 
 
 
 
 | 164 | 
 + | 
       if OniImage_New.FormatInfo.HasAlphaChannel then | 
 
 
 
 
 
 
 
 
 | 165 | 
 + | 
         ShowMessage('Loaded image has an alpha-channel.' + #13#10 + | 
 
 
 
 
 
 
 
 
 | 166 | 
 + | 
                     'Because the format is neither ARGB1555' +#13#10 + | 
 
 
 
 
 
 
 
 
 | 167 | 
 + | 
                     'nor ARGB4444 it can not be imported without conversion.' + #13#10 + | 
 
 
 
 
 
 
 
 
 | 168 | 
 + | 
                     'It is converted to RGB888, so alpha gets dropped.' + #13#10 + | 
 
 
 
 
 
 
 
 
 | 169 | 
 + | 
                     'If you need alpha you have to save your image in' + #13#10 + | 
 
 
 
 
 
 
 
 
 | 170 | 
 + | 
                     'one of the previously named formats.');   | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 | 
   | 
       OniImage_New.Format := ifX8R8G8B8; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 | 
   | 
       new_storetype := 8; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 | 
   | 
     end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 186 | 
   | 
       ConManager.Connection[ConnectionID].UpdateRawFile(fileid, $9C, mem); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 187 | 
   | 
     end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 188 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 147 | 
 – | 
     datbyte := $00; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 189 | 
   | 
     if check_fading.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 | 190 | 
 < | 
       datbyte := datbyte or $01; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 190 | 
 > | 
       oldfading := oldfading or $01 | 
 
 
 
 
 
 | 191 | 
 > | 
     else | 
 
 
 
 
 
 | 192 | 
 > | 
       oldfading := oldfading and (not Byte($01)); | 
 
 
 
 
 
 
 
 
 
 
 
 | 193 | 
   | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 194 | 
   | 
     datbyte := $10; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 195 | 
   | 
 //    if check_transparency.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 206 | 
   | 
       ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 207 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 208 | 
   | 
     ShowMessage('TXMP-image replaced'); | 
 
 
 
 
 
 
 
 
 | 209 | 
 + | 
     Self.listClick(Self); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 210 | 
   | 
   end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 211 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 212 | 
   | 
  |