| 40 |
|
|
| 41 |
|
implementation |
| 42 |
|
{$R *.dfm} |
| 43 |
< |
uses Main, ConnectionManager; |
| 43 |
> |
uses Main, ConnectionManager, ImagingTypes; |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 53 |
|
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte); |
| 54 |
|
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte); |
| 55 |
|
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; |
| 56 |
|
|
| 57 |
|
OniImage_Old.LoadFromTXMP(ConnectionID, fileid); |
| 58 |
< |
old_size := OniImage_Old.GetImageDataSize((fadingbyte and $01) > 0); |
| 59 |
< |
mem := TMemoryStream.Create; |
| 60 |
< |
OniImage_Old.GetAsBMP(TStream(mem)); |
| 61 |
< |
mem.Seek(0, soFromBeginning); |
| 62 |
< |
image_txmppreview.Picture.Bitmap.LoadFromStream(mem); |
| 63 |
< |
mem.Free; |
| 58 |
> |
old_size := OniImage_Old.GetImageSize(True); |
| 59 |
> |
OniImage_Old.DrawOnCanvas(image_txmppreview.Canvas, 0); |
| 60 |
> |
|
| 61 |
> |
check_fading.Checked := OniImage_Old.HasMipMaps; |
| 62 |
> |
// check_transparency.Checked := (depthbyte and $04) > 0; |
| 63 |
> |
check_transparency.Checked := storebyte in [0, 2, 7]; |
| 64 |
|
|
| 65 |
|
group_bmpselect.Enabled := True; |
| 66 |
|
end; |
| 72 |
|
begin |
| 73 |
|
if opend.Execute then |
| 74 |
|
begin |
| 75 |
< |
OniImage_New.LoadFromBMP(opend.FileName); |
| 76 |
< |
mem := TMemoryStream.Create; |
| 79 |
< |
OniImage_New.GetAsBMP(TStream(mem)); |
| 80 |
< |
mem.Seek(0, soFromBeginning); |
| 81 |
< |
image_bmppreview.Picture.Bitmap.LoadFromStream(mem); |
| 82 |
< |
mem.Free; |
| 75 |
> |
OniImage_New.LoadFromFile(opend.FileName); |
| 76 |
> |
OniImage_New.DrawOnCanvas(image_bmppreview.Canvas, 0); |
| 77 |
|
group_options.Enabled := True; |
| 78 |
|
end; |
| 79 |
|
end; |
| 97 |
|
else |
| 98 |
|
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr); |
| 99 |
|
|
| 100 |
< |
if (OniImage_Old.Width <> OniImage_New.Width) or |
| 101 |
< |
(OniImage_Old.Height <> OniImage_New.Height) then |
| 100 |
> |
if (OniImage_Old.Width[1] <> OniImage_New.Width[1]) or |
| 101 |
> |
(OniImage_Old.Height[1] <> OniImage_New.Height[1]) then |
| 102 |
|
begin |
| 103 |
|
if MessageBox(Self.Handle, |
| 104 |
|
PChar( |
| 105 |
|
'Current image and new image have different size' + CrLf + |
| 106 |
< |
'(Current: ' + IntToStr(OniImage_Old.Width) + 'x' + |
| 107 |
< |
IntToStr(OniImage_Old.Height) + ' - New: ' + |
| 108 |
< |
IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) + |
| 106 |
> |
'(Current: ' + IntToStr(OniImage_Old.Width[1]) + 'x' + |
| 107 |
> |
IntToStr(OniImage_Old.Height[1]) + ' - New: ' + |
| 108 |
> |
IntToStr(OniImage_New.Width[1]) + 'x' + |
| 109 |
> |
IntToStr(OniImage_New.Height[1]) + |
| 110 |
|
')' + CrLf + 'Replace anyway?'), |
| 111 |
|
PChar(filelist.Items.Strings[filelist.ItemIndex]), MB_YESNO) = idNo then |
| 112 |
|
Exit; |
| 114 |
|
|
| 115 |
|
mem := TMemoryStream.Create; |
| 116 |
|
|
| 117 |
< |
if check_fading.Checked then |
| 123 |
< |
if not OniImage_New.GetMipMappedImage(TStream(mem)) then |
| 124 |
< |
if MessageBox(Self.Handle, |
| 125 |
< |
PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' + |
| 126 |
< |
#13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'), |
| 127 |
< |
MB_YESNO) = ID_YES then |
| 128 |
< |
check_fading.Checked := False |
| 129 |
< |
else |
| 130 |
< |
Exit; |
| 117 |
> |
OniImage_New.SaveDataToStream(check_fading.Checked, TStream(mem)); |
| 118 |
|
|
| 119 |
< |
if not check_fading.Checked then |
| 120 |
< |
begin |
| 134 |
< |
mem.Clear; |
| 135 |
< |
OniImage_New.GetAsData(TStream(mem)); |
| 136 |
< |
end; |
| 137 |
< |
|
| 138 |
< |
newsize := OniImage_New.GetImageDataSize(check_fading.Checked); |
| 119 |
> |
newsize := mem.Size; |
| 120 |
> |
mem.Seek(0, soFromBeginning); |
| 121 |
|
|
| 122 |
|
if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then |
| 123 |
|
new_rawaddr := ConManager.Connection[ConnectionID].AppendRawFile( |
| 124 |
< |
not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem.Size, mem) |
| 124 |
> |
not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), |
| 125 |
> |
mem.Size, mem) |
| 126 |
|
else |
| 127 |
|
begin |
| 128 |
|
new_rawaddr := old_rawaddr; |
| 134 |
|
datbyte := datbyte or $01; |
| 135 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte); |
| 136 |
|
datbyte := $10; |
| 137 |
< |
if check_transparency.Checked then |
| 138 |
< |
datbyte := datbyte or $04; |
| 137 |
> |
// if check_transparency.Checked then |
| 138 |
> |
// datbyte := datbyte or $04; |
| 139 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $89, 1, @datbyte); |
| 140 |
< |
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width); |
| 141 |
< |
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height); |
| 142 |
< |
datbyte := $08; |
| 140 |
> |
datbyte := OniImage_New.Width[1]; |
| 141 |
> |
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @datbyte); |
| 142 |
> |
datbyte := OniImage_New.Height[1]; |
| 143 |
> |
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @datbyte); |
| 144 |
> |
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); |
| 159 |
|
if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then |
| 160 |
|
ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr) |
| 185 |
|
OniImage_New := TOniImage.Create; |
| 186 |
|
Self.AllowedExts := 'TXMP'; |
| 187 |
|
Self.OnNewFileSelected := SelectFile; |
| 188 |
+ |
opend.Filter := saved.Filter; |
| 189 |
|
end; |
| 190 |
|
|
| 191 |
|
|
| 194 |
|
procedure TForm_TxmpReplace.btn_saveClick(Sender: TObject); |
| 195 |
|
begin |
| 196 |
|
if saved.Execute then |
| 197 |
< |
OniImage_Old.WriteToBMP(saved.FileName); |
| 197 |
> |
OniImage_Old.WriteToFile(saved.FileName); |
| 198 |
|
end; |
| 199 |
|
|
| 200 |
|
begin |