home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
-
- #include <exec/execbase.h>
- #include <exec/memory.h>
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
- #include <cybergraphics/cybergraphics.h>
-
- #include <proof/proof.h>
- #include <proof/proof_protos.h>
- #include <proof/proof_pragmas.h>
-
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/cybergraphics_protos.h>
-
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/dos_pragmas.h>
- #include <pragmas/intuition_pragmas.h>
- #include <pragmas/cybergraphics_pragmas.h>
-
- /* Function prototypes */
- void ViewProof( struct Proof *pf );
-
- /* Global variables */
- extern struct Library *DOSBase;
- struct Library *IntuitionBase, *ProofBase, *CyberGfxBase;
-
- char *version = "$VER: ProofShow 1.1 (25.2.99)";
-
- void main( int argc, char **argv )
- {
- struct Proof *pf = NULL;
- ULONG err;
- char *iname;
-
- CyberGfxBase = OpenLibrary( "cybergraphics.library", NULL );
- IntuitionBase = OpenLibrary( "intuition.library", NULL );
- ProofBase = OpenLibrary( "proof.library", NULL );
- if ( IntuitionBase != NULL && ProofBase != NULL && CyberGfxBase != NULL )
- {
- if ( argc > 1 )
- {
- if ( IsProof( argv[1], TAG_DONE ) == FALSE )
- {
- printf( "File %s is not a proof file\n", FilePart( argv[1] ) );
- }
- else
- {
- err = LoadProof( argv[1], &pf, TAG_DONE );
- if ( err == PFERR_NONE )
- {
- char *str;
- UBYTE ub1, ub2;
- BOOL bo;
- WORD wo1, wo2;
- ULONG ul1, ul2;
-
- GetProofAttrs( pf, PFN_ProofPathName, &str, TAG_DONE );
- printf( "*ProofPathName=%s\n", str );
-
- printf( "ProofHeader:\n" );
- GetProofAttrs( pf, PFN_ProofVersion, &ub1, TAG_DONE );
- printf( " Version=%d\n", ub1 );
- GetProofAttrs( pf, PFN_ProofLinked, &bo, TAG_DONE );
- printf( " Linked=%s\n", bo ? "yes" : "no" );
- GetProofAttrs( pf, PFN_ProofWidth, &ub1, PFN_ProofHeight, &ub2, TAG_DONE );
- printf( " Dimensions=%d x %d\n", ub1, ub2 );
- GetProofAttrs( pf, PFN_ProofQuestionable, &bo, TAG_DONE );
- printf( " Questionable=%s\n", bo ? "yes" : "no" );
- GetProofAttrs( pf, PFN_ProofAspectX, &wo1, PFN_ProofAspectY, &wo2, TAG_DONE );
- printf( " Aspect=%d, %d\n", wo1, wo2 );
-
- if ( ValidProofDesc( pf ) )
- {
- printf( "ProofDescription:\n" );
- GetProofAttrs( pf, PFN_ImageWidth, &ul1, PFN_ImageHeight, &ul2, TAG_DONE );
- printf( " Dimensions=%d x %d\n", ul1, ul2 );
- GetProofAttrs( pf, PFN_ImageFileSize, &ul1, TAG_DONE );
- printf( " FileSize=%d\n", ul1 );
- GetProofAttrs( pf, PFN_ImageType, &ub1, TAG_DONE );
- printf( " ImageType=%d\n", ub1 );
- GetProofAttrs( pf, PFN_TextImageType, &str, TAG_DONE );
- printf( " TextImageType=%s\n", str );
-
- GetProofAttrs( pf, PFN_CategoryOwner, &ub1, TAG_DONE );
- printf( " CategoryOwner=%d\n", ub1 );
-
- GetProofAttrs( pf, PFN_ImageGroup, &ub1, TAG_DONE );
- printf( " ImageGroup=%d\n", ub1 );
-
- GetProofAttrs( pf, PFN_ImageCategory, &ul1, TAG_DONE );
- printf( " ImageCategory=%d\n", ul1 );
-
- GetProofAttrs( pf, PFN_ImageDepth, &ub1, TAG_DONE );
- printf( " Depth=%d\n", ub1 );
- GetProofAttrs( pf, PFN_ImageFormat, &ub1, TAG_DONE );
- printf( " Format=%d\n", ub1 );
- }
-
- err = GetProofAttrs( pf, PFN_ImageName, &iname, TAG_DONE );
- if ( err == PFERR_NONE )
- {
- printf( "Original image name: %s\n", iname );
- } else printf("Image name:%ld\n",err);
-
- err = GetProofAttrs( pf, PFN_ImagePath, &iname, TAG_DONE );
- if ( err == PFERR_NONE )
- {
- printf( "Original image path: %s\n", iname );
- } else printf("Image path:%ld\n",err);
-
- ViewProof( pf );
-
- FreeProof( &pf );
- }
- else printf( "Error=%ld\n", err );
- }
- }
- else printf( "Usage: ShowProof <filename>\n" );
- }
-
- if ( ProofBase != NULL ) CloseLibrary( ProofBase );
- if ( IntuitionBase != NULL ) CloseLibrary( IntuitionBase );
- if ( CyberGfxBase != NULL ) CloseLibrary( CyberGfxBase );
- }
-
- void ViewProof( struct Proof *pf )
- {
- ULONG DisplayID;
- struct Screen *scr;
- struct Window *win;
- struct Message *msg;
- UBYTE pw, ph;
-
- DisplayID = BestCModeIDTags( CYBRBIDTG_NominalWidth, 640,
- CYBRBIDTG_NominalHeight, 480,
- CYBRBIDTG_Depth, 24,
- TAG_DONE );
-
- if ( DisplayID != INVALID_ID )
- {
- scr = OpenScreenTags( NULL,
- SA_Title, "Proof",
- SA_DisplayID, DisplayID,
- SA_Depth, GetCyberIDAttr( CYBRIDATTR_DEPTH, DisplayID ),
- TAG_DONE );
-
- GetProofAttrs( pf, PFN_ProofWidth, &pw, PFN_ProofHeight, &ph, TAG_DONE );
-
- if ( scr != NULL )
- {
- win = OpenWindowTags( NULL,
- WA_Title, "Proof",
- WA_Flags,WFLG_ACTIVATE|WFLG_SIMPLE_REFRESH|
- WFLG_SIZEGADGET|WFLG_RMBTRAP|WFLG_DRAGBAR|
- WFLG_DEPTHGADGET|WFLG_CLOSEGADGET,
- WA_IDCMP,
- IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|
- IDCMP_SIZEVERIFY|IDCMP_NEWSIZE|IDCMP_RAWKEY,
- WA_Left, 16,
- WA_Top, scr->BarHeight+16,
- WA_Width, pw,
- WA_Height, ph,
- WA_CustomScreen, scr,
- TAG_DONE );
- if ( win != NULL )
- {
- UBYTE *rgb;
-
- rgb = AllocVec( pw * ph * 3, MEMF_PUBLIC | MEMF_CLEAR );
- if ( rgb != NULL )
- {
- if ( ConvertFromProof( pf, PFN_RGBTripletBuffer, rgb, TAG_DONE ) == PFERR_NONE )
- {
- WritePixelArray( rgb, 0, 0, pw * 3, win->RPort, 0, 0, pw, ph, RECTFMT_RGB );
-
- Wait( 1L << win->UserPort->mp_SigBit );
- while ( ( msg = GetMsg( win->UserPort ) ) != NULL ) ReplyMsg( msg );
- }
-
- FreeVec( rgb );
- }
-
- CloseWindow( win );
- }
-
- CloseScreen( scr );
- }
- }
- }
-