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

Packbytes compression as used in Apple Preferred Format. More...

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

Functions

void PackBytes_pack_init (T_PackBytes_data *data, FILE *f)
 init before packing More...
 
int PackBytes_pack_add (T_PackBytes_data *data, byte b)
 Add a byte to the packbits stream. More...
 
int PackBytes_pack_flush (T_PackBytes_data *data)
 Flush the packed data to the file. More...
 
int PackBytes_pack_buffer (FILE *f, const byte *buffer, size_t size)
 Pack a full buffer to FILE. More...
 

Detailed Description

Packbytes compression as used in Apple Preferred Format.

Function Documentation

◆ PackBytes_pack_init()

void PackBytes_pack_init ( T_PackBytes_data data,
FILE *  f 
)

init before packing

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

References T_PackBytes_data::f.

Referenced by PackBytes_pack_buffer(), and Save_2GS().

◆ PackBytes_pack_add()

int PackBytes_pack_add ( T_PackBytes_data data,
byte  b 
)

Add a byte to the packbits stream.

Returns
-1 for error, 0 if OK

References T_PackBytes_data::list, T_PackBytes_data::list_size, PackBytes_pack_flush(), and T_PackBytes_data::repetition_mode.

Referenced by PackBytes_pack_buffer(), and Save_2GS().

◆ PackBytes_pack_flush()

int PackBytes_pack_flush ( T_PackBytes_data data)

Flush the packed data to the file.

Returns
-1 for error, or the size of the packed stream so far

References T_PackBytes_data::f, GFX2_ERROR, GFX2_Log(), T_PackBytes_data::list, T_PackBytes_data::list_size, NULL, T_PackBytes_data::output_count, T_PackBytes_data::repetition_mode, Write_byte(), and Write_bytes().

Referenced by PackBytes_pack_add(), PackBytes_pack_buffer(), and Save_2GS().

◆ PackBytes_pack_buffer()

int PackBytes_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 PackBytes_pack_add(), PackBytes_pack_flush(), and PackBytes_pack_init().