Changeset 198


Ignore:
Timestamp:
May 26, 2007, 9:28:08 PM (14 years ago)
Author:
alloc
Message:
 
Location:
oup/current
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Global/Exporters.pas

    r192 r198  
    225225  img := TOniImage.Create;
    226226  img.Load(ConnectionID, FileID);
     227  img.WriteToFile(filename+'.dds');
    227228  img.WriteToFile(filename+'.bmp');
    228229  img.Free;
  • oup/current/Global/OniImgClass.pas

    r194 r198  
    4848implementation
    4949
    50 //uses Functions;
    5150uses Img_DDSTypes, ImagingComponents;
    5251
     
    180179    x_pspc, y_pspc: Word;
    181180    w, h:    Word;
    182     imgdata: TByteData;
     181    imgdata: TImageData;
    183182    used:    Boolean;
    184183  end;
    185184const
    186185  PartMatch: array[0..8] of Byte = (0, 3, 6, 1, 4, 7, 2, 5, 8);
    187 var
    188   x, y, pixel: Word;
     186  stretch_x: Integer = 50;
     187  stretch_y: Integer = 1;
     188var
     189  x, y: Word;
    189190  i: Integer;
    190191
    191192  PSpc:     TPSpc;
    192193  txmpimg:  TOniImage;
    193   txmpdata: TByteData;
     194//  txmpdata: TByteData;
    194195
    195196  parts:    array[0..8] of TPart;
     
    198199  rows:     array[0..2] of Word;
    199200  col, row: Byte;
    200 begin
    201 (*
     201
     202  pspcimage: TImageData;
     203begin
    202204  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc);
    203205  PSpc.TXMP := PSpc.TXMP div 256;
     
    208210  end;
    209211  txmpimg := TOniImage.Create;
    210   txmpimg.LoadFromTXMP(ConnectionID, PSpc.TXMP);
    211   txmpimg.DecodeImageTo32bit;
    212 //  txmpimg.WriteToBMP('C:\file.bmp');
    213   txmpimg.GetAs32bit(txmpdata);
    214 {    ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height));
    215     for i:=0 to High(txmpdata) do
    216       txmpimg.Data[i]:=txmpdata[i];
    217     txmpimg.WriteToBMP('D:\file2.bmp');
    218 }
    219   with PSpc do
     212  txmpimg.Load(ConnectionID, PSpc.TXMP);
     213  CloneImage(txmpimg.Image[1], pspcimage);
     214  txmpimg.Free;
     215
     216  with pspc do
    220217  begin
    221218    for i := 0 to 2 do
     
    246243        cols[col] := parts[part].w;
    247244        rows[row] := parts[part].h;
    248         SetLength(parts[part].imgdata, parts[part].w * parts[part].h * 4);
    249         for y := 0 to parts[part].h - 1 do
    250         begin
    251           for x := 0 to parts[part].w - 1 do
    252           begin
    253             for pixel := 0 to 3 do
    254             begin
    255               parts[part].imgdata[(y * parts[part].w + x) * 4 + pixel] :=
    256                 txmpdata[((parts[part].y_txmp + y) * txmpimg.Width +
    257                 parts[part].x_txmp + x) * 4 + pixel];
    258             end;
    259           end;
    260         end;
     245
     246        NewImage(parts[part].w, parts[part].h, pspcimage.Format, parts[part].imgdata);
     247
     248        CopyRect(pspcimage,
     249            parts[part].x_txmp, parts[part].y_txmp, parts[part].w, parts[part].h,
     250            parts[part].imgdata, 0, 0);
    261251      end
    262252      else
     
    268258  end;
    269259
    270   txmpimg.Free;
    271   txmpimg := TOniImage.Create;
    272260  for i := 0 to 8 do
    273261  begin
    274262    if parts[i].used then
    275263    begin
    276       SetLength(txmpimg.FData, Length(parts[i].imgdata));
    277       for pixel := 0 to High(parts[i].imgdata) do
    278         txmpimg.Data[pixel] := parts[i].imgdata[pixel];
    279       txmpimg.Width := parts[i].w;
    280       txmpimg.Height    := parts[i].h;
    281       txmpimg.StoreType := 8;
    282       txmpimg.DataType  := [DT_Decoded32];
    283       txmpimg.Depth     := 32;
    284       txmpimg.WriteToBMP('M:\' + IntToStr(i) + '.bmp');
    285     end;
    286   end;
    287   txmpimg.Free;
    288 
    289   Self.FWidth  := 0;
    290   Self.FHeight := 0;
    291   for i := 0 to 2 do
    292   begin
    293     Inc(Self.FWidth, cols[i]);
    294     Inc(Self.FHeight, rows[i]);
    295   end;
    296   SetLength(Self.FData, Self.FWidth * Self.FHeight * 4);
    297 
    298   //Combine data parts
    299 
    300   Self.FDepth     := 32;
    301   Self.FStoreType := 8;
    302   Self.FDataType  := [DT_Decoded32];
    303   //    Self.RevertImage;
    304 *)
     264//      SaveImageToFile('M:\' + IntToStr(i) + '.bmp', parts[i].imgdata);
     265    end;
     266  end;
     267
     268  SetLength(FImages, 1);
     269  x := cols[0] + cols[1] * stretch_x + cols[2];
     270  y := rows[0] + rows[1] * stretch_y + rows[2];
     271
     272  NewImage(x, y, pspcimage.Format, FImages[0]);
     273
     274  x := 0;
     275  for col := 0 to 2 do
     276  begin
     277    y := 0;
     278    for row := 0 to 2 do
     279    begin
     280      part := row*3 + col;
     281      if (row = 1) and (col = 1) then
     282        StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
     283            FImages[0], x, y, parts[part].w * stretch_x, parts[part].h * stretch_y, rfNearest)
     284      else
     285      if (row = 1) then
     286        StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
     287            FImages[0], x, y, parts[part].w, parts[part].h * stretch_y, rfNearest)
     288      else
     289      if (col = 1) then
     290        StretchRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
     291            FImages[0], x, y, parts[part].w * stretch_x, parts[part].h, rfNearest)
     292      else
     293        CopyRect(parts[part].imgdata, 0, 0, parts[part].w, parts[part].h,
     294            FImages[0], x, y );
     295      if row = 1 then
     296        y := y + parts[part].h * stretch_y
     297      else
     298        y := y + parts[part].h;
     299    end;
     300    if (part mod 3) = 1 then
     301      x := x + parts[part].w * stretch_x
     302    else
     303      x := x + parts[part].w;
     304  end;
     305
     306  FreeImage(pspcimage);
     307  for i := 0 to 8 do
     308    if parts[i].used then
     309      FreeImage(parts[i].imgdata);
    305310end;
    306311
     
    465470function TOniImage.LoadFromTXMB(ConnectionID, FileID: Integer): Boolean;
    466471var
    467   i, x, y, x2, y2, pixelid, imgid: Integer;
     472  i, x, y, imgid: Integer;
    468473  rows, cols: Word;
    469474  linkcount: Integer;
  • oup/current/Tools/BinEdit.dfm

    r179 r198  
    1212    inherited filelist: TListBox
    1313      Height = 210
     14      ExplicitHeight = 210
    1415    end
    1516    object panel_imexport: TPanel
  • oup/current/Tools/BinEdit.pas

    r179 r198  
    226226    begin
    227227      if Length(rawlist) > 0 then
     228      begin
    228229        for i := 0 to High(rawlist) do
    229230          if rawlist[i].SrcOffset = offset then
     
    235236            Break;
    236237          end;
     238        if i > High(rawlist) then
     239          Result := 'unused';
     240      end;
    237241    end;
    238242    12:
Note: See TracChangeset for help on using the changeset viewer.