Index: oup/current/Global/Exporters.pas
===================================================================
--- oup/current/Global/Exporters.pas	(revision 197)
+++ oup/current/Global/Exporters.pas	(revision 198)
@@ -225,4 +225,5 @@
   img := TOniImage.Create;
   img.Load(ConnectionID, FileID);
+  img.WriteToFile(filename+'.dds');
   img.WriteToFile(filename+'.bmp');
   img.Free;
Index: oup/current/Global/OniImgClass.pas
===================================================================
--- oup/current/Global/OniImgClass.pas	(revision 197)
+++ oup/current/Global/OniImgClass.pas	(revision 198)
@@ -48,5 +48,4 @@
 implementation
 
-//uses Functions;
 uses Img_DDSTypes, ImagingComponents;
 
@@ -180,16 +179,18 @@
     x_pspc, y_pspc: Word;
     w, h:    Word;
-    imgdata: TByteData;
+    imgdata: TImageData;
     used:    Boolean;
   end;
 const
   PartMatch: array[0..8] of Byte = (0, 3, 6, 1, 4, 7, 2, 5, 8);
-var
-  x, y, pixel: Word;
+  stretch_x: Integer = 50;
+  stretch_y: Integer = 1;
+var
+  x, y: Word;
   i: Integer;
 
   PSpc:     TPSpc;
   txmpimg:  TOniImage;
-  txmpdata: TByteData;
+//  txmpdata: TByteData;
 
   parts:    array[0..8] of TPart;
@@ -198,6 +199,7 @@
   rows:     array[0..2] of Word;
   col, row: Byte;
-begin
-(*
+
+  pspcimage: TImageData;
+begin
   ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc);
   PSpc.TXMP := PSpc.TXMP div 256;
@@ -208,14 +210,9 @@
   end;
   txmpimg := TOniImage.Create;
-  txmpimg.LoadFromTXMP(ConnectionID, PSpc.TXMP);
-  txmpimg.DecodeImageTo32bit;
-//  txmpimg.WriteToBMP('C:\file.bmp');
-  txmpimg.GetAs32bit(txmpdata);
-{    ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height));
-    for i:=0 to High(txmpdata) do
-      txmpimg.Data[i]:=txmpdata[i];
-    txmpimg.WriteToBMP('D:\file2.bmp');
-}
-  with PSpc do
+  txmpimg.Load(ConnectionID, PSpc.TXMP);
+  CloneImage(txmpimg.Image[1], pspcimage);
+  txmpimg.Free;
+
+  with pspc do
   begin
     for i := 0 to 2 do
@@ -246,17 +243,10 @@
         cols[col] := parts[part].w;
         rows[row] := parts[part].h;
-        SetLength(parts[part].imgdata, parts[part].w * parts[part].h * 4);
-        for y := 0 to parts[part].h - 1 do
-        begin
-          for x := 0 to parts[part].w - 1 do
-          begin
-            for pixel := 0 to 3 do
-            begin
-              parts[part].imgdata[(y * parts[part].w + x) * 4 + pixel] :=
-                txmpdata[((parts[part].y_txmp + y) * txmpimg.Width +
-                parts[part].x_txmp + x) * 4 + pixel];
-            end;
-          end;
-        end;
+
+        NewImage(parts[part].w, parts[part].h, pspcimage.Format, parts[part].imgdata);
+
+        CopyRect(pspcimage,
+            parts[part].x_txmp, parts[part].y_txmp, parts[part].w, parts[part].h,
+            parts[part].imgdata, 0, 0);
       end
       else
@@ -268,39 +258,54 @@
   end;
 
-  txmpimg.Free;
-  txmpimg := TOniImage.Create;
   for i := 0 to 8 do
   begin
     if parts[i].used then
     begin
-      SetLength(txmpimg.FData, Length(parts[i].imgdata));
-      for pixel := 0 to High(parts[i].imgdata) do
-        txmpimg.Data[pixel] := parts[i].imgdata[pixel];
-      txmpimg.Width := parts[i].w;
-      txmpimg.Height    := parts[i].h;
-      txmpimg.StoreType := 8;
-      txmpimg.DataType  := [DT_Decoded32];
-      txmpimg.Depth     := 32;
-      txmpimg.WriteToBMP('M:\' + IntToStr(i) + '.bmp');
-    end;
-  end;
-  txmpimg.Free;
-
-  Self.FWidth  := 0;
-  Self.FHeight := 0;
-  for i := 0 to 2 do
-  begin
-    Inc(Self.FWidth, cols[i]);
-    Inc(Self.FHeight, rows[i]);
-  end;
-  SetLength(Self.FData, Self.FWidth * Self.FHeight * 4);
-
-  //Combine data parts
-
-  Self.FDepth     := 32;
-  Self.FStoreType := 8;
-  Self.FDataType  := [DT_Decoded32];
-  //    Self.RevertImage;
-*)
+//      SaveImageToFile('M:\' + IntToStr(i) + '.bmp', parts[i].imgdata);
+    end;
+  end;
+
+  SetLength(FImages, 1);
+  x := cols[0] + cols[1] * stretch_x + cols[2];
+  y := rows[0] + rows[1] * stretch_y + rows[2];
+
+  NewImage(x, y, pspcimage.Format, FImages[0]);
+
+  x := 0;
+  for col := 0 to 2 do
+  begin
+    y := 0;
+    for row := 0 to 2 do
+    begin
+      part := row*3 + col;
+      if (row = 1) and (col = 1) then
+        StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
+            FImages[0], x, y, parts[part].w * stretch_x, parts[part].h * stretch_y, rfNearest)
+      else
+      if (row = 1) then
+        StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
+            FImages[0], x, y, parts[part].w, parts[part].h * stretch_y, rfNearest)
+      else
+      if (col = 1) then
+        StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
+            FImages[0], x, y, parts[part].w * stretch_x, parts[part].h, rfNearest)
+      else
+        CopyRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
+            FImages[0], x, y );
+      if row = 1 then
+        y := y + parts[part].h * stretch_y
+      else
+        y := y + parts[part].h;
+    end;
+    if (part mod 3) = 1 then
+      x := x + parts[part].w * stretch_x
+    else
+      x := x + parts[part].w;
+  end;
+
+  FreeImage(pspcimage);
+  for i := 0 to 8 do
+    if parts[i].used then
+      FreeImage(parts[i].imgdata);
 end;
 
@@ -465,5 +470,5 @@
 function TOniImage.LoadFromTXMB(ConnectionID, FileID: Integer): Boolean;
 var
-  i, x, y, x2, y2, pixelid, imgid: Integer;
+  i, x, y, imgid: Integer;
   rows, cols: Word;
   linkcount: Integer;
Index: oup/current/Tools/BinEdit.dfm
===================================================================
--- oup/current/Tools/BinEdit.dfm	(revision 197)
+++ oup/current/Tools/BinEdit.dfm	(revision 198)
@@ -12,4 +12,5 @@
     inherited filelist: TListBox
       Height = 210
+      ExplicitHeight = 210
     end
     object panel_imexport: TPanel
Index: oup/current/Tools/BinEdit.pas
===================================================================
--- oup/current/Tools/BinEdit.pas	(revision 197)
+++ oup/current/Tools/BinEdit.pas	(revision 198)
@@ -226,4 +226,5 @@
     begin
       if Length(rawlist) > 0 then
+      begin
         for i := 0 to High(rawlist) do
           if rawlist[i].SrcOffset = offset then
@@ -235,4 +236,7 @@
             Break;
           end;
+        if i > High(rawlist) then
+          Result := 'unused';
+      end;
     end;
     12:
