Changeset 192 for oup/current/Tools


Ignore:
Timestamp:
May 24, 2007, 7:48:18 PM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/current/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Tools/Preview.pas

    r111 r192  
    3030    procedure LoadImage(fileid, index: Integer);
    3131  private
    32     bitmaps:   array of TBitmap;
     32    bitmaps:   array of TOniImage;
    3333    actualimg: Byte;
    3434    _fileid:   Integer;
     
    4141implementation
    4242{$R *.dfm}
     43uses Imaging, ImagingComponents, ImagingTypes;
    4344
    4445
     
    8384
    8485procedure 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;
     86begin
     87  bitmaps[index].Load(ConnectionID, fileid);
    9688end;
    9789
     
    9991procedure TForm_Preview.DrawImage(index: Integer);
    10092begin
    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);
    10694end;
    10795
     
    122110    SetLength(bitmaps, Count);
    123111    for i := i to High(bitmaps) do
    124       bitmaps[i] := TBitmap.Create;
     112      bitmaps[i] := TOniImage.Create;
    125113  end;
    126114end;
  • oup/current/Tools/TxmpReplace.dfm

    r177 r192  
    147147  end
    148148  object opend: TOpenDialog [4]
    149     Filter = '24bit Bitmap (*.bmp)|*.bmp'
    150149    Options = [ofPathMustExist, ofFileMustExist, ofEnableSizing]
    151150    Left = 352
     
    154153  object saved: TSaveDialog [5]
    155154    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 (*.*)|*'
    157159    Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing]
    158160    Left = 104
  • oup/current/Tools/TxmpReplace.pas

    r111 r192  
    4141implementation
    4242{$R *.dfm}
    43 uses Main, ConnectionManager;
     43uses Main, ConnectionManager, ImagingTypes;
    4444
    4545
     
    5454  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte);
    5555  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;
    5856
    5957  OniImage_Old.LoadFromTXMP(ConnectionID, fileid);
    60   old_size := OniImage_Old.GetImageDataSize((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];
    6664
    6765  group_bmpselect.Enabled := True;
     
    7573  if opend.Execute then
    7674  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);
    8377    group_options.Enabled := True;
    8478  end;
     
    10498      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr);
    10599
    106     if (OniImage_Old.Width <> OniImage_New.Width) or
    107       (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
    108102    begin
    109103      if MessageBox(Self.Handle,
    110104            PChar(
    111105              '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]) +
    115110              ')' + CrLf + 'Replace anyway?'),
    116111            PChar(filelist.Items.Strings[filelist.ItemIndex]), MB_YESNO) = idNo then
     
    120115    mem := TMemoryStream.Create;
    121116
    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);
    139121
    140122    if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then
    141123      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)
    143126    else
    144127    begin
     
    152135    ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte);
    153136    datbyte := $10;
    154     if check_transparency.Checked then
    155       datbyte := datbyte or $04;
     137//    if check_transparency.Checked then
     138//      datbyte := datbyte or $04;
    156139    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;
    160158    ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @datbyte);
    161159    if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then
     
    188186  Self.AllowedExts := 'TXMP';
    189187  Self.OnNewFileSelected := SelectFile;
     188  opend.Filter := saved.Filter;
    190189end;
    191190
     
    196195begin
    197196  if saved.Execute then
    198     OniImage_Old.WriteToBMP(saved.FileName);
     197    OniImage_Old.WriteToFile(saved.FileName);
    199198end;
    200199
Note: See TracChangeset for help on using the changeset viewer.