| 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); |
| 39 |
|
public |
| 40 |
|
end; |
| 41 |
|
|
| 39 |
– |
var |
| 40 |
– |
Form_TxmpReplace: TForm_TxmpReplace; |
| 41 |
– |
|
| 42 |
|
implementation |
| 43 |
|
{$R *.dfm} |
| 44 |
< |
uses Main, ConnectionManager, ImagingTypes; |
| 45 |
< |
|
| 46 |
< |
|
| 44 |
> |
uses |
| 45 |
> |
_TemplateFile, ConnectionManager, ImagingTypes; |
| 46 |
|
|
| 47 |
|
procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo); |
| 48 |
|
var |
| 50 |
– |
mem: TMemoryStream; |
| 49 |
|
fadingbyte, depthbyte, storebyte: Byte; |
| 50 |
|
begin |
| 51 |
|
fileid := fileinfo.ID; |
| 77 |
|
end; |
| 78 |
|
|
| 79 |
|
procedure TForm_TxmpReplace.btn_loadClick(Sender: TObject); |
| 82 |
– |
var |
| 83 |
– |
mem: TMemoryStream; |
| 80 |
|
begin |
| 81 |
|
if opend.Execute then |
| 82 |
|
begin |
| 97 |
|
datbyte: Word; |
| 98 |
|
mem: TMemoryStream; |
| 99 |
|
new_storetype: Byte; |
| 100 |
< |
formatinfo: TImageFormatInfo; |
| 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_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 |
| 149 |
|
mem := TMemoryStream.Create; |
| 150 |
|
|
| 151 |
|
case OniImage_New.Format of |
| 152 |
+ |
ifX1R5G5B5: new_storetype := 1; |
| 153 |
|
ifA1R5G5B5: new_storetype := 2; |
| 154 |
|
ifA4R4G4B4: new_storetype := 0; |
| 155 |
|
ifA8R8G8B8: |
| 243 |
|
|
| 244 |
|
begin |
| 245 |
|
AddToolListEntry('txmpreplace', 'TXMP Replacer', 'TXMP'); |
| 246 |
< |
end. |
| 246 |
> |
end. |
| 247 |
> |
|