The input and output of PGM and CSV files. More...
Functions | |
NTTW_DLL_SYM int | openFile_Read (const char *filename, FILE **inFilePtr, int binary) |
Opens the file for read mode. | |
NTTW_DLL_SYM int | openFile_Write (const char *filename, FILE **inFilePtr, int binary) |
Opens the file for write mode. | |
NTTW_DLL_SYM int | openFile_Append (const char *filename, FILE **inFilePtr, int binary) |
Opens the file for append mode. | |
NTTW_DLL_SYM int | readCSV (nttw_integer **data, const int rows, const int cols, const char *filename) |
Reads a Comma Separated Value (CSV) file. Memory is internally allocated to the correct size. | |
NTTW_DLL_SYM int | readPGMHeader (FILE *inFile, char *type, int *rows, int *cols, int *maxGrey) |
Reads the parameters in the header of a PGM file. | |
NTTW_DLL_SYM int | readPGM (nttw_integer **data, int *rows, int *cols, const char *filename, int binary) |
Reads in an image which has a PGM format of name given. | |
NTTW_DLL_SYM int | readSignedPGM (long **data, int *rows, int *cols, const char *filename, int binary) |
Inputs data as a PGM file with signed values. | |
NTTW_DLL_SYM int | readUCharPGM (unsigned char **data, int *rows, int *cols, const char *filename, int binary) |
Inputs data as a PGM file with signed values. | |
NTTW_DLL_SYM int | writePGM (nttw_integer *data, const int rows, const int cols, const int greyMax, const char *filename, int binary) |
Outputs data as a PGM file. | |
NTTW_DLL_SYM int | writeSignedPGM (long *data, const int rows, const int cols, const int greyMax, const char *filename, int binary) |
Outputs data as a PGM file with signed values. | |
NTTW_DLL_SYM int | writeUCharPGM (unsigned char *data, const int rows, const int cols, const char *filename, int binary) |
Outputs data as a PGM file with unsigned character values. |
The input and output of PGM and CSV files.
Read a PGM file by using readPGM() and write using writePGM(). CSV files can be read using readCSV(). All functions read and write 32-bit integers.
openFile_Append | ( | const char * | filename, | |
FILE ** | inFilePtr, | |||
int | binary | |||
) |
openFile_Read | ( | const char * | filename, | |
FILE ** | inFilePtr, | |||
int | binary | |||
) |
openFile_Write | ( | const char * | filename, | |
FILE ** | inFilePtr, | |||
int | binary | |||
) |
readCSV | ( | nttw_integer ** | data, | |
const int | rows, | |||
const int | cols, | |||
const char * | filename | |||
) |
readPGM | ( | nttw_integer ** | data, | |
int * | rows, | |||
int * | cols, | |||
const char * | filename, | |||
int | binary | |||
) |
Reads in an image which has a PGM format of name given.
Takes a reference to a 1D pointer, and reads the file as a 2D array into the 1D array.
Memory is handled internally, no prior allocation is required.
data | - This is an array passed by reference, or &(image) where "image" is a 1D array declared with array_1D(). | |
rows | - number of rows that the file has. Passed by reference. Prior knowledge of file size is not required. This will contain the number of rows in file. | |
cols | - number of columns that the file has. Passed by reference. Prior knowledge of file size is not required. This will contain the number of columns in file. | |
filename | - The name of the PGM to be opened. | |
binary | - Boolean for reading binary file. |
Allocate Memory for Image appropriately
Read Data according to size and type provided in header
Close File
readPGMHeader | ( | FILE * | inFile, | |
char * | type, | |||
int * | rows, | |||
int * | cols, | |||
int * | maxGrey | |||
) |
Reads the parameters in the header of a PGM file.
Read PGM Header Read Filetype and File comment
See if Comment not present
If so, Start again and dont read comment
Read Filetype
Else read comments until none left
Read Image Characteristics
Allocate Memory for Image appropriately
readSignedPGM | ( | long ** | data, | |
int * | rows, | |||
int * | cols, | |||
const char * | filename, | |||
int | binary | |||
) |
readUCharPGM | ( | unsigned char ** | data, | |
int * | rows, | |||
int * | cols, | |||
const char * | filename, | |||
int | binary | |||
) |
writePGM | ( | nttw_integer * | data, | |
const int | rows, | |||
const int | cols, | |||
const int | greyMax, | |||
const char * | filename, | |||
int | binary | |||
) |
writeSignedPGM | ( | long * | data, | |
const int | rows, | |||
const int | cols, | |||
const int | greyMax, | |||
const char * | filename, | |||
int | binary | |||
) |