| 1 | 
   | 
 unit TxmpReplace; | 
 
 
 
 
 
 
 
 
 | 2 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 3 | 
   | 
 interface | 
 
 
 
 
 
 
 
 
 | 4 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 5 | 
   | 
 uses | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 6 | 
   | 
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | 
 
 
 
 
 
 
 
 
 
 
 
 | 7 | 
 < | 
   Dialogs, Template, StdCtrls, ExtCtrls, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 8 | 
 < | 
   Functions, Data, OniImgClass, Menus, Buttons, TypeDefs; | 
 
 
 
 
 
 
 
 
 
 | 7 | 
 > | 
   Dialogs, _TemplateFileList, Menus, StdCtrls, Buttons, ComCtrls, ExtCtrls, | 
 
 
 
 
 
 | 8 | 
 > | 
   OniImgClass, TypeDefs; | 
 
 
 
 
 
 
 
 
 
 
 
 | 9 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 10 | 
   | 
 type | 
 
 
 
 
 
 
 
 
 
 
 
 | 11 | 
 < | 
   TForm_TxmpReplace = class(TForm_ToolTemplate) | 
 
 
 
 
 
 
 
 
 
 | 11 | 
 > | 
   TForm_TxmpReplace = class(TForm_TemplateFileList) | 
 
 
 
 
 
 
 
 
 
 
 
 | 12 | 
   | 
     group_options: TGroupBox; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 13 | 
   | 
     btn_replace: TButton; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 | 
   | 
     check_transparency: TCheckBox; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 15 | 
   | 
     check_fading: TCheckBox; | 
 
 
 
 
 
 
 
 
 
 
 
 | 16 | 
 < | 
     panel_txmppreview: TPanel; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 17 | 
 < | 
     btn_save: TButton; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 16 | 
 < | 
     image_txmppreview: TImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 17 | 
 < | 
     splitter_txmp: TSplitter; | 
 
 
 
 
 
 
 
 
 
 | 16 | 
 > | 
     GroupBox1: TGroupBox; | 
 
 
 
 
 
 | 17 | 
 > | 
     Splitter1: TSplitter; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 18 | 
   | 
     group_bmpselect: TGroupBox; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 19 | 
   | 
     image_bmppreview: TImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 | 
   | 
     panel_load: TPanel; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 | 
   | 
     btn_load: TButton; | 
 
 
 
 
 
 
 
 
 
 
 
 | 22 | 
 < | 
     opend: TOpenDialog; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 22 | 
 > | 
     image_txmppreview: TImage; | 
 
 
 
 
 
 | 23 | 
 > | 
     panel_txmppreview: TPanel; | 
 
 
 
 
 
 | 24 | 
 > | 
     btn_save: TButton; | 
 
 
 
 
 
 
 
 
 
 
 
 | 25 | 
   | 
     saved: TSaveDialog; | 
 
 
 
 
 
 
 
 
 | 26 | 
 + | 
     opend: TOpenDialog; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 27 | 
   | 
     procedure SelectFile(fileinfo: TFileInfo); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 28 | 
   | 
     procedure FormCreate(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 29 | 
   | 
     procedure FormClose(Sender: TObject; var Action: TCloseAction); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 30 | 
   | 
     procedure btn_saveClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
   | 
     procedure btn_loadClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 | 
   | 
     procedure btn_replaceClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 | 33 | 
 + | 
     procedure Splitter1Moved(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 34 | 
   | 
   private | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 35 | 
   | 
     OniImage_Old: TOniImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 36 | 
   | 
     OniImage_New: TOniImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 39 | 
   | 
   public | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 40 | 
   | 
   end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 41 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 38 | 
 – | 
 var | 
 
 
 
 
 
 
 
 
 
 | 39 | 
 – | 
   Form_TxmpReplace: TForm_TxmpReplace; | 
 
 
 
 
 
 
 
 
 
 | 40 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 | 
   | 
 implementation | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 | 
   | 
 {$R *.dfm} | 
 
 
 
 
 
 
 
 
 
 
 
 | 44 | 
 < | 
 uses Main, ConnectionManager; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 | 44 | 
 > | 
 uses | 
 
 
 
 
 
 | 45 | 
 > | 
   _TemplateFile, ConnectionManager, ImagingTypes; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 46 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 | 
   | 
 procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 | 
   | 
 var | 
 
 
 
 
 
 
 
 
 
 | 49 | 
 – | 
   mem:  TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 | 
   | 
   fadingbyte, depthbyte, storebyte: Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 | 
   | 
   fileid := fileinfo.ID; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | 
   | 
   ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 | 
   | 
   ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 54 | 
   | 
   ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte); | 
 
 
 
 
 
 
 
 
 
 | 56 | 
 – | 
   check_fading.Checked := (fadingbyte and $01) > 0; | 
 
 
 
 
 
 
 
 
 
 | 57 | 
 – | 
   check_transparency.Checked := (depthbyte and $04) > 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 55 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 | 
   | 
   OniImage_Old.LoadFromTXMP(ConnectionID, fileid); | 
 
 
 
 
 
 
 
 
 
 
 
 | 57 | 
 < | 
   old_size := OniImage_Old.GetImageDataSize((fadingbyte and $01) > 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 | 
 < | 
   mem  := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 59 | 
 < | 
   OniImage_Old.GetAsBMP(TStream(mem)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 60 | 
 < | 
   mem.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 61 | 
 < | 
   image_txmppreview.Picture.Bitmap.LoadFromStream(mem); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 62 | 
 < | 
   mem.Free; | 
 
 
 
 
 
 
 
 
 
 | 57 | 
 > | 
   old_size := OniImage_Old.GetImageSize(True); | 
 
 
 
 
 
 | 58 | 
 > | 
   OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 1); | 
 
 
 
 
 
 | 59 | 
 > | 
  | 
 
 
 
 
 
 | 60 | 
 > | 
   check_fading.Checked := OniImage_Old.HasMipMaps; | 
 
 
 
 
 
 | 61 | 
 > | 
 //  check_transparency.Checked := (depthbyte and $04) > 0; | 
 
 
 
 
 
 | 62 | 
 > | 
   check_transparency.Checked := storebyte in [0, 2, 7]; | 
 
 
 
 
 
 
 
 
 
 
 
 | 63 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 64 | 
   | 
   group_bmpselect.Enabled := True; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 65 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 66 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 67 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 68 | 
 + | 
 procedure TForm_TxmpReplace.Splitter1Moved(Sender: TObject); | 
 
 
 
 
 
 
 
 
 | 69 | 
 + | 
 begin | 
 
 
 
 
 
 
 
 
 | 70 | 
 + | 
   inherited; | 
 
 
 
 
 
 
 
 
 | 71 | 
 + | 
   image_txmppreview.Picture.Assign(nil); | 
 
 
 
 
 
 
 
 
 | 72 | 
 + | 
   image_bmppreview.Picture.Assign(nil); | 
 
 
 
 
 
 
 
 
 | 73 | 
 + | 
   if Length(OniImage_Old.Images) > 0 then | 
 
 
 
 
 
 
 
 
 | 74 | 
 + | 
     OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 1); | 
 
 
 
 
 
 
 
 
 | 75 | 
 + | 
   if Length(OniImage_New.Images) > 0 then | 
 
 
 
 
 
 
 
 
 | 76 | 
 + | 
     OniImage_New.DrawOnCanvas(image_bmppreview.Canvas, 1); | 
 
 
 
 
 
 
 
 
 | 77 | 
 + | 
 end; | 
 
 
 
 
 
 
 
 
 | 78 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | 
   | 
 procedure TForm_TxmpReplace.btn_loadClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 | 72 | 
 – | 
 var | 
 
 
 
 
 
 
 
 
 
 | 73 | 
 – | 
   mem:   TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
   | 
   if opend.Execute then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 | 83 | 
 < | 
     OniImage_New.LoadFromBMP(opend.FileName); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 84 | 
 < | 
     mem   := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | 
 < | 
     OniImage_New.GetAsBMP(TStream(mem)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | 
 < | 
     mem.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
 < | 
     image_bmppreview.Picture.Bitmap.LoadFromStream(mem); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
 < | 
     mem.Free; | 
 
 
 
 
 
 
 
 
 
 | 83 | 
 > | 
     OniImage_New.LoadFromFile(opend.FileName); | 
 
 
 
 
 
 | 84 | 
 > | 
     OniImage_New.DrawOnCanvas(image_bmppreview.Canvas, 1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 85 | 
   | 
     group_options.Enabled := True; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 86 | 
   | 
   end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 87 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 91 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 | 
   | 
 procedure TForm_TxmpReplace.btn_replaceClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 | 
   | 
 var | 
 
 
 
 
 
 
 
 
 
 
 
 | 94 | 
 < | 
   newsize: LongWord; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 | 
 < | 
   old_rawaddr, new_rawaddr: LongWord; | 
 
 
 
 
 
 
 
 
 
 | 94 | 
 > | 
   newsize: Integer; | 
 
 
 
 
 
 | 95 | 
 > | 
   old_rawaddr, new_rawaddr: Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 | 96 | 
   | 
   oldfading: Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 | 
   | 
   datbyte: Word; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 | 
   | 
   mem: TMemoryStream; | 
 
 
 
 
 
 
 
 
 | 99 | 
 + | 
   new_storetype: Byte; | 
 
 
 
 
 
 
 
 
 | 100 | 
 + | 
   i: Integer; | 
 
 
 
 
 
 
 
 
 | 101 | 
 + | 
 const | 
 
 
 
 
 
 
 
 
 | 102 | 
 + | 
   powers: array[0..8] of Integer = (1, 2, 4, 8, 16, 32, 64, 128, 256); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 103 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 104 | 
   | 
   if filelist.ItemIndex >= 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 105 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 109 | 
   | 
     else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 | 
   | 
       ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 111 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 112 | 
 < | 
     if (OniImage_Old.Width <> OniImage_New.Width) or | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 113 | 
 < | 
       (OniImage_Old.Height <> OniImage_New.Height) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 112 | 
 > | 
     if (OniImage_New.Width[1] > 256) or (OniImage_New.Height[1] > 256) then | 
 
 
 
 
 
 | 113 | 
 > | 
     begin | 
 
 
 
 
 
 | 114 | 
 > | 
       ShowMessage('Widht and height have to be smaller than or equal to 256.'); | 
 
 
 
 
 
 | 115 | 
 > | 
       Exit; | 
 
 
 
 
 
 | 116 | 
 > | 
     end; | 
 
 
 
 
 
 | 117 | 
 > | 
     for i := 0 to High(powers) do | 
 
 
 
 
 
 | 118 | 
 > | 
       if OniImage_New.Width[1] = powers[i] then | 
 
 
 
 
 
 | 119 | 
 > | 
         Break; | 
 
 
 
 
 
 | 120 | 
 > | 
     if i = Length(powers) then | 
 
 
 
 
 
 | 121 | 
 > | 
     begin | 
 
 
 
 
 
 | 122 | 
 > | 
       ShowMessage('Width has to be a power of 2 (1, 2, 4, 8, 16 ...)'); | 
 
 
 
 
 
 | 123 | 
 > | 
       Exit; | 
 
 
 
 
 
 | 124 | 
 > | 
     end; | 
 
 
 
 
 
 | 125 | 
 > | 
     for i := 0 to High(powers) do | 
 
 
 
 
 
 | 126 | 
 > | 
       if OniImage_New.Height[1] = powers[i] then | 
 
 
 
 
 
 | 127 | 
 > | 
         Break; | 
 
 
 
 
 
 | 128 | 
 > | 
     if i = Length(powers) then | 
 
 
 
 
 
 | 129 | 
 > | 
     begin | 
 
 
 
 
 
 | 130 | 
 > | 
       ShowMessage('Height has to be a power of 2 (1, 2, 4, 8, 16 ...)'); | 
 
 
 
 
 
 | 131 | 
 > | 
       Exit; | 
 
 
 
 
 
 | 132 | 
 > | 
     end; | 
 
 
 
 
 
 | 133 | 
 > | 
  | 
 
 
 
 
 
 | 134 | 
 > | 
     if (OniImage_Old.Width[1] <> OniImage_New.Width[1]) or | 
 
 
 
 
 
 | 135 | 
 > | 
       (OniImage_Old.Height[1] <> OniImage_New.Height[1]) then | 
 
 
 
 
 
 
 
 
 
 
 
 | 136 | 
   | 
     begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 137 | 
   | 
       if MessageBox(Self.Handle, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 138 | 
   | 
             PChar( | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 139 | 
   | 
               'Current image and new image have different size' + CrLf + | 
 
 
 
 
 
 
 
 
 
 
 
 | 140 | 
 < | 
               '(Current: ' + IntToStr(OniImage_Old.Width) + 'x' + | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 141 | 
 < | 
               IntToStr(OniImage_Old.Height) + ' - New: ' + | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 142 | 
 < | 
               IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) + | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 140 | 
 > | 
               '(Current: ' + IntToStr(OniImage_Old.Width[1]) + 'x' + | 
 
 
 
 
 
 | 141 | 
 > | 
               IntToStr(OniImage_Old.Height[1]) + ' - New: ' + | 
 
 
 
 
 
 | 142 | 
 > | 
               IntToStr(OniImage_New.Width[1]) + 'x' + | 
 
 
 
 
 
 | 143 | 
 > | 
               IntToStr(OniImage_New.Height[1]) + | 
 
 
 
 
 
 
 
 
 
 
 
 | 144 | 
   | 
               ')' + CrLf + 'Replace anyway?'), | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 145 | 
   | 
             PChar(filelist.Items.Strings[filelist.ItemIndex]), MB_YESNO) = idNo then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 146 | 
   | 
         Exit; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 148 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 149 | 
   | 
     mem := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 151 | 
 < | 
     if check_fading.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 152 | 
 < | 
       if not OniImage_New.GetMipMappedImage(TStream(mem)) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 153 | 
 < | 
         if MessageBox(Self.Handle, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 154 | 
 < | 
               PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' + | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 155 | 
 < | 
                 #13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'), | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 156 | 
 < | 
                 MB_YESNO) = ID_YES then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 157 | 
 < | 
           check_fading.Checked := False | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 158 | 
 < | 
         else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 159 | 
 < | 
           Exit; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 160 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 161 | 
 < | 
     if not check_fading.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 162 | 
 < | 
     begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 163 | 
 < | 
       mem.Clear; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 164 | 
 < | 
       OniImage_New.GetAsData(TStream(mem)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 151 | 
 > | 
     case OniImage_New.Format of | 
 
 
 
 
 
 | 152 | 
 > | 
       ifX1R5G5B5: new_storetype := 1; | 
 
 
 
 
 
 | 153 | 
 > | 
       ifA1R5G5B5: new_storetype := 2; | 
 
 
 
 
 
 | 154 | 
 > | 
       ifA4R4G4B4: new_storetype := 0; | 
 
 
 
 
 
 | 155 | 
 > | 
       ifA8R8G8B8: | 
 
 
 
 
 
 | 156 | 
 > | 
         begin | 
 
 
 
 
 
 | 157 | 
 > | 
           new_storetype := 8; | 
 
 
 
 
 
 | 158 | 
 > | 
           OniImage_New.Format := ifX8R8G8B8; | 
 
 
 
 
 
 | 159 | 
 > | 
         end; | 
 
 
 
 
 
 | 160 | 
 > | 
       ifX8R8G8B8: new_storetype := 8; | 
 
 
 
 
 
 | 161 | 
 > | 
       ifDXT1: new_storetype := 9; | 
 
 
 
 
 
 | 162 | 
 > | 
     else | 
 
 
 
 
 
 | 163 | 
 > | 
       if OniImage_New.FormatInfo.HasAlphaChannel then | 
 
 
 
 
 
 | 164 | 
 > | 
         ShowMessage('Loaded image has an alpha-channel.' + #13#10 + | 
 
 
 
 
 
 | 165 | 
 > | 
                     'Because the format is neither ARGB1555' +#13#10 + | 
 
 
 
 
 
 | 166 | 
 > | 
                     'nor ARGB4444 it can not be imported without conversion.' + #13#10 + | 
 
 
 
 
 
 | 167 | 
 > | 
                     'It is converted to RGB888, so alpha gets dropped.' + #13#10 + | 
 
 
 
 
 
 | 168 | 
 > | 
                     'If you need alpha you have to save your image in' + #13#10 + | 
 
 
 
 
 
 | 169 | 
 > | 
                     'one of the previously named formats.');   | 
 
 
 
 
 
 | 170 | 
 > | 
       OniImage_New.Format := ifX8R8G8B8; | 
 
 
 
 
 
 | 171 | 
 > | 
       new_storetype := 8; | 
 
 
 
 
 
 
 
 
 
 
 
 | 172 | 
   | 
     end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 174 | 
 < | 
     newsize := OniImage_New.GetImageDataSize(check_fading.Checked); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 174 | 
 > | 
     OniImage_New.SaveDataToStream(check_fading.Checked, TStream(mem)); | 
 
 
 
 
 
 | 175 | 
 > | 
  | 
 
 
 
 
 
 | 176 | 
 > | 
     newsize := mem.Size; | 
 
 
 
 
 
 | 177 | 
 > | 
     mem.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 | 178 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 179 | 
   | 
     if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 180 | 
   | 
       new_rawaddr := ConManager.Connection[ConnectionID].AppendRawFile( | 
 
 
 
 
 
 
 
 
 
 
 
 | 181 | 
 < | 
         not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem.Size, mem) | 
 
 
 
 
 
 
 
 
 
 | 181 | 
 > | 
         not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem) | 
 
 
 
 
 
 
 
 
 
 
 
 | 182 | 
   | 
     else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 183 | 
   | 
     begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 184 | 
   | 
       new_rawaddr := old_rawaddr; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 185 | 
   | 
       ConManager.Connection[ConnectionID].UpdateRawFile(fileid, $9C, mem); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 186 | 
   | 
     end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 187 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 149 | 
 – | 
     datbyte := $00; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 188 | 
   | 
     if check_fading.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 | 189 | 
 < | 
       datbyte := datbyte or $01; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 189 | 
 > | 
       oldfading := oldfading or $01 | 
 
 
 
 
 
 | 190 | 
 > | 
     else | 
 
 
 
 
 
 | 191 | 
 > | 
       oldfading := oldfading and (not Byte($01)); | 
 
 
 
 
 
 
 
 
 
 
 
 | 192 | 
   | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 193 | 
   | 
     datbyte := $10; | 
 
 
 
 
 
 
 
 
 
 
 
 | 194 | 
 < | 
     if check_transparency.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 195 | 
 < | 
       datbyte := datbyte or $04; | 
 
 
 
 
 
 
 
 
 
 | 194 | 
 > | 
 //    if check_transparency.Checked then | 
 
 
 
 
 
 | 195 | 
 > | 
 //      datbyte := datbyte or $04; | 
 
 
 
 
 
 
 
 
 
 
 
 | 196 | 
   | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $89, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 | 197 | 
 < | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 198 | 
 < | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 199 | 
 < | 
     datbyte := $08; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 200 | 
 < | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 197 | 
 > | 
     datbyte := OniImage_New.Width[1]; | 
 
 
 
 
 
 | 198 | 
 > | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @datbyte); | 
 
 
 
 
 
 | 199 | 
 > | 
     datbyte := OniImage_New.Height[1]; | 
 
 
 
 
 
 | 200 | 
 > | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @datbyte); | 
 
 
 
 
 
 | 201 | 
 > | 
     ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @new_storetype); | 
 
 
 
 
 
 
 
 
 
 
 
 | 202 | 
   | 
     if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 203 | 
   | 
       ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 204 | 
   | 
     else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 205 | 
   | 
       ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 206 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 207 | 
   | 
     ShowMessage('TXMP-image replaced'); | 
 
 
 
 
 
 
 
 
 | 208 | 
 + | 
     Self.listClick(Self); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 209 | 
   | 
   end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 210 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 211 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 229 | 
   | 
   OniImage_New := TOniImage.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 230 | 
   | 
   Self.AllowedExts := 'TXMP'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 231 | 
   | 
   Self.OnNewFileSelected := SelectFile; | 
 
 
 
 
 
 
 
 
 | 232 | 
 + | 
   opend.Filter := saved.Filter; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 233 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 234 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 235 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 238 | 
   | 
 procedure TForm_TxmpReplace.btn_saveClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 239 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 240 | 
   | 
   if saved.Execute then | 
 
 
 
 
 
 
 
 
 
 
 
 | 241 | 
 < | 
     OniImage_Old.WriteToBMP(saved.FileName); | 
 
 
 
 
 
 
 
 
 
 | 241 | 
 > | 
     OniImage_Old.WriteToFile(saved.FileName); | 
 
 
 
 
 
 
 
 
 
 
 
 | 242 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 243 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 244 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 245 | 
   | 
   AddToolListEntry('txmpreplace', 'TXMP Replacer', 'TXMP'); | 
 
 
 
 
 
 
 
 
 
 
 
 | 246 | 
 < | 
 end. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 246 | 
 > | 
 end. | 
 
 
 
 
 
 | 247 | 
 > | 
  |