Chapter 21:
Load/Save File Functions
 

Clone_TIFFGraph(); Clone a TIFF Graph

 

F3DF_ReadDescription(); Read description string from TIFF file

 

F3DF_ReadThumbnail(); Read thumbnail from TIFF file

 

Load_TIFFGraph(); Load a TIFF graph

 

Load_TIFFGraphPath(); Load a TIFF graph path

 

Save_TIFFGraph(); Save TIFF Graph

 

Save_TIFFGraphPath(); Save TIFF Graph Path

 

Save_TIFFGraphPathTrim(); Save TIFF Graph Path with trim option

 

ThumbWIN_GetFileDescriptionFromGraph(); Get File Description from Graph

 

ThumbWIN_GetThumbnailFromGraph(); Get Thumbnail from Graph

 

ThumbWIN_LoadDescription(); Load description into graph

 

ThumbWIN_LoadThumbnail(); Load thumbnail into graph

 

ThumbWIN_SetFileDescriptionIntoGraph(); Set File Description into Graph

 

ThumbWIN_UpdateInGraph(); Update Thumbnail in Graph

Clone_TIFFGraph()

 

This function creates a duplicate of a GraphPtr using the TIFF-based loader/saver.

Syntax:

GraphPtr PUBLIC
Clone_TIFFGraph (
     GraphPtr pGraph
);

Input:

pGraph: Pointer to a graph object created by AllocGraphPtr()

Return:

GraphPtr: A valid GraphPtr upon success, otherwise NULL.

Example:

// New graph pointer
GraphPtr      pNewGraph;
// Do cloning
pNewGraph = Clone_TIFFGraph(pApp->m_gpGraph);
if (pNewGraph){
     // Free old pointer
     FreeGraphPtr(pApp->m_gpGraph);
     pApp->m_gpGraph = pNewGraph;

Also See:

Load_TIFFGraph(), Load_TIFFGraphPath(), Save_TIFFGraph(), Save_TIFFGraphPath()

   

F3DF_ReadDescription()

 

This function reads the description string from the specified TIFF file.

Syntax:

INT16 PUBLIC
F3DF_ReadDescription(
     TiffInputPtr pInput,
     char FAR * szDescription,
     INT16 nMaxBuf
);

Input:

pInput; Pointer to a TIFF-file input record. See TiffInputRec in Appendix A.

 

szDescription; Caller-supplied buffer

 

nMaxBuf; Maximum buffer size.

Return:

INT16; Standard Error Code.

Also See:

F3DF_ReadThumbnail(), ThumbWIN_GetFileDescriptionFromGraph(), ThumbWIN_GetThumbnailFromGraph(), ThumbWIN_LoadDescription(), ThumbWIN_LoadThumbnail(), ThumbWIN_SetFileDescriptionIntoGraph()

F3DF_ReadThumbnail()

 

This function creates a bitmap from the specified TIFF file. It assumes that the file header has already been read. This function returns the bitmap in a form convenient for the host program to manipulate. For the Mac, it is a PictHandle. For Windows, it is a HANDLE to a DIB.

Syntax:

INT16 PUBLIC
F3DF_ReadThumbnail(
     TiffInputPtr pInput,
     void FAR * pPixRef
);

Input:

pInput; Pointer to a TIFF-file input record. See TiffInputRec in Appendix A.

 

pPixRef; Place to store a PictHandle or DIB-Handle depending on the platform.

Return:

Standard Error Code.

Notes:

This function is PLATFORM-SPECIFIC since the format of a color bitmap image differs from system to system.

Also See:

F3DF_ReadDescription(), ThumbWIN_GetFileDescriptionFromGraph(), ThumbWIN_GetThumbnailFromGraph(), ThumbWIN_LoadDescription(), ThumbWIN_LoadThumbnail(), ThumbWIN_SetFileDescriptionIntoGraph()

   

Load_TIFFGraph()

 

This function loads a graph (pGraph) with the TIFF format image in pFileSpec.

Syntax:

INT16 PUBLIC
Load_TIFFGraph (
     GraphPtr pGraph,
     UINT32 ulRequest,
     #if defined(WIN32) || UNIX
          char * pszFileName
     #else
          FSSpec * pFileSpec
     #endif
);

Input:

pGraph: Pointer to a valid graph.

 

ulRequest: One of the following load requests codes:

 

#define

Value

Description

 

REQUEST_TIFFTHUMBNAIL

0X0100

TIFF Thumbnail

 

REQUEST_PICTURES

0x0400

Pictures stored in file

 

REQUEST_TDL

0x04DF

Look of the Graph only

 

REQUEST_TDT

0x045F

Full chart tag aggregation except CELL and DLOOK (Template)

 

REQUEST_TDC

0x04FF

Look of the Graph and Data

 

REQUEST_TDF

0x05FF

Look of the Graph, Data and TIFF Thumbnail

 

REQUEST_THUMBFILEDESCRIPTION

0x0600

Thumbnail File Description

 

pFileSpec: Name of the .TIFF file to be loaded.

Return:

INT16: An Error Code. See the error codes in Appendix B.

Example:

/* Free up any pages used in the saved graph */
FreeStoragePages(&SaveGraph.Storage);
#if DEBUGGING
PrintStruct_OpenOutputFile ("inputfile");
#endif
nError = Load_TIFFGraph ((GraphPtr) &LoadGraph,
          ulRequest, "DEFAULT.3TF");
#if DEBUGGING
PrintStruct_CloseFileExit();
#endif

Also See:

Clone_TIFFGraph(), Load_TIFFGraphPath(), Save_TIFFGraph()

Load_TIFFGraphPath()

 

This function loads a graph structure with the proper information. The file is already opened by the time this routine is called (i.e. pIOPathFile contains valid data).

Syntax:

INT16 PUBLIC
Load_TIFFGraphPath (
     IOPATHPTR pIOPathFile,
     GraphPtr pGraph,
     UINT32 ulRequest
);

Input:

pIOPathFile: Pointer to an IOPATH structure.

 

pGraph: Pointer to a valid graph.

 

ulRequest: One of the following load requests codes:

 

#define

Value

Description

 

REQUEST_TIFFTHUMBNAIL

0X0100

TIFF Thumbnail

 

REQUEST_PICTURES

0x0400

Pictures stored in file

 

REQUEST_TDL

0x04DF

Look of the Graph only

 

REQUEST_TDT

0x045F

Full chart tag aggregation except CELL and DLOOK (Template)

 

REQUEST_TDC

0x04FF

Look of the Graph and Data

 

REQUEST_TDF

0x05FF

Look of the Graph, Data and TIFF Thumbnail

 

REQUEST_THUMBFILEDESCRIPTION

0x0600

Thumbnail File Description

Return:

INT16: An Error Code

Example:

if (nError == E00_OK) {
/** Load the graph */
nError = Load_TIFFGraphPath (
     pIOPathFile, pGraph, ulRequest);
/* Close the file */
IOclose (pIOPathFile);
}

Notes:

Use this function in conjunction with IOopen and the RAMFILE functions to load a chart directly from a resource or from any arbitrary memory location. See SAMP7.C for an example.

Also See:

Clone_TIFFGraph(), Load_TIFFGraph(), Save_TIFFGraphPath()

Save_TIFFGraph()

 

This function saves a graph structure into a binary or ASCII file. This function assumes the graph structure has been ZEROED and pre-allocated

Syntax:

INT16 PUBLIC Save_TIFFGraph (
     GraphPtr pGraph,
     UINT32 ulRequest,
     INT16 nFileFmt,
     INT16 bTerminator,
     #if defined(WIN32) || UNIX
          char * pszFileName
     #else
          FSSpec * pFileSpec
     #endif
);

Input:

pGraph: Pointer to a pre-allocated zeroed Graph structure

 

ulRequest: One of the following load requests codes:

 

#define

Value

Description

 

REQUEST_TIFFTHUMBNAIL

0X0100

TIFF Thumbnail

 

REQUEST_PICTURES

0x0400

Pictures stored in file

 

REQUEST_TDL

0x04DF

Look of the Graph only

 

REQUEST_TDT

0x045F

Full chart tag aggregation except CELL and DLOOK (Template)

 

REQUEST_TDC

0x04FF

Look of the Graph and Data

 

REQUEST_TDF

0x05FF

Look of the Graph, Data and TIFF Thumbnail

 

REQUEST_THUMBFILEDESCRIPTION

0x0600

Thumbnail File Description

 

nFileFmt: File Format

 

#define

Value

Description

 

FILEFMT_BINARY

1

Binary File Format

 

FILEFMT_ASCII

2

ASCII File Format

 

Terminator: Whether to add terminators after each record

 

#define

Value

Description

 

TERMINATOR_NO

0

No terminators

 

TERMINATOR_YES

1

Add terminators

 

pszFileName or pFilespec: Name of the .TIFF file.

Return:

INT16: An Error Code defined in com_errs.h for files.

Notes:

For normal usage, set nFileFmt to FILEFMT_BINARY and terminator to TERMINATOR_NO.

Also See:

Load_TIFFGraph(), Save_TIFFGraphPath(), Save_TIFFGraphPathTrim()

Save_TIFFGraphPath()

 

This function saves a graph structure into a binary or ASCII file. The file is already opened when this routine is called (i.e. pIOPathFile contains valid data). This function assumes the Graph structure (at pGraph) has been ZEROED and pre-allocated.

Syntax:

INT16 PUBLIC
Save_TIFFGraphPath (
     IOPATHPTR pIOPathFile,
     GraphPtr pGraph,
     UINT32 ulRequest,
     INT16 nFileFmt,
     INT16 bTerminator
);

Input:

pGraph: Pointer to a pre-allocated zeroed Graph structure

 

ulRequest: One of the following load requests codes:

 

#define

Value

Description

 

REQUEST_TIFFTHUMBNAIL

0X0100

TIFF Thumbnail

 

REQUEST_PICTURES

0x0400

Pictures stored in file

 

REQUEST_TDL

0x04DF

Look of the Graph only

 

REQUEST_TDT

0x045F

Full chart tag aggregation except CELL and DLOOK (Template)

 

REQUEST_TDC

0x04FF

Look of the Graph and Data

 

REQUEST_TDF

0x05FF

Look of the Graph, Data and TIFF Thumbnail

 

REQUEST_THUMBFILEDESCRIPTION

0x0600

Thumbnail File Description

 

nFileFmt: File Format

 

#define

Value

Description

 

FILEFMT_BINARY

1

Binary File Format

 

FILEFMT_ASCII

2

ASCII File Format

 

Terminator: Whether to add terminators after each record

 

#define

Value

Description

 

TERMINATOR_NO

0

No terminators

 

TERMINATOR_YES

1

Add terminators

 

pszFileName or pFilespec: Name of the .TIFF file.

Return:

INT16: An Error Code defined in com_errs.h for files.

Notes:

For normal usage, set nFileFmt to FILEFMT_BINARY and terminator to TERMINATOR_NO.

Also See:

Load_TIFFGraph(), Save_TIFFGraph(), Save_TIFFGraphPathTrim()

Save_TIFFGraphPathTrim()

 

This function is the same as Save_TIFFGraphPath() except it provides an option (bWantTrim) to trim array elements that are greater than 64. It is useful for creating templates from charts of large datasets where the normal save might create an extremely large .3tf file on disk.

Syntax:

INT16 PUBLIC
Save_TIFFGraphPathTrim(
     IOPATHPTR pIOPathFile,
     GraphPtr pGraph,
     UINT32 ulRequest,
     INT16 nFileFmt,
     INT16 bTerminator,
     BOOLEAN16 bWantTrim
);

Input:

pGraph: Pointer to a pre-allocated zeroed Graph structure

 

ulRequest: One of the following load requests codes:

 

#define

Value

Description

 

REQUEST_TIFFTHUMBNAIL

0X0100

TIFF Thumbnail

 

REQUEST_PICTURES

0x0400

Pictures stored in file

 

REQUEST_TDL

0x04DF

Look of the Graph only

 

REQUEST_TDT

0x045F

Full chart tag aggregation except CELL and DLOOK (Template)

 

REQUEST_TDC

0x04FF

Look of the Graph and Data

 

REQUEST_TDF

0x05FF

Look of the Graph, Data and TIFF Thumbnail

 

REQUEST_THUMBFILEDESCRIPTION

0x0600

Thumbnail File Description

 

nFileFmt: File Format

 

#define

Value

Description

 

FILEFMT_BINARY

1

Binary File Format

 

FILEFMT_ASCII

2

ASCII File Format

 

Terminator: Whether to add terminators after each record

 

#define

Value

Description

 

TERMINATOR_NO

0

No terminators

 

TERMINATOR_YES

1

Add terminators

 

pszFileName or pFilespec: Name of the .TIFF file.

 

bWantTrim: TRUE = trim array elements that are > 64.

Return:

INT16: An Error Code as defined in com_errs.h for files.

Notes:

For normal usage, set nFileFmt to FILEFMT_BINARY and terminator to TERMINATOR_NO.

Also See:

Load_TIFFGraph(), Save_TIFFGraph(), Save_TIFFGraphPath()

ThumbWIN_GetFileDescriptionFromGraph()

 

This function stores the text description in the graph identified by pGraph at the location identified by pszDescription.

Syntax:

INT16 PUBLIC ThumbWIN_GetFileDescriptionFromGraph(
     GraphPtr pGraph, char * pszDescription
);

Input:

pGraph: Pointer to the graph object created by AllocGraphPtr()

 

pszDescription; Pointer to a character string where the text description in the graph can be stored.

Return:

INT16; See Appendix B for Standard System Error Codes.

 

Possible Values

Description

 

E00_OK =

Success

 

Any other value =

Standard System Error Code.

Notes:

This function is PLATFORM-SPECIFIC.

Also See:

F3DF_ReadDescription(), F3DF_ReadThumbnail(), ThumbWIN_GetThumbnailFromGraph(), ThumbWIN_LoadDescription(), ThumbWIN_LoadThumbnail(), ThumbWIN_SetFileDescriptionIntoGraph(), ThumbWIN_UpdateInGraph()

ThumbWIN_GetThumbnailFromGraph()

 

This function returns the thumbnail stored in the graph.

Syntax:

INT16 PUBLIC ThumbWIN_GetThumbnailFromGraph(
     GraphPtr pGraph, HANDLE * phThumbnail
);

Input:

pGraph: Pointer to the graph object created by AllocGraphPtr()

 

phThumbnail; Pointer to a location to store the thumbnail handle.

Return:

INT16; See Appendix B for Standard System Error Codes.

 

Possible Values

Description

 

E00_OK =

Success

 

Any other value =

Standard System Error Code

Notes:

This function is PLATFORM-SPECIFIC.

Also See:

F3DF_ReadDescription(), F3DF_ReadThumbnail(), ThumbWIN_GetFileDescriptionFromGraph(), ThumbWIN_LoadDescription(), ThumbWIN_LoadThumbnail(), ThumbWIN_SetFileDescriptionIntoGraph(), ThumbWIN_UpdateInGraph()

ThumbWIN_LoadDescription()

 

This function loads the file description.

Syntax:

INT16 PUBLIC
ThumbWIN_LoadDescription (
     char * pszFileName,
     char * pszDescription,
     size_t nSizeOfDescription
);

Input:

pszFileName; File Specification record Sys 7 type

 

pszDescription; Pointer to a location to store the description of file

 

nSizeOfDescription; Size of the description buffer

Return:

INT16; See Appendix B for Standard System Error Codes.

 

Possible Values

Description

 

E00_OK =

Success

 

Any other value =

Standard System Error Code

Notes:

This function is PLATFORM-SPECIFIC.

Also See:

F3DF_ReadDescription(), F3DF_ReadThumbnail(), ThumbWIN_GetFileDescriptionFromGraph(), ThumbWIN_GetThumbnailFromGraph(), ThumbWIN_LoadThumbnail(), ThumbWIN_SetFileDescriptionIntoGraph(), ThumbWIN_UpdateInGraph()

   

ThumbWIN_LoadThumbnail()

 

This function reads the thumb file from a TIFF or TDI type file and places it in a Picture handle.

Syntax:

INT16 PUBLIC
ThumbWIN_LoadThumbnail (
     char * pszFileName,
     void FAR * pvPixRef
);

Input:

pszFileName; Pointer to a "C" style string filename

 

pvPixRef;

Return:

INT16; See Appendix B for Standard System Error Codes.

 

Possible Values

Description

 

E00_OK =

Success

 

Any other value =

Standard System Error Code

Notes:

This function is PLATFORM-SPECIFIC.

Also See:

F3DF_ReadDescription(), F3DF_ReadThumbnail(), ThumbWIN_GetFileDescriptionFromGraph(), ThumbWIN_GetThumbnailFromGraph(), ThumbWIN_LoadDescription(), ThumbWIN_SetFileDescriptionIntoGraph(), ThumbWIN_UpdateInGraph()

   

ThumbWIN_SetFileDescriptionIntoGraph()

 

This function sets a file description in the Graph structure.

Syntax:

INT16 PUBLIC
ThumbWIN_SetFileDescriptionIntoGraph(
     GraphPtr pGraph,
     char * pszDescription
);

Input:

pGraph: Pointer to the graph object created by AllocGraphPtr()

 

pszDescription; Pointer to a character string where the text description is stored.

Return:

INT16; See Appendix B for Standard System Error Codes.

 

Possible Values

Description

 

E00_OK =

Success

 

Any other value =

Standard System Error Code

Notes:

This function is PLATFORM-SPECIFIC.

Also See:

F3DF_ReadDescription(), F3DF_ReadThumbnail(), ThumbWIN_GetFileDescriptionFromGraph(), ThumbWIN_GetThumbnailFromGraph(), ThumbWIN_LoadDescription(), ThumbWIN_LoadThumbnail(), ThumbWIN_UpdateInGraph()

   

ThumbWIN_UpdateInGraph()

 

This function updates the thumbnail in the graph.

 

INT16 PUBLIC
ThumbWIN_UpdateInGraph(
     GraphPtr pGraph,
     INT16 nThumbnailWidth,
     INT16 nThumbnailHeight
);

Input:

pGraph: Pointer pre-allocated zeroed Graph structure

 

nThumbnailWidth; Thumbnail width

 

nThumbnailHeight; Thumbnail height

Return:

INT16; See Appendix B for Standard System Error Codes.

 

Possible Values

Description

 

E00_OK =

Success

 

Any other value =

Standard System Error Code

Notes:

This function is PLATFORM-SPECIFIC.

Also See:

F3DF_ReadDescription(), F3DF_ReadThumbnail(), ThumbWIN_GetFileDescriptionFromGraph(), ThumbWIN_GetThumbnailFromGraph(), ThumbWIN_LoadDescription(), ThumbWIN_LoadThumbnail(), ThumbWIN_SetFileDescriptionIntoGraph()