Engine directory for ticket #1

This commit is contained in:
DavidWyand-GG 2012-09-19 11:15:01 -04:00
parent 352279af7a
commit 7dbfe6994d
3795 changed files with 1363358 additions and 0 deletions

View file

@ -0,0 +1,25 @@
//---------------------------------------------------------------------------
// About.cpp : About pane text
//---------------------------------------------------------------------------
#include "About.h"
// NB : If more text is to go in here don't forget to enlarge min/max
extern char *_szAbout = {
"\nCopyright (c) 2000 Andy Protano (a.a.protano@care4free.net)"\
"\n Gerard Juyn (gerard@libmng.com)"\
"\n"\
"\nLibmng website - www.libmng.com"
"\nMNG Homepage - www.libpng.org/pub/mng"
"\nPNG Homepage - www.libpng.org/pub/png"
"\n"
"\nThis program is based upon the orignal \'MngTree\' by Gerard Juyn"\
"\nAuthor & current maintainer : Andy Protano (a.a.protano@care4free.net)"\
"\n"\
"\nThis software is based on libmng which in its turn is based on software by :"\
"\n"\
"\nIndependant JPEG Group - http://www.ijg.org"\
"\nLcms (little CMS) library by Marti Maria Saguar - http://www.lcms.colorid.de"\
"\nZlib - http://www.info-zip.org/pub/infozip/zlib"\
};
//---------------------------------------------------------------------------

View file

@ -0,0 +1,7 @@
//---------------------------------------------------------------------------
#ifndef AboutH
#define AboutH
//---------------------------------------------------------------------------
extern char *_szAbout;
#endif

View file

@ -0,0 +1,96 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
# include <stdlib.h>
#include "Main.h"
//---------------------------------------------------------------------------
mng_ptr __stdcall TMainForm::Alloc( mng_size_t iSize )
{
return (mng_ptr)calloc( 1, (size_t)iSize );
}
//---------------------------------------------------------------------------
void __stdcall TMainForm::Free( mng_ptr pPtr, mng_size_t iSize )
{
free( pPtr );
return;
}
//---------------------------------------------------------------------------
mng_bool __stdcall TMainForm::FileReadData( mng_handle hMNG,
mng_ptr pBuf,
mng_uint32 iSize,
mng_uint32 *iRead )
{
TMainForm *MainForm = (TMainForm *)mng_get_userdata( hMNG );
*iRead = fread( pBuf, 1, iSize, MainForm->GetFd() );
// iRead will indicate EOF
MainForm->ProgressBar1->Position += (int)iRead;
return MNG_TRUE;
}
//---------------------------------------------------------------------------
mng_bool __stdcall TMainForm::ProcessHeader( mng_handle hHandle,
mng_uint32 iWidth,
mng_uint32 iHeight )
{
TMainForm *MainForm = (TMainForm *)mng_get_userdata( hHandle );
MainForm->Caption = ExtractFileName( MainForm->OpenDialog1->FileName ) +
" [" +
String( iWidth ) +
"x" +
String( iHeight ) +
"]";
Application->Title = MainForm->asAppName + " " + MainForm->Caption;
MainForm->ProgressBar1->Max = iWidth * iHeight;
return MNG_TRUE;
}
//---------------------------------------------------------------------------
mng_bool __stdcall TMainForm::OpenStream( mng_handle hMNG )
{
// nothing to do !
return MNG_TRUE;
}
//---------------------------------------------------------------------------
mng_bool __stdcall TMainForm::CloseStream( mng_handle hMNG )
{
MainForm->ProgressBar1->Position = 0;
return MNG_TRUE;
}
//---------------------------------------------------------------------------
mng_bool __stdcall TMainForm::IterateChunks( mng_handle hMNG,
mng_handle hChunk,
mng_chunkid iChunktype,
mng_uint32 iChunkseq )
{
TMainForm *MainForm = (TMainForm *)mng_get_userdata( hMNG );
char aCh[5];
// decode the chunkname
aCh[0] = (char)((iChunktype >> 24) & 0xFF);
aCh[1] = (char)((iChunktype >> 16) & 0xFF);
aCh[2] = (char)((iChunktype >> 8) & 0xFF);
aCh[3] = (char)((iChunktype ) & 0xFF);
aCh[4] = (char)0; // zero terminate - used as a "C" string below
MainForm->RichEditReport->Lines->Add( "" );
MainForm->RichEditReport->Lines->Add(
"Chunk " + String( iChunkseq + 1 ) + " : " + String( aCh ) );
// Add Chunk text to listbox
MainForm->ListBoxChunks->Items->Add( aCh );
// keep'm coming ... unless we encounter an error
return MainForm->ShowChunk( hMNG, hChunk, iChunktype );
}
//---------------------------------------------------------------------------

View file

@ -0,0 +1,39 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Main.h"
#include "libmng.h"
#pragma hdrstop
#ifndef CallbackH
#define CallbackH
//---------------------------------------------------------------------------
extern mng_ptr __stdcall myalloc( mng_size_t iSize );
//---------------------------------------------------------------------------
extern void __stdcall myfree( mng_ptr pPtr, mng_size_t iSize );
//---------------------------------------------------------------------------
extern mng_bool __stdcall myreaddata( mng_handle hMNG,
mng_ptr pBuf,
mng_uint32 iSize,
mng_uint32 *iRead );
//---------------------------------------------------------------------------
extern mng_bool __stdcall ProcessHeader( mng_handle hHandle,
mng_uint32 iWidth,
mng_uint32 iHeight );
//---------------------------------------------------------------------------
extern mng_bool __stdcall myopenstream( mng_handle hMNG );
//---------------------------------------------------------------------------
extern mng_bool __stdcall myclosestream( mng_handle hMNG );
//---------------------------------------------------------------------------
extern mng_bool __stdcall myiterchunk ( mng_handle hMNG,
mng_handle hChunk,
mng_chunkid iChunktype,
mng_uint32 iChunkseq );
//---------------------------------------------------------------------------
extern mng_bool __stdcall mytraceproc( mng_handle hHandle,
mng_int32 iFuncnr,
mng_int32 iFuncseq,
mng_pchar zFuncname );
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
//---------------------------------------------------------------------------
// Help.cpp : Help pane text
//---------------------------------------------------------------------------
#include "Help.h"
// NB : If more text is to go in here don't forget to enlarge min/max
extern char *_szHelp = {
"\nA MNG developers tool to display the chunk data of MNG/JNG/PNG files."\
"\n"
"\nMngDump - Version 1.0 - September 2000"\
"\n"\
"\n NOTE - This program comes with NO warranties whatsoever."\
"\n"\
"\nInstruction for use ... press the folder button and load a file !"\
"\n"\
"\nThe following chunks are (currently) unsupported :"\
"\nIJNG, IPNG, JSEP, MaGN, MAGN, oFFs, pCAL, sCAL"\
"\n"\
"\nThe program will be periodically updated, inline with libmng's growth."\
"\nPlease report any bugs, suggestions, etc to the maintainer."
};
//---------------------------------------------------------------------------

View file

@ -0,0 +1,6 @@
//---------------------------------------------------------------------------
#ifndef HelpH
#define HelpH
//---------------------------------------------------------------------------
extern char *_szHelp;
#endif

View file

@ -0,0 +1,195 @@
# ---------------------------------------------------------------------------
!if !$d(BCB)
BCB = $(MAKEDIR)\..
!endif
# ---------------------------------------------------------------------------
# IDE SECTION
# ---------------------------------------------------------------------------
# The following section of the project makefile is managed by the BCB IDE.
# It is recommended to use the IDE to change any of the values in this
# section.
# ---------------------------------------------------------------------------
VERSION = BCB.03
# ---------------------------------------------------------------------------
PROJECT = MNGDUMP.exe
OBJFILES = MNGDUMP.obj Main.obj Chunks.obj About.obj Callback.obj Help.obj
RESFILES = MngDump.res
DEFFILE =
RESDEPEN = $(RESFILES) Main.dfm
LIBFILES = ..\..\..\bcb\win32dll\libmng.lib
LIBRARIES = VCL35.lib
SPARELIBS = VCL35.lib
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi bcbsmp35.bpi dclocx35.bpi \
QRPT35.bpi
# ---------------------------------------------------------------------------
PATHCPP = .;
PATHASM = .;
PATHPAS = .;
PATHRC = .;
DEBUGLIBPATH = $(BCB)\lib\debug
RELEASELIBPATH = $(BCB)\lib\release
# ---------------------------------------------------------------------------
CFLAG1 = -O2 -w -Ve -k- -vi -c -b- -w-par -w-inl -Vx -tW
CFLAG2 = -I..\win32dll;$(BCB)\include;$(BCB)\include\vcl;..\..\..\libmng;..\..\..\zlib;..\..\..\jpgsrc6b
CFLAG3 = -Tkh30000 -6
PFLAGS = -U..\win32dll;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \
-I..\win32dll;$(BCB)\include;$(BCB)\include\vcl;..\..\..\libmng;..\..\..\zlib;..\..\..\jpgsrc6b \
-$L- -$D- -v -JPHN -M
RFLAGS = -i..\win32dll;$(BCB)\include;$(BCB)\include\vcl;..\..\..\libmng;..\..\..\zlib;..\..\..\jpgsrc6b
AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /i..\..\..\libmng /i..\..\..\zlib \
/i..\..\..\jpgsrc6b /mx /w2 /zd /dMNG_SUPPORT_READ /dMNG_ACCESS_CHUNKS \
/dMNG_STORE_CHUNKS /dMNG_NO_CMS /dMNG_USE_DLL /dHAVE_BOOLEAN
LFLAGS = -L..\win32dll;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -aa -Tpe -x -Gn
IFLAGS =
# ---------------------------------------------------------------------------
ALLOBJ = c0w32.obj sysinit.obj $(OBJFILES)
ALLRES = $(RESFILES)
ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib
# ---------------------------------------------------------------------------
!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=1
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=1
Special=0
Private=0
DLL=0
Locale=2057
CodePage=1252
[Version Info Keys]
CompanyName=RDS
FileDescription=MngDump
FileVersion=1.0.0.0
InternalName=
LegalCopyright=Copyright (c) 2000 G.Juyn
LegalTrademarks=
OriginalFilename=MngTree
ProductName=
ProductVersion=1.0.0.0
Comments=Author Andy Protano - September 2000
[HistoryLists\hlIncludePath]
Count=10
Item0=$(BCB)\include;$(BCB)\include\vcl;..\..\..\libmng;..\..\..\zlib;..\..\..\jpgsrc6b
Item1=$(BCB)\include;$(BCB)\include\vcl;..\..;..\..\..\zlib;..\..\..\jpgsrc6b
Item2=..\mngtree;..\..\delphi\mngview;$(BCB)\include;$(BCB)\include\vcl;..\..\..\libmng;..\..\..\zlib;..\..\..\jpgsrc6b
Item3=..\mngtree;..\..\delphi\mngview;$(BCB)\include;$(BCB)\include\vcl;..\..\..\libmng;..\..\..\zlib;..\..\..\libjpeg
Item4=..\..\delphi\mngview;$(BCB)\include;$(BCB)\include\vcl;..\..;..\..\..\zlib;..\..\..\libjpeg
Item5=$(BCB)\include;$(BCB)\include\vcl;..\..;..\..\..\zlib;..\..\..\libjpeg
Item6=$(BCB)\include;$(BCB)\include\vcl;..\..;..\..\zlib;..\..\libjpeg
Item7=$(BCB)\include;$(BCB)\include\vcl;..\..
Item8=$(BCB)\include;$(BCB)\include\vcl;..
Item9=$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=4
Item0=$(BCB)\lib\obj;$(BCB)\lib
Item1=..\mngtree;$(BCB)\lib\obj;$(BCB)\lib
Item2=..\mngtree;..\..\delphi\mngview;$(BCB)\lib\obj;$(BCB)\lib
Item3=..\..\delphi\mngview;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[HistoryLists\hlConditionals]
Count=6
Item0=MNG_SUPPORT_READ;MNG_ACCESS_CHUNKS;MNG_STORE_CHUNKS;MNG_NO_CMS;MNG_USE_DLL;HAVE_BOOLEAN
Item1=_RTLDLL;MNG_SUPPORT_READ;MNG_ACCESS_CHUNKS;MNG_STORE_CHUNKS;MNG_NO_CMS;MNG_USE_DLL;HAVE_BOOLEAN
Item2=_RTLDLL;MNG_SUPPORT_READ;MNG_ACCESS_CHUNKS;MNG_STORE_CHUNKS;MNG_NO_CMS;MNG_USE_DLL
Item3=_RTLDLL;HAVE_BOOLEAN
Item4=_RTLDLL
Item5=_RTLDLL;USEPACKAGES
[Debugging]
DebugSourceDirs=$(BCB)\source\vcl
[Parameters]
RunParams=
HostApplication=
!endif
# ---------------------------------------------------------------------------
# MAKE SECTION
# ---------------------------------------------------------------------------
# This section of the project file is not used by the BCB IDE. It is for
# the benefit of building from the command-line using the MAKE utility.
# ---------------------------------------------------------------------------
.autodepend
# ---------------------------------------------------------------------------
!if !$d(BCC32)
BCC32 = bcc32
!endif
!if !$d(DCC32)
DCC32 = dcc32
!endif
!if !$d(TASM32)
TASM32 = tasm32
!endif
!if !$d(LINKER)
LINKER = ilink32
!endif
!if !$d(BRCC32)
BRCC32 = brcc32
!endif
# ---------------------------------------------------------------------------
!if $d(PATHCPP)
.PATH.CPP = $(PATHCPP)
.PATH.C = $(PATHCPP)
!endif
!if $d(PATHPAS)
.PATH.PAS = $(PATHPAS)
!endif
!if $d(PATHASM)
.PATH.ASM = $(PATHASM)
!endif
!if $d(PATHRC)
.PATH.RC = $(PATHRC)
!endif
# ---------------------------------------------------------------------------
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE)
$(BCB)\BIN\$(LINKER) @&&!
$(LFLAGS) +
$(ALLOBJ), +
$(PROJECT),, +
$(ALLLIB), +
$(DEFFILE), +
$(ALLRES)
!
# ---------------------------------------------------------------------------
.pas.hpp:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.pas.obj:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.cpp.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.c.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.asm.obj:
$(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@
.rc.res:
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $<
# ---------------------------------------------------------------------------

Binary file not shown.

View file

@ -0,0 +1,27 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
USERES("MngDump.res");
USEFORM("Main.cpp", MainForm);
USEUNIT("Chunks.cpp");
USEUNIT("About.cpp");
USEUNIT("Callback.cpp");
USEUNIT("Help.cpp");
USELIB("..\..\..\bcb\win32dll\libmng.lib");
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->Title = "MngDump";
Application->CreateForm(__classid(TMainForm), &MainForm);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
//---------------------------------------------------------------------------

View file

@ -0,0 +1,793 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdlib.h>
#include <dir.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#include "Main.h"
TMainForm *MainForm;
//---------------------------------------------------------------------------
#include "About.h"
#include "Help.h"
# define PAGE_CHUNKS 1
# define PAGE_REPORT 2
# define PAGE_OPTIONS 3
# define PAGE_ABOUT 4
# define PAGE_HELP 5
/* ************************************************************************** */
/* * * */
/* * MngDump is based on Gerard Juyn's MngTree * */
/* * * */
/* * COPYRIGHT NOTICE: * */
/* * * */
/* * Copyright (c) 2000 Andy Protano * */
/* * Gerard Juyn (gerard@libmng.com) * */
/* * [You may insert additional notices after this sentence if you modify * */
/* * this source] * */
/* * * */
/* * For the purposes of this copyright and license, "Contributing Authors" * */
/* * is defined as the following set of individuals: * */
/* * * */
/* * Gerard Juyn (gerard@libmng.com) * */
/* * Andy Protano (a.a.protano@care4free.net) * */
/* * * */
/* * This program is supplied "AS IS". The Contributing Authors * */
/* * disclaim all warranties, expressed or implied, including, without * */
/* * limitation, the warranties of merchantability and of fitness for any * */
/* * purpose. The Contributing Authors assume no liability for direct, * */
/* * indirect, incidental, special, exemplary, or consequential damages, * */
/* * which may result from the use of the MNG Library, even if advised of * */
/* * the possibility of such damage. * */
/* * * */
/* * Permission is hereby granted to use, copy, modify, and distribute this * */
/* * source code, or portions hereof, for any purpose, without fee, subject * */
/* * to the following restrictions: * */
/* * * */
/* * 1. The origin of this source code must not be misrepresented; * */
/* * you must not claim that you wrote the original software. * */
/* * * */
/* * 2. Altered versions must be plainly marked as such and must not be * */
/* * misrepresented as being the original source. * */
/* * * */
/* * 3. This Copyright notice may not be removed or altered from any source * */
/* * or altered source distribution. * */
/* * * */
/* * The Contributing Authors specifically permit, without fee, and * */
/* * encourage the use of this source code as a component to supporting * */
/* * the MNG and JNG file format in commercial products. If you use this * */
/* * source code in a product, acknowledgment would be highly appreciated. * */
/* * * */
/* ************************************************************************** */
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
__fastcall TMainForm::~TMainForm( void )
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::OnMinMax(TMessage& Msg)
{
((POINT far *)Msg.LParam)[3].x = 500;
((POINT far *)Msg.LParam)[3].y = 450;
TForm::Dispatch(&Msg);
}
//---------------------------------------------------------------------------
// MessageBox Methods
// ----------------------------------------------------------------------
int __fastcall TMainForm::MessageBox( String &as, UINT flags )
{
return ::MessageBox( Handle, as.c_str(), Application->Title.c_str(), flags );
}
// ----------------------------------------------------------------------
void __fastcall TMainForm::MsgBoxOk( String as )
{
(void)MessageBox( as, MB_ICONINFORMATION );
}
//-------------------------------------------------------------------------
int __fastcall TMainForm::MsgBoxYN( String as )
{
return MessageBox( as, MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON1 );
}
//-------------------------------------------------------------------------
int __fastcall TMainForm::MsgBoxYNC( String as )
{
return MessageBox( as, MB_YESNOCANCEL | MB_ICONQUESTION );
}
//-------------------------------------------------------------------------
void __fastcall TMainForm::MsgBoxStop( String as )
{
(void)MessageBox( as, MB_ICONSTOP );
}
//-------------------------------------------------------------------------
void __fastcall TMainForm::MsgBoxInfo( String as )
{
(void)MessageBox( as, MB_OK | MB_ICONINFORMATION );
}
//-------------------------------------------------------------------------
void __fastcall TMainForm::MsgBoxWarn( String as )
{
(void)MessageBox( as, MB_OK | MB_ICONWARNING );
}
//-------------------------------------------------------------------------
void __fastcall TMainForm::FormCreate(TObject *Sender)
{
// For when the application name changes - coz i'll forget !
asAppName = Application->Title;
// And while we've got it set the caption
Caption = Application->Title;
// Load About Screen
LabelAbout->Caption = _szAbout;
// Load Help Screen
LabelHelp->Caption = _szHelp;
fd = NULL;
strList = new TStringList();
asTab = " ";// default tab size 2
RadioGroupTabSize->ItemIndex = 1; // range is zero based
// Start with the help pane
PageControl1->ActivePage = tsHelp;
mnuWordWrap->Checked = false;
// This call will TOGGLE and set word wrap for all the applicables
// editors and enable/disable the Horz scroll bar.
mnuWordWrapClick( this ); // So start with false to get to true;
// Clear things from design time settings
StaticTextStatus->Caption = "";
//strList->Clear(); constructor dodid that
pnlChunks->Caption = "";
ListBoxChunks->Clear();
RichEditChunks->Clear();
RichEditReport->Clear();
ProgressBar1->Min = 0;
ProgressBar1->Position = 0;
SetChunkCount( 0 );
// Set default states for switches
cbPaletteEntries->Checked = false;
cbRGBOrder->Checked = true;
cbRawData->Checked = true;
cbComments->Checked = true;
cbMacroIdentifier->Checked = true;
cbBool->Checked = true;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormDestroy(TObject *Sender)
{
delete strList;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuExitClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuFileOpenClick(TObject *Sender)
{
if( !OpenDialog1->Execute() )
return;
Application->ProcessMessages(); // Refresh the screen
LoadFile();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuReloadClick(TObject *Sender)
{
// Only reload - if we have something to reload
if( OpenDialog1->FileName.Length() )
LoadFile();
else
MsgBoxStop( "Nothing to reload yet !" );
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuUndoClick(TObject *Sender)
{
if( RichEditReport->Lines->Count ) // Do we have something in there ?
RichEditReport->Undo();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuCutClick(TObject *Sender)
{
if( RichEditReport->Lines->Count ) // Do we have something in there ?
RichEditReport->CutToClipboard();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuCopyClick(TObject *Sender)
{
if( RichEditReport->Lines->Count ) // Do we have something in there ?
RichEditReport->CopyToClipboard();
}
//-------------------------------------------------------------------------
void __fastcall TMainForm::sbtnCopyChunkClick(TObject *Sender)
{
if( RichEditChunks->Lines->Count ) // Do we have something in there ?
{
// Copy chunk data from Chunks pane to clipboard
RichEditChunks->SelectAll();
RichEditChunks->CopyToClipboard();
RichEditChunks->SelLength = 0;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuPasteClick(TObject *Sender)
{
if( RichEditReport->Lines->Count ) // Do we have something in there ?
RichEditReport->PasteFromClipboard();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuSelectAllClick(TObject *Sender)
{
if( RichEditReport->Lines->Count ) // Do we have something in there ?
RichEditReport->SelectAll();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuWordWrapClick(TObject *Sender)
{
bool bWrap;
mnuWordWrap->Checked = !mnuWordWrap->Checked;
bWrap = mnuWordWrap->Checked;
RichEditChunks->WordWrap = bWrap;
RichEditReport->WordWrap = bWrap;
if( bWrap ) { // if Word wrap on then no need for horizontal scrollbar
RichEditChunks->ScrollBars = ssVertical;
RichEditReport->ScrollBars = ssVertical;
} else { // Horizontal scrollbar required (auto)
RichEditChunks->ScrollBars = ssBoth;
RichEditReport->ScrollBars = ssBoth;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuSetFontClick(TObject *Sender)
{
if( FontDialog1->Execute() )
{
RichEditChunks->Font = FontDialog1->Font;
RichEditReport->Font = FontDialog1->Font;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FontDialog1Apply(TObject *Sender, HWND Wnd)
{
RichEditChunks->Font = FontDialog1->Font;
RichEditReport->Font = FontDialog1->Font;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuFindClick(TObject *Sender)
{
if( RichEditReport->Lines->Count == 0 )
{
MsgBoxStop( "Find what ?.");
return;
}
FindDialog->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FindDialogFind(TObject *Sender)
{
TSearchTypes st;
TFindDialog *fd;
int newpos;
if( RichEditReport->Lines->Count == 0 )
{
MsgBoxStop( "Find what ?.");
return;
}
fd = dynamic_cast<TFindDialog *>( Sender );
if( fd->Options.Contains( frMatchCase ) )
st << stMatchCase;
if( fd->Options.Contains( frWholeWord ) )
st << stWholeWord;
if( RichEditReport->SelLength )
RichEditReport->SelStart += 1;
newpos = RichEditReport->FindText( fd->FindText,
RichEditReport->SelStart, RichEditReport->Text.Length(), st );
if( newpos != -1 ) {
RichEditReport->SelStart = newpos;
RichEditReport->SelLength = fd->FindText.Length();
} else {
MsgBoxInfo( "End of document reached." );
RichEditReport->SelStart = 0;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuFindNextClick(TObject *Sender)
{
if( RichEditReport->Lines->Count == 0 )
{
MsgBoxStop( "Find what ?.");
return;
}
FindDialogFind( FindDialog );
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuPrintClick(TObject *Sender)
{
if( RichEditReport->Lines->Count == 0 )
{
MsgBoxStop( "I can't find anything to print !.");
return;
}
RichEditReport->Print( ExtractFileName( OpenDialog1->FileName ) );
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuPrintSetupClick(TObject *Sender)
{
PrinterSetupDialog->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::mnuSaveClick(TObject *Sender)
{
if( RichEditReport->Lines->Count == 0 )
{
MsgBoxStop( "I can't find anything to save !.");
return;
}
// Grab the graphic's filename and change to "txt" extension
{
char szFile[ MAXFILE ];
char szExt[ MAXEXT ];
char szDest[ MAXPATH ];
String as;
fnsplit( OpenDialog1->FileName.c_str(), NULL, NULL, szFile, szExt );
memset( szDest, 0, MAXPATH );
strcat( szDest, szFile );
strcat( szDest, "\." );
strcat( szDest, "txt" );
as = szDest;
// Initially create a text file of the same name as the graphic
// but with "txt" extension
SaveDialog1->FileName = as;
}
if( !SaveDialog1->Execute() )
return; // Given up hey ?
RichEditReport->Lines->SaveToFile( SaveDialog1->FileName );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMainForm::LoadFile( void )
{
int bStatus;
// Can we open the file ?
if( (fd = fopen( OpenDialog1->FileName.c_str(), "rb") ) == NULL )
{
MsgBoxStop( "Cannot open input file\n\n" + OpenDialog1->FileName );
return;
}
pnlChunks->Caption = "";
strList->Clear();
ListBoxChunks->Clear();
RichEditChunks->Clear();
RichEditReport->Clear();
ProgressBar1->Min = 0;
ProgressBar1->Position = 0;
SetChunkCount( 0 );
RichEditReport->Lines->Add( "" );
RichEditReport->Lines->Add( "Chunk contents of file :" );
RichEditReport->Lines->Add( OpenDialog1->FileName );
RichEditReport->Lines->Add( "" );
// Make report pane visible - prove we are working and not locked up
PageControl1->ActivePage = tsReport;
try {
StaticTextStatus->Caption = "Working ... please wait";
StaticTextStatus->Update();
bStatus = DumpTree(); // true indicates success
}
__finally {
ProgressBar1->Position = 0;
StaticTextStatus->Caption = "Ok";
fclose( fd );
fd = NULL;
}
if( !bStatus ) // We have an error
{
pnlChunks->Caption = "";
strList->Clear();
ListBoxChunks->Clear();
RichEditChunks->Clear();
RichEditReport->Lines->Add("");
RichEditReport->Lines->Add("An error occurred while reading the file.");
} else { // Read file and chunks without any problems
// Set Report Panels caption
pnlChunks->Caption = "Chunk 1 of " + String( ListBoxChunks->Items->Count );
// Set Listbox to first item
ListBoxChunks->ItemIndex = 0;
// Put gleeful message in report pane
RichEditChunks->Lines->Add( "" );
RichEditChunks->Lines->Add(
"No error's found when reading file ... " );
RichEditChunks->Lines->Add(
"Click the list box to display the data for each chunk.");
// Place cursor at top of editor
RichEditChunks->SelStart = 0;
RichEditChunks->SelLength = 0;
// Place cursor at top of editor
RichEditReport->SelStart = 0;
RichEditReport->SelLength = 0;
// Lock richedits - so an immediate undo does not make data vanish !
RichEditReport->Modified = false;
// @ap@ Borland should fix this ! (it don't work)
}
}
//---------------------------------------------------------------------------
bool __fastcall TMainForm::DumpTree( void )
{
mng_handle hMNG;
// let's initialize the library
hMNG = mng_initialize( (mng_ptr)this, Alloc, Free, NULL );
if( !hMNG ) // did that work out ?
{
MNGError( hMNG, "Cannot initialize libmng." );
mng_cleanup( &hMNG ); // Always cleanup the library
MsgBoxStop( "Bye!" );
Application->Terminate(); // Exit now
}
// setup callbacks
if( (mng_setcb_openstream ( hMNG, OpenStream ) != 0) ||
(mng_setcb_closestream ( hMNG, CloseStream ) != 0) ||
(mng_setcb_processheader( hMNG,ProcessHeader ) != 0) ||
(mng_setcb_readdata ( hMNG, FileReadData ) != 0)
)
{
MNGError( hMNG, "Cannot set callbacks for libmng.");
mng_cleanup( &hMNG ); // Always cleanup the library
MsgBoxStop( "Bye!" );
Application->Terminate(); // Exit now
}
else
{
// read the file into memory
if( mng_read( hMNG ) != 0 )
{
// Because we read the whole file in first,
// here is where bad input files first choke !
MNGError( hMNG, "Cannot read the file." );
mng_cleanup( &hMNG ); // Always cleanup the library
return false;
}
else
{
// run through the chunk list
if( mng_iterate_chunks( hMNG, 0, IterateChunks ) != 0 )
{
MNGError( hMNG, "Error Getting Chunk info!" );
mng_cleanup( &hMNG ); // Always cleanup the library
return false; // Errors may occur with bad chunk data
}
}
}
mng_cleanup( &hMNG ); // Always cleanup the library
return true;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::MNGError( mng_handle hMNG, String SHMsg )
{
// get extended info
mng_uint32 iErrorcode;
mng_uint8 iSeverity;
mng_chunkid iChunkname;
mng_uint32 iChunkseq;
mng_int32 iExtra1;
mng_int32 iExtra2;
mng_pchar zErrortext;
char szFormatStr[ 256 ];
iErrorcode = mng_getlasterror( hMNG, &iSeverity, &iChunkname,
&iChunkseq, &iExtra1, &iExtra2,
&zErrortext);
wsprintf( szFormatStr,
"Error = %d; Severity = %d; Chunknr = %d; Extra1 = %d",
(int)iErrorcode, (int)iSeverity, (int)iChunkseq, (int)iExtra1
);
MsgBoxStop( SHMsg + "\n\n" + String( zErrortext ) + "\n\n" + String( szFormatStr ) );
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ListBoxChunksClick(TObject *Sender)
{
// When the Chunks listbox is clicked ...
// display strings from strlist in the RichEditChunks window.
int iIndex = ListBoxChunks->ItemIndex;
if( !ListBoxChunks->Items->Count )
return;
// Update panel to reflect the selection : "Chunk N of NChunks"
pnlChunks->Caption = "Chunk " + String( iIndex + 1) +
" of " + String( ListBoxChunks->Items->Count );
// Reset Chunks windows ...
RichEditChunks->Clear();
RichEditChunks->Lines->Add( "" );
// ... Chunks header string : "Chunk N : XXXX" (XXXX == Chunk name)
RichEditChunks->Lines->Add( "Chunk " + String( iIndex + 1 ) + " : " +
ListBoxChunks->Items->Strings[ iIndex ] );
// ... Seperator line
//RichEditChunks->Lines->Add("");
// ... add the data from the stringlist
{
String as = strList->Strings[ iIndex ] + 1;
String z;
int n =1;
do{
if( as[n] == '\n' )
{
RichEditChunks->Lines->Add( z );
z = "";
}
else
z = z + as[n];
n+=1;
} while( n < as.Length() );
RichEditChunks->Lines->Add( z );
}
// ... Seperator line
RichEditChunks->Lines->Add("");
// Place cursor at top of editor
RichEditChunks->SelStart = 0;
RichEditChunks->SelLength = 0;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::EventShowPage(TObject *Sender)
{
switch( ((TTabSheet *)Sender)->Tag ) {
case PAGE_REPORT :
mnuPrint->Enabled = true;
mnuEdit->Enabled = true;
mnuUndo->Enabled = true;
mnuSave->Enabled = true;
sbtnSave->Enabled = true;
sbtnUndo->Enabled = true;
mnuCut->Enabled = true;
sbtnCut->Enabled = true;
mnuCopy->Enabled = true;
sbtnCopy->Enabled = true;
mnuPaste->Enabled = true;
sbtnPaste->Enabled = true;
mnuSearch->Enabled = true;
sbtnPrint->Enabled = true;
break;
//case PAGE_CHUNKS :
//case PAGE_OPTIONS :
///case PAGE_ABOUT :
//case PAGE_HELP :
default :
mnuPrint->Enabled = false;
mnuEdit->Enabled = false;
// no need to enable/disable menu commands as none will be available
mnuSave->Enabled = false;
sbtnSave->Enabled = false;
sbtnUndo->Enabled = false;
sbtnCut->Enabled = false;
sbtnCopy->Enabled = false;
sbtnPaste->Enabled = false;
mnuSearch->Enabled = false;
sbtnPrint->Enabled = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::RadioGroupTabSizeClick(TObject *Sender)
{
switch( RadioGroupTabSize->ItemIndex ) {
case 0 : asTab = " "; break;
case 1 : asTab = " "; break;
case 2 : asTab = " "; break;
case 3 : asTab = " "; break;
case 4 : asTab = " "; break;
case 5 : asTab = " "; break;
}
}
//---------------------------------------------------------------------------
String __fastcall TMainForm::PadInt( int iInt, int iWidth )
{
char szFmtStr[ 24 ];
char szInt[ 24 ]; // Should be wide enough !
String as;
wsprintf( szFmtStr,"%%%d\d\0",iWidth ); //"%[iWidth]d"
as = szFmtStr;
wsprintf( szInt, szFmtStr, iInt );
return String( szInt );
}
//---------------------------------------------------------------------------
mng_bool __fastcall TMainForm::ShowChunk(
mng_handle hMNG, mng_handle hChunk, mng_chunkid iChunktype )
{
String asDataText;
// Fill asDataText with string data including newline's ...
// this is added to string list for each chunk
// and also added to the tail end of "Report"
// NOTE :
// Return True to continue processing.
// If mng_getchunk_xxxx fails just return false to the
// caller "(bool) myiterchunk" which inturn will then return false
// to "(mng_retcode) mng_iterate_chunks(...)" which will then
// give us the correct error code.
// In other words DON'T check for errors in "(bool) myiterchunk" !
switch( iChunktype ) {
case MNG_UINT_BACK :
if( !Info_BACK( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_BASI :
if( !Info_BASI( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_CLIP :
if( !Info_CLIP( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_CLON :
if( !Info_CLON( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_DBYK : // untested @ap@
if( !Info_DBYK( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_DEFI :
if( !Info_DEFI( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_DHDR :
if( !Info_DHDR( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_DISC : // untested @ap@
if( !Info_DISC( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_DROP : // untested @ap@
if( !Info_DROP( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_ENDL :
if( !Info_ENDL( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_FRAM :
if( !Info_FRAM( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_IDAT :
if( !Info_IDAT( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_IEND :
if( !Info_IEND( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_IHDR :
if( !Info_IHDR( hMNG, hChunk, asDataText ) ) return false; break;
#define MNG_UINT_IJNG 0x494a4e47L // Function AWOL @ap@
#define MNG_UINT_IPNG 0x49504e47L // Function AWOL @ap@
case MNG_UINT_JDAT :
if( !Info_JDAT( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_JHDR :
if( !Info_JHDR( hMNG, hChunk, asDataText ) ) return false; break;
#define MNG_UINT_JSEP 0x4a534550L // Function AWOL @ap@
case MNG_UINT_LOOP :
if( !Info_LOOP( hMNG, hChunk, asDataText ) ) return false; break;
#define MNG_UINT_MaGN 0x4d61474eL // which one "mng_getchunk_magn" ?
case MNG_UINT_MEND :
if( !Info_MEND( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_MHDR :
if( !Info_MHDR( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_MOVE :
if( !Info_MOVE( hMNG, hChunk, asDataText ) ) return false; break;
#define MNG_UINT_MaGN 0x4d61474eL // which one "mng_getchunk_magn" ?
case MNG_UINT_ORDR :
if( !Info_ORDR( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_PAST :
if( !Info_PAST( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_PLTE :
if( !Info_PLTE( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_PPLT :
if( !Info_PPLT( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_PROM :
if( !Info_PROM( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_SAVE :
if( !Info_SAVE( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_SEEK :
if( !Info_SEEK( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_SHOW :
if( !Info_SHOW( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_TERM :
if( !Info_TERM( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_bKGD :
if( !Info_bKGD( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_cHRM :
if( !Info_cHRM( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_eXPI :
if( !Info_eXPI( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_fPRI :
if( !Info_fPRI( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_gAMA :
if( !Info_gAMA( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_hIST :
if( !Info_hIST( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_iCCP :
if( !Info_iCCP( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_iTXt : // untested @ap@
if( !Info_iTXt( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_nEED :
if( !Info_nEED( hMNG, hChunk, asDataText ) ) return false; break;
#define MNG_UINT_oFFs 0x6f464673L // Function AWOL @ap@
#define MNG_UINT_pCAL 0x7043414cL // Function AWOL @ap@
case MNG_UINT_pHYg : // untested @ap@
if( !Info_pHYg( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_pHYs :
if( !Info_pHYs( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_sBIT :
if( !Info_sBIT( hMNG, hChunk, asDataText ) ) return false; break;
#define MNG_UINT_sCAL 0x7343414cL // Function AWOL @ap@
case MNG_UINT_sPLT : // untested @ap@
if( !Info_sPLT( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_sRGB :
if( !Info_sRGB( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_tEXt :
if( !Info_tEXt( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_tIME :
if( !Info_tIME( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_tRNS :
if( !Info_tRNS( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_zTXt :
if( !Info_zTXt( hMNG, hChunk, asDataText ) ) return false; break;
case MNG_UINT_HUH :
default : // this will catch unknown chunks - Huh !
if( !Info_Unknown( hMNG, hChunk, asDataText ) ) return false; break;
} // end of switch
//-------------------------------------------------
// Add this chunk's string to our string list
strList->Insert( GetChunkCount(), asDataText );
// Now's the time to bump chunk count
IncChunkCount();
// Add this chunk's string to the Report
MainForm->RichEditReport->Lines->Add( asDataText );
return true;
}
//---------------------------------------------------------------------------

Binary file not shown.

View file

@ -0,0 +1,296 @@
//---------------------------------------------------------------------------
#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ComCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <stdio.h>
//---------------------------------------------------------------------------
// These MUST be defined before we include "Libmng.h
//# define MNG_SUPPORT_READ
//# define MNG_ACCESS_CHUNKS
//# define MNG_STORE_CHUNKS
//# define MNG_NO_CMS
# define MNG_USE_DLL
# define MNG_SKIP_ZLIB
# define MNG_SKIP_LCMS
# define MNG_SKIP_IJG6B
#include "../../../libmng.h"
//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published: // IDE-managed Components
TMainMenu *MainMenu1;
TMenuItem *mnuFile;
TMenuItem *mnuOpen;
TMenuItem *mnuReload;
TMenuItem *mnuSave;
TMenuItem *N1;
TMenuItem *mnuPrint;
TMenuItem *mnuPrintSetup;
TMenuItem *N2;
TMenuItem *mnuExit;
TMenuItem *mnuEdit;
TMenuItem *mnuUndo;
TMenuItem *N3;
TMenuItem *mnuCut;
TMenuItem *mnuCopy;
TMenuItem *mnuPaste;
TMenuItem *N4;
TMenuItem *mnuSelectAll;
TMenuItem *N5;
TMenuItem *mnuSetFont;
TMenuItem *mnuWordWrap;
TMenuItem *mnuSearch;
TMenuItem *mnuFind;
TMenuItem *mnuFindNext;
TPanel *Panel1;
TSpeedButton *sbtnOpen;
TSpeedButton *sbtnReload;
TSpeedButton *sbtnSave;
TSpeedButton *sbtnPrint;
TSpeedButton *sbtnPrintSetup;
TSpeedButton *sbtnUndo;
TSpeedButton *sbtnCut;
TSpeedButton *sbtnCopy;
TSpeedButton *sbtnPaste;
TOpenDialog *OpenDialog1;
TSaveDialog *SaveDialog1;
TPrintDialog *PrintDialog;
TPrinterSetupDialog *PrinterSetupDialog;
TFontDialog *FontDialog1;
TFindDialog *FindDialog;
TPageControl *PageControl1;
TTabSheet *tsChunks;
TTabSheet *tsReport;
TPanel *pnlChunks;
TListBox *ListBoxChunks;
TSpeedButton *sbtnCopyChunk;
TRichEdit *RichEditChunks;
TRichEdit *RichEditReport;
TPanel *PanelStatusBar;
TProgressBar *ProgressBar1;
TTabSheet *tsOptions;
TTabSheet *tsAbout;
TLabel *LabelAbout;
TTabSheet *tsHelp;
TLabel *LabelHelp;
TCheckBox *cbBool;
TCheckBox *cbMacroIdentifier;
TCheckBox *cbRawData;
TCheckBox *cbRGBOrder;
TCheckBox *cbPaletteEntries;
TCheckBox *cbComments;
TRadioGroup *RadioGroupTabSize;
TStaticText *StaticTextStatus;
TStaticText *StaticText1;
void __fastcall mnuFileOpenClick(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall ListBoxChunksClick(TObject *Sender);
void __fastcall mnuReloadClick(TObject *Sender);
void __fastcall mnuExitClick(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall mnuUndoClick(TObject *Sender);
void __fastcall mnuCutClick(TObject *Sender);
void __fastcall mnuCopyClick(TObject *Sender);
void __fastcall mnuPasteClick(TObject *Sender);
void __fastcall mnuSelectAllClick(TObject *Sender);
void __fastcall mnuWordWrapClick(TObject *Sender);
void __fastcall mnuSetFontClick(TObject *Sender);
void __fastcall FontDialog1Apply(TObject *Sender, HWND Wnd);
void __fastcall mnuFindClick(TObject *Sender);
void __fastcall FindDialogFind(TObject *Sender);
void __fastcall mnuFindNextClick(TObject *Sender);
void __fastcall sbtnCopyChunkClick(TObject *Sender);
void __fastcall mnuPrintClick(TObject *Sender);
void __fastcall mnuPrintSetupClick(TObject *Sender);
void __fastcall mnuSaveClick(TObject *Sender);
void __fastcall EventShowPage(TObject *Sender);
void __fastcall RadioGroupTabSizeClick(TObject *Sender);
protected :
void virtual __fastcall OnMinMax(TMessage& Msg);
BEGIN_MESSAGE_MAP // to limit minimum form size for about/help panes
MESSAGE_HANDLER( WM_GETMINMAXINFO, TMessage, OnMinMax )
END_MESSAGE_MAP(TForm)
private: // User declarations
FILE *fd;
int iChunkCount; // To link stringList to listbox
String asTab; // Number of spaces to use as tab stop
public: // User declarations
// Constructor
__fastcall TMainForm(TComponent* Owner);
// Destructor
__fastcall ~TMainForm( void );
// ------------------------------------------------------------------
// Callbacks ... as static member functions
// ------------------------------------------------------------------
static mng_ptr __stdcall Alloc( mng_size_t iSize );
static void __stdcall Free( mng_ptr pPtr, mng_size_t iSize );
static mng_bool __stdcall FileReadData( mng_handle hMNG,
mng_ptr pBuf,
mng_uint32 iSize,
mng_uint32 *iRead );
static mng_bool __stdcall ProcessHeader( mng_handle hHandle,
mng_uint32 iWidth,
mng_uint32 iHeight );
static mng_bool __stdcall OpenStream( mng_handle hMNG );
static mng_bool __stdcall CloseStream( mng_handle hMNG );
static mng_bool __stdcall IterateChunks( mng_handle hMNG,
mng_handle hChunk,
mng_chunkid iChunktype,
mng_uint32 iChunkseq );
// ------------------------------------------------------------------
//public data members
// ------------------------------------------------------------------
// Associates a string, strList[n], with a chunk in the listbox[N]
TStringList *strList;
String asAppName; // pinch Application->Title at startup
// ------------------------------------------------------------------
// MessageBox functions
// ------------------------------------------------------------------
int __fastcall MessageBox( String &as, UINT flags );
void __fastcall MsgBoxOk( String as );
int __fastcall MsgBoxYN( String as );
int __fastcall MsgBoxYNC( String as );
void __fastcall MsgBoxStop( String as );
void __fastcall MsgBoxInfo( String as );
void __fastcall MsgBoxWarn( String as );
// ------------------------------------------------------------------
// Just to isolate teh "FILE *fd" variable from possible change.
inline FILE* __fastcall GetFd( void )
{ return fd; };
// ------------------------------------------------------------------
// Options
// ------------------------------------------------------------------
inline bool _fastcall WantsComments( void )
{ return cbComments->Checked; };
inline bool _fastcall WantsPaletteEntries( void )
{ return cbPaletteEntries->Checked; };
inline bool _fastcall WantsRgbOrder( void )
{ return cbRGBOrder->Checked; };
inline bool _fastcall WantsRawData( void )
{ return cbRawData->Checked; };
inline bool _fastcall WantsMacroIds( void )
{ return cbMacroIdentifier->Checked; };
inline bool _fastcall WantsBool( void )
{ return cbBool->Checked; };
// ------------------------------------------------------------------
// Chunk count stuff
// ------------------------------------------------------------------
inline int __fastcall IncChunkCount( void )
{ return iChunkCount += 1; };
inline int __fastcall SetChunkCount( int anInt )
{ iChunkCount = anInt; };
inline int __fastcall GetChunkCount( void )
{ return iChunkCount; };
// ------------------------------------------------------------------
// Open a file, initialise things, and then calls "Dumptree(...)"
void __fastcall LoadFile( void );
// All LibMng calls involving the library handle are made from here :
// Initialize the library
// Setup callbacks
// Read the file into memory
// Run through the chunk list (mng_iterate_chunks)
// Cleanup the library
// Show Report page, all done. (then explode into the starry heavens!)
bool __fastcall DumpTree( void );
// Handle library errors gracefully.
void __fastcall MNGError( mng_handle hMNG, String SHMsg );
// Uesd with Palette entries - to right align int's to N chars width
String __fastcall PadInt( int iInt, int iWidth = 3 ); // default = 3
// A long switch that calls Info_XXXX's to assemble the chunks string
mng_bool __fastcall ShowChunk( mng_handle hMNG,
mng_handle hChunk,
mng_chunkid iChunktype );
// ------------------------------------------------------------------
// The following functions are to assemble a string for each chunk.
// The function name "Info_????" denotes which chunk it handles
// Definitions can be found in "Chunks.cpp"
// ------------------------------------------------------------------
bool __fastcall Info_BACK( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_BASI( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_CLIP( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_CLON( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_DBYK( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_DEFI( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_DHDR( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_DISC( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_DROP( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_ENDL( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_FRAM( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_IDAT( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_IEND( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_IHDR( mng_handle hMNG, mng_handle hChunk, String &as );
// MNG_UINT_IJNG - Function missing @ap@
// MNG_UINT_IPNG - Function missing @ap@
bool __fastcall Info_JDAT( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_JHDR( mng_handle hMNG, mng_handle hChunk, String &as );
// MNG_UINT_JSEP - Function missing @ap@
bool __fastcall Info_LOOP( mng_handle hMNG, mng_handle hChunk, String &as );
// MAGN ? MNG_UINT_MAGN @ap@
bool __fastcall Info_MEND( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_MHDR( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_MOVE( mng_handle hMNG, mng_handle hChunk, String &as );
// MaGN ? MNG_UINT_MaGN @ap@
bool __fastcall Info_ORDR( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_PAST( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_PLTE( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_PPLT( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_PROM( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_SAVE( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_SEEK( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_SHOW( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_TERM( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_bKGD( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_cHRM( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_eXPI( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_fPRI( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_gAMA( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_hIST( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_iCCP( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_iTXt( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_nEED( mng_handle hMNG, mng_handle hChunk, String &as );
// MNG_UINT_oFFs - Function missing @ap@
// MNG_UINT_pCAL - Function missing @ap@
bool __fastcall Info_pHYg( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_pHYs( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_sBIT( mng_handle hMNG, mng_handle hChunk, String &as );
// MNG_UINT_sCAL - Function missing @ap@
bool __fastcall Info_sPLT( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_sRGB( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_tEXt( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_tIME( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_tRNS( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_zTXt( mng_handle hMNG, mng_handle hChunk, String &as );
bool __fastcall Info_Unknown( mng_handle hMNG, mng_handle hChunk, String &as );
};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif