From 911e5cb01a4c5811caa32bbe5d5fa56a1118cb5b Mon Sep 17 00:00:00 2001 From: "meffi@lab313.ru" Date: Sun, 27 Apr 2014 23:00:00 +0000 Subject: [PATCH] Updated to last BGRABitmap. Fixed converter. Small fixes. --- tim2view.lpi | 60 +++++++++++++++++++++++++++++++++++------ tim2view.lpr | 4 +-- tim2view.lps | 72 +++++++++++++++++++------------------------------- tim2view.res | Bin 16796 -> 16796 bytes todos.inc | 1 + ucommon.pas | 2 +- udrawtim.pas | 41 ++++++++++++++++------------ umain.lfm | 19 ++++++------- umain.pas | 45 +++++++++++++++++-------------- usettings.pas | 2 +- 10 files changed, 142 insertions(+), 104 deletions(-) diff --git a/tim2view.lpi b/tim2view.lpi index 9f049ea..6f0379a 100644 --- a/tim2view.lpi +++ b/tim2view.lpi @@ -23,11 +23,11 @@ - - + + - + @@ -38,7 +38,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -170,7 +170,7 @@ - + @@ -205,6 +205,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -307,7 +351,7 @@ - + diff --git a/tim2view.lpr b/tim2view.lpr index ec6401b..9363cb8 100644 --- a/tim2view.lpr +++ b/tim2view.lpr @@ -6,9 +6,7 @@ uses {$IFDEF UNIX} cthreads, cmem, {$ENDIF} - Interfaces, // this includes the LCL widgetset - Forms, umain, edc, ucommon, ecc, ucdimage, utim, usettings, uscanresult, - uscanthread, ucpucount, udrawtim, BGRABitmap, uexportimport; + Forms, umain, Interfaces; {$R *.res} diff --git a/tim2view.lps b/tim2view.lps index 9046247..8450797 100644 --- a/tim2view.lps +++ b/tim2view.lps @@ -3,16 +3,16 @@ - + - + - + @@ -25,8 +25,8 @@ - - + + @@ -41,20 +41,19 @@ - - - + + - + @@ -63,7 +62,7 @@ - + @@ -74,7 +73,7 @@ - + @@ -85,7 +84,7 @@ - + @@ -96,10 +95,10 @@ - + - - + + @@ -107,10 +106,10 @@ - + - - + + @@ -118,7 +117,7 @@ - + @@ -129,11 +128,10 @@ - - + - - + + @@ -149,22 +147,20 @@ - - + - - + - - - + + + @@ -173,7 +169,7 @@ - + @@ -188,20 +184,6 @@ - - - - - - - - - - - - - - diff --git a/tim2view.res b/tim2view.res index 3c0edffd52ecf81771ff07dd8186f3fd6130550d..46491ec3ea0b2fff35ccf0a6303496e934073b33 100644 GIT binary patch delta 48 zcmV-00MGxNg8`g_0kEtC0|Wp|ldl6|lPm;~leh&alMn nil) then Surf^.Free; + if (Image^ <> nil) then Image^.Free; - Surf^ := TBGRABitmap.Create(RW, RH); - Surf^.UsePalette := not(TIM^.HEAD^.bBPP in [cTIM16NC, cTIM24NC]); + Image^ := TBGRABitmap.Create(RW, RH); + Image^.UsePalette := not(TIM^.HEAD^.bBPP in [cTIM16NC, cTIM24NC]); - PAL := @(Surf^.Palette); + PAL := @(Image^.Palette); - PrepareClut(TIM, CLUT_NUM, PAL, TranspMode); + PrepareClut(TIM, CLUT_NUM, PAL, TranspMode, ForExport); INDEXES := PrepareIMAGE(TIM); COLORS := GetTimColorsCount(TIM); @@ -210,7 +217,7 @@ begin begin case TIM^.HEAD^.bBPP of cTIM4C, cTIM4NC, cTIM8C, cTIM8NC: - Surf^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS; + Image^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS; cTIM16C, cTIM16NC, cTIMMix: begin CW := 0; @@ -220,7 +227,7 @@ begin FC := BGRAToFPColor(BGRA(CC.R, CC.G, CC.B, CC.STP)); AlphaForMode(@FC, TranspMode); - Surf^.Colors[X - 1, Y - 1] := FC; + Image^.Colors[X - 1, Y - 1] := FC; end; cTIM24C, cTIM24NC: begin @@ -229,7 +236,7 @@ begin R := (INDEX and $FF); G := ((INDEX and $FF00) shr 8); B := ((INDEX and $FF0000) shr 16); - Surf^.Colors[X - 1, Y - 1] := BGRAToFPColor(BGRA(R, G, B, 255)); + Image^.Colors[X - 1, Y - 1] := BGRAToFPColor(BGRA(R, G, B, 255)); end; else Break; diff --git a/umain.lfm b/umain.lfm index dd7606a..8c0c82e 100644 --- a/umain.lfm +++ b/umain.lfm @@ -1,7 +1,7 @@ object frmMain: TfrmMain - Left = 807 + Left = 919 Height = 590 - Top = 193 + Top = 209 Width = 780 HorzScrollBar.Page = 780 HorzScrollBar.Range = 489 @@ -954,12 +954,12 @@ object frmMain: TfrmMain object actScanFile: TAction Caption = 'Scan &File...' OnExecute = actScanFileExecute - ShortCut = 116 + ShortCut = 117 end object actScanDir: TAction Caption = 'Scan &Directory...' OnExecute = actScanDirExecute - ShortCut = 117 + ShortCut = 118 end object actCloseFile: TAction Caption = 'Close &this File' @@ -981,20 +981,21 @@ object frmMain: TfrmMain OnExecute = actExtractTimExecute ShortCut = 113 end + object actPngExport: TAction + Caption = 'Export &PNG...' + OnExecute = actPngExportExecute + ShortCut = 115 + end object actPngImport: TAction Caption = '&Import PNG...' OnExecute = actPngImportExecute + ShortCut = 116 end object actReplaceTim: TAction Caption = '&Replace TIM...' OnExecute = actReplaceTimExecute ShortCut = 114 end - object actPngExport: TAction - Caption = 'Export &PNG...' - OnExecute = actPngExportExecute - ShortCut = 115 - end object actOpenRepo: TAction Caption = 'Tim2Vew &SVN Repo' OnExecute = actOpenRepoExecute diff --git a/umain.pas b/umain.pas index 9588975..17e6863 100644 --- a/umain.pas +++ b/umain.pas @@ -5,10 +5,10 @@ unit umain; interface uses - Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList, + Classes, SysUtils, FileUtil, Forms, Dialogs, ActnList, Menus, StdCtrls, ExtCtrls, ComCtrls, Grids, ExtDlgs, - uscanresult, uscanthread, usettings, utim, udrawtim; + uscanresult, uscanthread, usettings, utim, udrawtim, types; {$INCLUDE todos.inc} @@ -185,7 +185,8 @@ var implementation -uses ucdimage, ucpucount, lcltype, ucommon, LCLIntf, uexportimport +uses ucdimage, ucpucount, lcltype, ucommon, LCLIntf, uexportimport, + FPimage {$IFDEF windows} ,registry @@ -237,17 +238,20 @@ end; procedure TfrmMain.actPngExportExecute(Sender: TObject); var TIM: PTIM; + Image: PDrawSurf; begin TIM := SelectedTimInMode; if TIM = nil then Exit; dlgSavePNG.FileName := FormatPngName(SelectedScanResult.ScanFile, TIM^.dwTimNumber, SelectedTimInfo.BitMode, cbbCLUT.ItemIndex); - if not dlgSavePNG.Execute then Exit; - SaveImage(dlgSavePNG.FileName, Surf, TIMisIndexed(TIM)); + Tim2Png(TIM, cbbCLUT.ItemIndex, Image, cbbTranspMode.ItemIndex, True); + SaveImage(dlgSavePNG.FileName, Image, TIMisIndexed(TIM)); FreeTIM(TIM); - {$IFDEF Linux}FpChmod(dlgSavePNG.FileName, &777){$IFEND} + Image^.Free; + Dispose(Image); + {$IFDEF Linux}FpChmod(dlgSavePNG.FileName, &777);{$IFEND} end; procedure TfrmMain.btnShowClutClick(Sender: TObject); @@ -382,15 +386,15 @@ var IsImage: Boolean; ScanTim: TTimInfo; TIM: PTIM; - PNG: PDrawSurf; + Image: PDrawSurf; begin lblStatus.Caption := sStatusBarPngsExtracting; FName := SelectedScanResult.ScanFile; IsImage := SelectedScanResult.IsImage; - New(PNG); - PNG^ := nil; + New(Image); + Image^ := nil; pbProgress.Position := 0; pbProgress.Max := SelectedScanResult.Count; @@ -407,20 +411,20 @@ begin CreateDirUTF8(Path); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); - Tim2Png(TIM, cbbCLUT.ItemIndex, PNG, cbbTranspMode.ItemIndex); + Tim2Png(TIM, cbbCLUT.ItemIndex, Image, cbbTranspMode.ItemIndex, False); Path := Path + FormatPngName(FName, I - 1, BIT_MODE, 0); - SaveImage(Path, PNG, TIMisIndexed(TIM)); - {$IFDEF Linux}FpChmod(Path, &777){$IFEND} - PNG^.Free; - PNG^ := nil; + SaveImage(Path, Image, TIMisIndexed(TIM)); + {$IFDEF Linux}FpChmod(Path, &777);{$IFEND} + Image^.Free; + Image^ := nil; FreeTIM(TIM); pbProgress.Position := I; Application.ProcessMessages; end; - Dispose(PNG); + Dispose(Image); lblStatus.Caption := sStatusBarExtracted; pbProgress.Position := 0; end; @@ -435,7 +439,7 @@ begin TIM := SelectedTimInMode; SaveTimToFile(dlgSaveTIM.FileName, TIM); - {$IFDEF Linux}FpChmod(dlgSaveTIM.FileName, &777){$IFEND} + {$IFDEF Linux}FpChmod(dlgSaveTIM.FileName, &777);{$IFEND} FreeTIM(TIM); end; @@ -469,7 +473,7 @@ begin TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); Path := Path + FormatTimName(FName, I - 1, BIT_MODE); SaveTimToFile(Path, TIM); - {$IFDEF Linux}FpChmod(Path, &777){$IFEND} + {$IFDEF Linux}FpChmod(Path, &777);{$IFEND} FreeTIM(TIM); pbProgress.Position := I; @@ -553,7 +557,6 @@ begin Surf^.Free; Dispose(Surf); - Settings.Free; end; @@ -821,6 +824,7 @@ begin actReplaceTim.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1); actPngExport.Enabled := (Surf^ <> nil) and actReplaceTim.Enabled; + actPngImport.Enabled := actReplaceTim.Enabled; actExtractTim.Enabled := actReplaceTim.Enabled; pnlImageOptions.Enabled := actReplaceTim.Enabled; @@ -895,13 +899,14 @@ procedure TfrmMain.DrawSelTim; var TIM: PTIM; begin + imgTim.Picture.Bitmap.FreeImage; imgTim.Picture.Bitmap := nil; TIM := SelectedTimInMode; if TIM = nil then Exit; - Tim2Png(TIM, cbbCLUT.ItemIndex, Surf, cbbTranspMode.ItemIndex); - imgTim.Picture.Bitmap := Surf^.Bitmap; + Tim2Png(TIM, cbbCLUT.ItemIndex, Surf, cbbTranspMode.ItemIndex, False); + imgTim.Picture.Bitmap.Assign(Surf^.Bitmap); FreeTIM(TIM); imgTim.Stretch := actStretch.Checked; diff --git a/usettings.pas b/usettings.pas index 6f03c8b..93cc2f1 100644 --- a/usettings.pas +++ b/usettings.pas @@ -5,7 +5,7 @@ unit usettings; interface uses - Classes, SysUtils, IniFiles, Graphics; + SysUtils, IniFiles, Graphics; type