| 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; |
| 57 |
|
|
| 58 |
|
OniImage_Old.LoadFromTXMP(ConnectionID, fileid); |
| 59 |
|
old_size := OniImage_Old.GetImageSize(True); |
| 60 |
< |
OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 0); |
| 60 |
> |
OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 1); |
| 61 |
|
|
| 62 |
|
check_fading.Checked := OniImage_Old.HasMipMaps; |
| 63 |
|
// check_transparency.Checked := (depthbyte and $04) > 0; |
| 67 |
|
end; |
| 68 |
|
|
| 69 |
|
|
| 70 |
+ |
procedure TForm_TxmpReplace.Splitter1Moved(Sender: TObject); |
| 71 |
+ |
begin |
| 72 |
+ |
inherited; |
| 73 |
+ |
image_txmppreview.Picture.Assign(nil); |
| 74 |
+ |
image_bmppreview.Picture.Assign(nil); |
| 75 |
+ |
if Length(OniImage_Old.Images) > 0 then |
| 76 |
+ |
OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 1); |
| 77 |
+ |
if Length(OniImage_New.Images) > 0 then |
| 78 |
+ |
OniImage_New.DrawOnCanvas(image_bmppreview.Canvas, 1); |
| 79 |
+ |
end; |
| 80 |
+ |
|
| 81 |
|
procedure TForm_TxmpReplace.btn_loadClick(Sender: TObject); |
| 82 |
|
var |
| 83 |
|
mem: TMemoryStream; |
| 85 |
|
if opend.Execute then |
| 86 |
|
begin |
| 87 |
|
OniImage_New.LoadFromFile(opend.FileName); |
| 88 |
< |
OniImage_New.DrawOnCanvas(image_bmppreview.Canvas, 0); |
| 88 |
> |
OniImage_New.DrawOnCanvas(image_bmppreview.Canvas, 1); |
| 89 |
|
group_options.Enabled := True; |
| 90 |
|
end; |
| 91 |
|
end; |
| 100 |
|
oldfading: Byte; |
| 101 |
|
datbyte: Word; |
| 102 |
|
mem: TMemoryStream; |
| 103 |
+ |
new_storetype: Byte; |
| 104 |
+ |
formatinfo: TImageFormatInfo; |
| 105 |
|
begin |
| 106 |
|
if filelist.ItemIndex >= 0 then |
| 107 |
|
begin |
| 128 |
|
|
| 129 |
|
mem := TMemoryStream.Create; |
| 130 |
|
|
| 131 |
+ |
case OniImage_New.Format of |
| 132 |
+ |
ifA1R5G5B5: new_storetype := 2; |
| 133 |
+ |
ifA4R4G4B4: new_storetype := 0; |
| 134 |
+ |
ifA8R8G8B8: |
| 135 |
+ |
begin |
| 136 |
+ |
new_storetype := 8; |
| 137 |
+ |
OniImage_New.Format := ifX8R8G8B8; |
| 138 |
+ |
end; |
| 139 |
+ |
ifX8R8G8B8: new_storetype := 8; |
| 140 |
+ |
ifDXT1: new_storetype := 9; |
| 141 |
+ |
else |
| 142 |
+ |
if OniImage_New.FormatInfo.HasAlphaChannel then |
| 143 |
+ |
ShowMessage('Loaded image has an alpha-channel.' + #13#10 + |
| 144 |
+ |
'Because the format is neither ARGB1555' +#13#10 + |
| 145 |
+ |
'nor ARGB4444 it can not be imported without conversion.' + #13#10 + |
| 146 |
+ |
'It is converted to RGB888, so alpha gets dropped.' + #13#10 + |
| 147 |
+ |
'If you need alpha you have to save your image in' + #13#10 + |
| 148 |
+ |
'one of the previously named formats.'); |
| 149 |
+ |
OniImage_New.Format := ifX8R8G8B8; |
| 150 |
+ |
new_storetype := 8; |
| 151 |
+ |
end; |
| 152 |
+ |
|
| 153 |
|
OniImage_New.SaveDataToStream(check_fading.Checked, TStream(mem)); |
| 154 |
|
|
| 155 |
|
newsize := mem.Size; |
| 157 |
|
|
| 158 |
|
if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then |
| 159 |
|
new_rawaddr := ConManager.Connection[ConnectionID].AppendRawFile( |
| 160 |
< |
not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), |
| 125 |
< |
mem.Size, mem) |
| 160 |
> |
not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem) |
| 161 |
|
else |
| 162 |
|
begin |
| 163 |
|
new_rawaddr := old_rawaddr; |
| 164 |
|
ConManager.Connection[ConnectionID].UpdateRawFile(fileid, $9C, mem); |
| 165 |
|
end; |
| 166 |
|
|
| 132 |
– |
datbyte := $00; |
| 167 |
|
if check_fading.Checked then |
| 168 |
< |
datbyte := datbyte or $01; |
| 168 |
> |
oldfading := oldfading or $01 |
| 169 |
> |
else |
| 170 |
> |
oldfading := oldfading and (not Byte($01)); |
| 171 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte); |
| 172 |
|
datbyte := $10; |
| 173 |
|
// if check_transparency.Checked then |
| 177 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @datbyte); |
| 178 |
|
datbyte := OniImage_New.Height[1]; |
| 179 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @datbyte); |
| 180 |
< |
case OniImage_New.Format of |
| 145 |
< |
ifA1R5G5B5: datbyte := 2; |
| 146 |
< |
ifA4R4G4B4: datbyte := 0; |
| 147 |
< |
ifA8R8G8B8: |
| 148 |
< |
begin |
| 149 |
< |
datbyte := 8; |
| 150 |
< |
OniImage_New.Format := ifX8R8G8B8; |
| 151 |
< |
end; |
| 152 |
< |
ifX8R8G8B8: datbyte := 8; |
| 153 |
< |
ifDXT1: datbyte := 9; |
| 154 |
< |
else |
| 155 |
< |
OniImage_New.Format := ifX8R8G8B8; |
| 156 |
< |
datbyte := 8; |
| 157 |
< |
end; |
| 158 |
< |
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @datbyte); |
| 180 |
> |
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @new_storetype); |
| 181 |
|
if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then |
| 182 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr) |
| 183 |
|
else |
| 184 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr); |
| 185 |
|
|
| 186 |
|
ShowMessage('TXMP-image replaced'); |
| 187 |
+ |
Self.listClick(Self); |
| 188 |
|
end; |
| 189 |
|
end; |
| 190 |
|
|