aboutsummaryrefslogtreecommitdiff
path: root/plugin-img.h
blob: 8523a79e0a61b37473d3cf72b07d5090453bc42a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef __IMG_H__
#  define __IMG_H__

#  include <libgimp/gimp.h>
#  include <libgimp/gimpui.h>
#  include <errno.h>
#  include <string.h>
#  include <glib/gstdio.h>

#  define LOAD_PROC        "file-img-load"
#  define SAVE_PROC        "file-img-save"
#  define PLUG_IN_BINARY   "file-img"

/* Comment out to disable debug */
#  define DEBUG

#  ifdef DEBUG
#    define __DEBUG(x) {x}
#    define D(x) \
{ \
  printf("IMG plugin: "); \
  printf x; \
}
#  else
#    define __DEBUG(x)
#    define D(x)
#  endif

/* FIXME: MIME type for these files */
#  define IMG_MIME        "image/x-img"

#  define FMT_RGB565 0
#  define FMT_RGB 1
#  define FMT_RGBA 2

extern const gchar *FMT[3];

/* File structure:
 * |------------------------|
 * | File header            |
 * |------------------------|
 * | [Color key for RGB]    |
 * |------------------------|
 * | Image data             |
 * |- - - - - - - - - - - - |
 *
 * */

/* ACHTUNG: byte order in the file is LITTLE-ENDIAN - lowest byte comes first */
typedef struct _FileHeader
{
    guint8 fmt;                 /* 0 - RGB565, 1 - RGB, 2 - RGBA) */

    /*
     * ACHTUNG: do not align, or else sizeof(ftm)==4:  __attribute__ ((packed))
     */
    guint32 nrows __attribute__ ((packed));     /* Number of rows of frames */
    guint32 ncols __attribute__ ((packed));     /* Number of columns of frames */

    guint32 width __attribute__ ((packed));     /* Image width (total) */
    guint32 height __attribute__ ((packed));    /* Image height (total) */

} FileHeader;

typedef struct _ColorKey
{
    guint8 is;                  /* 0 - no color key, otherwise is one */
    guint8 R __attribute__ ((packed));
    guint8 G __attribute__ ((packed));
    guint8 B __attribute__ ((packed));

} ColorKey;

/* Save params for GIMP_RUN_WITH_LAST_VALS
 * for each image LOADED image or for plugin defaults *
 * */

#  define PARASITE_ORIG_FILE "orig-file-info"
typedef struct _ImageParasite
{
    guint32 format;
    ColorKey ckey;
} ImageParasite;

#endif