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

Saving and loading different picture formats. More...

#include <string.h>
#include <png.h>
#include <stdlib.h>
#include <endian.h>
#include "gfx2log.h"
#include "errors.h"
#include "global.h"
#include "loadsave.h"
#include "loadsavefuncs.h"
#include "struct.h"
#include "io.h"
#include "pages.h"
#include "windows.h"
#include "unicode.h"
#include "fileformats.h"
#include "oldies.h"
#include "bitcount.h"
+ Include dependency graph for fileformats.c:

Data Structures

struct  T_INFO_Header
 
struct  T_INFO_ImageHeader
 
struct  T_BMP_Header
 BMP file header. More...
 
struct  T_ICO_ImageEntry
 
struct  T_PCX_Header
 
struct  T_SCx_Header
 SCx header data. More...
 

Macros

#define MIN(a, b)   ((a)<(b)?(a):(b))
 
#define LOAD_BMP_PIXEL_FLAG_TOP_DOWN   0x01
 rows are stored from the top to the bottom (standard for BMP is from bottom to the top) More...
 
#define LOAD_BMP_PIXEL_FLAG_TRANSP_PLANE   0x02
 We are decoding the AND-mask plane (transparency) of a .ICO file. More...
 
#define XPM_USABLE_CHARS   (0x7f - 0x20 - 2)
 

Functions

void Draw_IFF_line (T_IO_Context *context, const byte *buffer, short y_pos, short real_line_size, byte bitplanes)
 Planar to chunky conversion of a line. More...
 
void Test_IMG (T_IO_Context *context, FILE *file)
 
void Load_IMG (T_IO_Context *context)
 
void Save_IMG (T_IO_Context *context)
 
static int Read_INFO_Header (FILE *file, T_INFO_Header *header)
 
static int Read_INFO_ImageHeader (FILE *file, T_INFO_ImageHeader *header)
 
void Test_INFO (T_IO_Context *context, FILE *file)
 
static char * Read_INFO_String (FILE *file)
 
static byteDecode_NewIcons (const byte *p, int bits, unsigned int *len)
 
void Load_INFO (T_IO_Context *context)
 
void Test_BMP (T_IO_Context *context, FILE *file)
 Test for BMP format. More...
 
static byte Bitmap_mask (dword pixel, dword mask, int bits, int shift)
 extract component value and properly shift it. More...
 
static void Load_BMP_Palette (T_IO_Context *context, FILE *file, unsigned int nb_colors, int is_rgb24)
 Load the Palette for 1 to 8bpp BMP's. More...
 
static void Load_BMP_Pixels (T_IO_Context *context, FILE *file, unsigned int compression, unsigned int nbbits, int flags, const dword *mask)
 
void Load_BMP (T_IO_Context *context)
 Load BMP file. More...
 
void Save_BMP (T_IO_Context *context)
 Save BMP file. More...
 
void Test_ICO (T_IO_Context *context, FILE *file)
 
void Load_ICO (T_IO_Context *context)
 
void Save_ICO (T_IO_Context *context)
 
void Test_PCX (T_IO_Context *context, FILE *file)
 
static void Draw_PCX_line (T_IO_Context *context, const byte *buffer, short y_pos, byte depth)
 
static void Set_CGA_Color (int i, T_Components *comp)
 
void Load_PCX (T_IO_Context *context)
 
void Save_PCX (T_IO_Context *context)
 
void Test_SCx (T_IO_Context *context, FILE *file)
 Test if a file is SCx format. More...
 
void Load_SCx (T_IO_Context *context)
 Read a SCx file. More...
 
void Save_SCx (T_IO_Context *context)
 Save a SCx file. More...
 
void Save_XPM (T_IO_Context *context)
 

Variables

T_PCX_Header PCX_header
 

Detailed Description

Saving and loading different picture formats.

Macro Definition Documentation

◆ MIN

#define MIN (   a,
 
)    ((a)<(b)?(a):(b))

◆ XPM_USABLE_CHARS

#define XPM_USABLE_CHARS   (0x7f - 0x20 - 2)

Function Documentation

◆ Read_INFO_Header()

◆ Read_INFO_ImageHeader()

◆ Read_INFO_String()

static char * Read_INFO_String ( FILE *  file)
static

References NULL, Read_bytes(), and Read_dword_be().

Referenced by Load_INFO().

◆ Decode_NewIcons()

static byte * Decode_NewIcons ( const byte p,
int  bits,
unsigned int *  len 
)
static

References GFX2_Log(), GFX2_WARNING, and NULL.

Referenced by Load_INFO().

◆ Draw_PCX_line()

static void Draw_PCX_line ( T_IO_Context context,
const byte buffer,
short  y_pos,
byte  depth 
)
static

References Set_pixel(), and T_IO_Context::Width.

Referenced by Load_PCX().

◆ Set_CGA_Color()

static void Set_CGA_Color ( int  i,
T_Components comp 
)
static

References T_Components::B, T_Components::G, and T_Components::R.

Referenced by Load_PCX().

Variable Documentation

◆ PCX_header

T_PCX_Header PCX_header

Referenced by Load_PCX(), Save_PCX(), and Test_PCX().