GrafX2 2.9.3227
The ultimate 256-color painting program
packbits.c File Reference

Packbits compression as used in IFF etc. More...

#include <stdio.h>
#include <string.h>
#include "struct.h"
#include "io.h"
#include "gfx2log.h"
#include "packbits.h"
+ Include dependency graph for packbits.c:

Functions

int PackBits_unpack_from_file (FILE *f, byte *dest, unsigned int count)
 
void PackBits_pack_init (T_PackBits_data *data, FILE *f)
 init before packing More...
 
int PackBits_pack_add (T_PackBits_data *data, byte b)
 Add a byte to the packbits stream. More...
 
int PackBits_pack_flush (T_PackBits_data *data)
 Flush the packed data to the file. More...
 
int PackBits_pack_buffer (FILE *f, const byte *buffer, size_t size)
 Pack a full buffer to FILE. More...
 

Detailed Description

Packbits compression as used in IFF etc.

see http://fileformats.archiveteam.org/wiki/PackBits

Function Documentation

◆ PackBits_unpack_from_file()

int PackBits_unpack_from_file ( FILE *  f,
byte dest,
unsigned int  count 
)
Returns
PACKBITS_UNPACK_OK or PACKBITS_UNPACK_READ_ERROR or PACKBITS_UNPACK_OVERFLOW_ERROR

References GFX2_Log(), GFX2_WARNING, PACKBITS_UNPACK_OK, PACKBITS_UNPACK_OVERFLOW_ERROR, and PACKBITS_UNPACK_READ_ERROR.

Referenced by Load_PC1(), and Test_Packbits().

◆ PackBits_pack_init()

void PackBits_pack_init ( T_PackBits_data data,
FILE *  f 
)

init before packing

Parameters
datastorage for packbits data
fFILE output or NULL (for no output)

References T_PackBits_data::f.

Referenced by PackBits_pack_buffer(), Save_IFF(), and Test_Packbits().

◆ PackBits_pack_add()

int PackBits_pack_add ( T_PackBits_data data,
byte  b 
)

Add a byte to the packbits stream.

Returns
-1 for error, 0 if OK

References T_PackBits_data::list, T_PackBits_data::list_size, PackBits_pack_flush(), and T_PackBits_data::repetition_mode.

Referenced by PackBits_pack_buffer(), Save_IFF(), and Test_Packbits().

◆ PackBits_pack_flush()

int PackBits_pack_flush ( T_PackBits_data data)

◆ PackBits_pack_buffer()

int PackBits_pack_buffer ( FILE *  f,
const byte buffer,
size_t  size 
)

Pack a full buffer to FILE.

Parameters
fFILE output or NULL (for no output)
bufferinput buffer
sizebyte size of input buffer
Returns
-1 for error, or the size of the packed stream so far

References PackBits_pack_add(), PackBits_pack_flush(), and PackBits_pack_init().

Referenced by Save_PC1(), and Save_PRG().