FileError File::write( FileHandle fh, const void* buffer, size_t inSize ) { if( !Is_Open( fh ) || !Write_Bytes( fh, buffer, inSize ) ) return FILE_WRITE_FAIL; else return FILE_SUCCESS; }
void Store_Opacity(char filename []) { char local_filename[FILENAME_STRING_SIZE]; int fd; strcpy(local_filename,filename); strcat(local_filename,".opc"); fd = Create_File(local_filename); opc_version = OPC_CUR_VERSION; strcpy(local_filename,filename); strcat(local_filename,".opc"); fd = Create_File(local_filename); Write_Shorts(fd,(unsigned char *)&opc_version,(long)sizeof(opc_version)); Write_Shorts(fd,(unsigned char *)opc_len,(long)sizeof(opc_len)); Write_Longs(fd,(unsigned char *)&opc_length,(long)sizeof(opc_length)); printf(" Storing opacity map into .opc file...\n"); Write_Bytes(fd,(unsigned char *)opc_address,(long)(opc_length*sizeof(OPACITY))); Close_File(fd); }
void Store_Image(char filename[]) { char local_filename[FILENAME_STRING_SIZE]; long fd; short pix_version; short local_image_len[NI+1]; /* dimension larger than NI for backwards */ /* compatibility of .pix file with no color */ local_image_len[X] = image_len[X]; local_image_len[Y] = image_len[Y]; local_image_len[2] = 1; pix_version = PIX_CUR_VERSION; strcpy(local_filename,filename); strcat(local_filename,".pix"); fd = Create_File(local_filename); Write_Shorts(fd,(unsigned char *)&pix_version,(long)sizeof(pix_version)); Write_Shorts(fd,(unsigned char *)local_image_len,(long)sizeof(local_image_len)); Write_Longs(fd,(unsigned char *)&image_length,(long)sizeof(image_length)); Write_Bytes(fd,image_address,(long)(image_length*sizeof(PIXEL))); Close_File(fd); }