Changeset 192 for oup/current/Tools
- Timestamp:
- May 24, 2007, 7:48:18 PM (18 years ago)
- Location:
- oup/current/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Tools/Preview.pas
r111 r192 30 30 procedure LoadImage(fileid, index: Integer); 31 31 private 32 bitmaps: array of T Bitmap;32 bitmaps: array of TOniImage; 33 33 actualimg: Byte; 34 34 _fileid: Integer; … … 41 41 implementation 42 42 {$R *.dfm} 43 uses Imaging, ImagingComponents, ImagingTypes; 43 44 44 45 … … 83 84 84 85 procedure TForm_Preview.LoadImage(fileid, index: Integer); 85 var 86 memstream: TMemoryStream; 87 OniImage: TOniImage; 88 begin 89 OniImage := TOniImage.Create; 90 OniImage.Load(ConnectionID, fileid); 91 memstream := TMemoryStream.Create; 92 OniImage.GetAsBMP(TStream(memstream)); 93 OniImage.Free; 94 bitmaps[index].LoadFromStream(memstream); 95 memstream.Free; 86 begin 87 bitmaps[index].Load(ConnectionID, fileid); 96 88 end; 97 89 … … 99 91 procedure TForm_Preview.DrawImage(index: Integer); 100 92 begin 101 BitBlt(img.Canvas.Handle, 0, 0, img.Width, img.Height, 102 bitmaps[index].Canvas.Handle, 0, 0, WHITENESS); 103 BitBlt(img.Canvas.Handle, 0, 0, bitmaps[index].Width, bitmaps[index].Height, 104 bitmaps[index].Canvas.Handle, 0, 0, SRCCOPY); 105 img.Invalidate; 93 bitmaps[index].DrawOnCanvas(img.Canvas, 0); 106 94 end; 107 95 … … 122 110 SetLength(bitmaps, Count); 123 111 for i := i to High(bitmaps) do 124 bitmaps[i] := T Bitmap.Create;112 bitmaps[i] := TOniImage.Create; 125 113 end; 126 114 end; -
oup/current/Tools/TxmpReplace.dfm
r177 r192 147 147 end 148 148 object opend: TOpenDialog [4] 149 Filter = '24bit Bitmap (*.bmp)|*.bmp'150 149 Options = [ofPathMustExist, ofFileMustExist, ofEnableSizing] 151 150 Left = 352 … … 154 153 object saved: TSaveDialog [5] 155 154 DefaultExt = 'bmp' 156 Filter = 'Windows Bitmap (*.bmp)|*.bmp' 155 Filter = 156 'All supported files (*.bmp, *.dds)|*.bmp;*.dds|Windows Bitmap (*' + 157 '.bmp)|*.bmp|DirectDraw Surface (*.dds)|*.dds|Targa (*.tga)|*.tga' + 158 '|JPEG (*.jpg, *.jpeg)|*.jpg;*.jpeg|All files (*.*)|*' 157 159 Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] 158 160 Left = 104 -
oup/current/Tools/TxmpReplace.pas
r111 r192 41 41 implementation 42 42 {$R *.dfm} 43 uses Main, ConnectionManager ;43 uses Main, ConnectionManager, ImagingTypes; 44 44 45 45 … … 54 54 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte); 55 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;58 56 59 57 OniImage_Old.LoadFromTXMP(ConnectionID, fileid); 60 old_size := OniImage_Old.GetImage DataSize((fadingbyte and $01) > 0);61 mem := TMemoryStream.Create;62 OniImage_Old.GetAsBMP(TStream(mem)); 63 mem.Seek(0, soFromBeginning);64 image_txmppreview.Picture.Bitmap.LoadFromStream(mem);65 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]; 66 64 67 65 group_bmpselect.Enabled := True; … … 75 73 if opend.Execute then 76 74 begin 77 OniImage_New.LoadFromBMP(opend.FileName); 78 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); 83 77 group_options.Enabled := True; 84 78 end; … … 104 98 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr); 105 99 106 if (OniImage_Old.Width <> OniImage_New.Width) or107 (OniImage_Old.Height <> OniImage_New.Height) then100 if (OniImage_Old.Width[1] <> OniImage_New.Width[1]) or 101 (OniImage_Old.Height[1] <> OniImage_New.Height[1]) then 108 102 begin 109 103 if MessageBox(Self.Handle, 110 104 PChar( 111 105 'Current image and new image have different size' + CrLf + 112 '(Current: ' + IntToStr(OniImage_Old.Width) + 'x' + 113 IntToStr(OniImage_Old.Height) + ' - New: ' + 114 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]) + 115 110 ')' + CrLf + 'Replace anyway?'), 116 111 PChar(filelist.Items.Strings[filelist.ItemIndex]), MB_YESNO) = idNo then … … 120 115 mem := TMemoryStream.Create; 121 116 122 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; 131 132 if not check_fading.Checked then 133 begin 134 mem.Clear; 135 OniImage_New.GetAsData(TStream(mem)); 136 end; 137 138 newsize := OniImage_New.GetImageDataSize(check_fading.Checked); 117 OniImage_New.SaveDataToStream(check_fading.Checked, TStream(mem)); 118 119 newsize := mem.Size; 120 mem.Seek(0, soFromBeginning); 139 121 140 122 if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then 141 123 new_rawaddr := ConManager.Connection[ConnectionID].AppendRawFile( 142 not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem.Size, mem) 124 not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), 125 mem.Size, mem) 143 126 else 144 127 begin … … 152 135 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte); 153 136 datbyte := $10; 154 if check_transparency.Checked then155 datbyte := datbyte or $04;137 // if check_transparency.Checked then 138 // datbyte := datbyte or $04; 156 139 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $89, 1, @datbyte); 157 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width); 158 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height); 159 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; 160 158 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @datbyte); 161 159 if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then … … 188 186 Self.AllowedExts := 'TXMP'; 189 187 Self.OnNewFileSelected := SelectFile; 188 opend.Filter := saved.Filter; 190 189 end; 191 190 … … 196 195 begin 197 196 if saved.Execute then 198 OniImage_Old.WriteTo BMP(saved.FileName);197 OniImage_Old.WriteToFile(saved.FileName); 199 198 end; 200 199
Note:
See TracChangeset
for help on using the changeset viewer.