~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/core/gimpbrush-load.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <errno.h>
 
22
#include <fcntl.h>
 
23
#include <stdlib.h>
 
24
#include <string.h>
 
25
#include <sys/types.h>
 
26
#include <sys/stat.h>
 
27
 
 
28
#ifdef HAVE_UNISTD_H
 
29
#include <unistd.h>
 
30
#endif
 
31
 
 
32
#ifndef _O_BINARY
 
33
#define _O_BINARY 0
 
34
#endif
 
35
 
 
36
#include <glib-object.h>
 
37
#include <glib/gstdio.h>
 
38
 
 
39
#include "libgimpbase/gimpbase.h"
 
40
 
 
41
#ifdef G_OS_WIN32
 
42
#include "libgimpbase/gimpwin32-io.h"
 
43
#endif
 
44
 
 
45
#include "core-types.h"
 
46
 
 
47
#include "base/temp-buf.h"
 
48
 
 
49
#include "gimpbrush.h"
 
50
#include "gimpbrush-header.h"
 
51
#include "gimpbrush-load.h"
 
52
 
 
53
#include "gimp-intl.h"
 
54
 
 
55
 
 
56
/* stuff from abr2gbr Copyright (C) 2001 Marco Lamberto <lm@sunnyspot.org>  */
 
57
/* the above is gpl  see http://the.sunnyspot.org/gimp/  */
 
58
 
 
59
typedef struct _AbrHeader               AbrHeader;
 
60
typedef struct _AbrBrushHeader          AbrBrushHeader;
 
61
typedef struct _AbrSampledBrushHeader   AbrSampledBrushHeader;
 
62
 
 
63
struct _AbrHeader
 
64
{
 
65
  gint16 version;
 
66
  gint16 count;
 
67
};
 
68
 
 
69
struct _AbrBrushHeader
 
70
{
 
71
  gint16 type;
 
72
  gint32 size;
 
73
};
 
74
 
 
75
struct _AbrSampledBrushHeader
 
76
{
 
77
  gint32   misc;
 
78
  gint16   spacing;
 
79
  gchar    antialiasing;
 
80
  gint16   bounds[4];
 
81
  gint32   bounds_long[4];
 
82
  gint16   depth;
 
83
  gboolean wide;
 
84
};
 
85
 
 
86
 
 
87
/*  local function prototypes  */
 
88
 
 
89
static GimpBrush * gimp_brush_load_abr_brush (FILE         *file,
 
90
                                              gint          index,
 
91
                                              const gchar  *filename,
 
92
                                              GError      **error);
 
93
static gchar       abr_read_char             (FILE         *file);
 
94
static gint16      abr_read_short            (FILE         *file);
 
95
static gint32      abr_read_long             (FILE         *file);
 
96
 
 
97
 
 
98
/*  public functions  */
 
99
 
 
100
GList *
 
101
gimp_brush_load (const gchar  *filename,
 
102
                 GError      **error)
 
103
{
 
104
  GimpBrush *brush;
 
105
  gint       fd;
 
106
 
 
107
  g_return_val_if_fail (filename != NULL, NULL);
 
108
  g_return_val_if_fail (g_path_is_absolute (filename), NULL);
 
109
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
110
 
 
111
  fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
 
112
  if (fd == -1)
 
113
    {
 
114
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
 
115
                   _("Could not open '%s' for reading: %s"),
 
116
                   gimp_filename_to_utf8 (filename), g_strerror (errno));
 
117
      return NULL;
 
118
    }
 
119
 
 
120
  brush = gimp_brush_load_brush (fd, filename, error);
 
121
 
 
122
  close (fd);
 
123
 
 
124
  if (! brush)
 
125
    return NULL;
 
126
 
 
127
  return g_list_prepend (NULL, brush);
 
128
}
 
129
 
 
130
GimpBrush *
 
131
gimp_brush_load_brush (gint          fd,
 
132
                       const gchar  *filename,
 
133
                       GError      **error)
 
134
{
 
135
  GimpBrush   *brush;
 
136
  gint         bn_size;
 
137
  BrushHeader  header;
 
138
  gchar       *name = NULL;
 
139
  guchar      *pixmap;
 
140
  guchar      *mask;
 
141
  gssize       i, size;
 
142
  gboolean     success = TRUE;
 
143
 
 
144
  g_return_val_if_fail (filename != NULL, NULL);
 
145
  g_return_val_if_fail (fd != -1, NULL);
 
146
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
147
 
 
148
  /*  Read in the header size  */
 
149
  if (read (fd, &header, sizeof (header)) != sizeof (header))
 
150
    {
 
151
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
152
                   _("Could not read %d bytes from '%s': %s"),
 
153
                   (gint) sizeof (header),
 
154
                   gimp_filename_to_utf8 (filename), g_strerror (errno));
 
155
      return NULL;
 
156
    }
 
157
 
 
158
  /*  rearrange the bytes in each unsigned int  */
 
159
  header.header_size  = g_ntohl (header.header_size);
 
160
  header.version      = g_ntohl (header.version);
 
161
  header.width        = g_ntohl (header.width);
 
162
  header.height       = g_ntohl (header.height);
 
163
  header.bytes        = g_ntohl (header.bytes);
 
164
  header.magic_number = g_ntohl (header.magic_number);
 
165
  header.spacing      = g_ntohl (header.spacing);
 
166
 
 
167
  /*  Check for correct file format */
 
168
 
 
169
  if (header.width == 0)
 
170
    {
 
171
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
172
                   _("Fatal parse error in brush file '%s': "
 
173
                     "Width = 0."),
 
174
                   gimp_filename_to_utf8 (filename));
 
175
      return NULL;
 
176
    }
 
177
 
 
178
  if (header.height == 0)
 
179
    {
 
180
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
181
                   _("Fatal parse error in brush file '%s': "
 
182
                     "Height = 0."),
 
183
                   gimp_filename_to_utf8 (filename));
 
184
      return NULL;
 
185
    }
 
186
 
 
187
  if (header.bytes == 0)
 
188
    {
 
189
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
190
                   _("Fatal parse error in brush file '%s': "
 
191
                     "Bytes = 0."),
 
192
                   gimp_filename_to_utf8 (filename));
 
193
      return NULL;
 
194
    }
 
195
 
 
196
  switch (header.version)
 
197
    {
 
198
    case 1:
 
199
      /*  If this is a version 1 brush, set the fp back 8 bytes  */
 
200
      lseek (fd, -8, SEEK_CUR);
 
201
      header.header_size += 8;
 
202
      /*  spacing is not defined in version 1  */
 
203
      header.spacing = 25;
 
204
      break;
 
205
 
 
206
    case 3:  /*  cinepaint brush  */
 
207
      if (header.bytes == 18  /* FLOAT16_GRAY_GIMAGE */)
 
208
        {
 
209
          header.bytes = 2;
 
210
        }
 
211
      else
 
212
        {
 
213
          g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
214
                       _("Fatal parse error in brush file '%s': "
 
215
                         "Unknown depth %d."),
 
216
                       gimp_filename_to_utf8 (filename), header.bytes);
 
217
          return NULL;
 
218
        }
 
219
      /*  fallthrough  */
 
220
 
 
221
    case 2:
 
222
      if (header.magic_number == GBRUSH_MAGIC)
 
223
        break;
 
224
 
 
225
    default:
 
226
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
227
                   _("Fatal parse error in brush file '%s': "
 
228
                     "Unknown version %d."),
 
229
                   gimp_filename_to_utf8 (filename), header.version);
 
230
      return NULL;
 
231
    }
 
232
 
 
233
  /*  Read in the brush name  */
 
234
  if ((bn_size = (header.header_size - sizeof (header))))
 
235
    {
 
236
      gchar *utf8;
 
237
 
 
238
      name = g_new (gchar, bn_size);
 
239
 
 
240
      if ((read (fd, name, bn_size)) < bn_size)
 
241
        {
 
242
          g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
243
                       _("Fatal parse error in brush file '%s': "
 
244
                         "File appears truncated."),
 
245
                       gimp_filename_to_utf8 (filename));
 
246
          g_free (name);
 
247
          return NULL;
 
248
        }
 
249
 
 
250
      utf8 = gimp_any_to_utf8 (name, -1,
 
251
                               _("Invalid UTF-8 string in brush file '%s'."),
 
252
                               gimp_filename_to_utf8 (filename));
 
253
      g_free (name);
 
254
      name = utf8;
 
255
    }
 
256
 
 
257
  if (!name)
 
258
    name = g_strdup (_("Unnamed"));
 
259
 
 
260
  brush = g_object_new (GIMP_TYPE_BRUSH,
 
261
                        "name",      name,
 
262
                        "mime-type", "image/x-gimp-gbr",
 
263
                        NULL);
 
264
  g_free (name);
 
265
 
 
266
  brush->mask = temp_buf_new (header.width, header.height, 1, 0, 0, NULL);
 
267
 
 
268
  mask = temp_buf_data (brush->mask);
 
269
  size = header.width * header.height * header.bytes;
 
270
 
 
271
  switch (header.bytes)
 
272
    {
 
273
    case 1:
 
274
      success = (read (fd, mask, size) == size);
 
275
      break;
 
276
 
 
277
    case 2:  /*  cinepaint brush, 16 bit floats  */
 
278
      {
 
279
        guchar buf[8 * 1024];
 
280
 
 
281
        for (i = 0; success && i < size;)
 
282
          {
 
283
            gssize  bytes = MIN (size - i, sizeof (buf));
 
284
 
 
285
            success = (read (fd, buf, bytes) == bytes);
 
286
 
 
287
            if (success)
 
288
              {
 
289
                guint16 *b = (guint16 *) buf;
 
290
 
 
291
                i += bytes;
 
292
 
 
293
                for (; bytes > 0; bytes -= 2, mask++, b++)
 
294
                  {
 
295
                    union
 
296
                    {
 
297
                      guint16 u[2];
 
298
                      gfloat  f;
 
299
                    } short_float;
 
300
 
 
301
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 
302
                    short_float.u[0] = 0;
 
303
                    short_float.u[1] = GUINT16_FROM_BE (*b);
 
304
#else
 
305
                    short_float.u[0] = GUINT16_FROM_BE (*b);
 
306
                    short_float.u[1] = 0;
 
307
#endif
 
308
 
 
309
                    *mask = (guchar) (short_float.f * 255.0 + 0.5);
 
310
                  }
 
311
              }
 
312
          }
 
313
      }
 
314
      break;
 
315
 
 
316
    case 4:
 
317
      {
 
318
        guchar buf[8 * 1024];
 
319
 
 
320
        brush->pixmap = temp_buf_new (header.width, header.height,
 
321
                                      3, 0, 0, NULL);
 
322
        pixmap = temp_buf_data (brush->pixmap);
 
323
 
 
324
        for (i = 0; success && i < size;)
 
325
          {
 
326
            gssize  bytes = MIN (size - i, sizeof (buf));
 
327
 
 
328
            success = (read (fd, buf, bytes) == bytes);
 
329
 
 
330
            if (success)
 
331
              {
 
332
                guchar *b = buf;
 
333
 
 
334
                i += bytes;
 
335
 
 
336
                for (; bytes > 0; bytes -= 4, pixmap += 3, mask++, b += 4)
 
337
                  {
 
338
                    pixmap[0] = b[0];
 
339
                    pixmap[1] = b[1];
 
340
                    pixmap[2] = b[2];
 
341
 
 
342
                    mask[0]   = b[3];
 
343
                  }
 
344
              }
 
345
          }
 
346
      }
 
347
      break;
 
348
 
 
349
    default:
 
350
      g_object_unref (brush);
 
351
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
352
                   _("Fatal parse error in brush file '%s': "
 
353
                     "Unsupported brush depth %d\n"
 
354
                     "GIMP brushes must be GRAY or RGBA."),
 
355
                   gimp_filename_to_utf8 (filename), header.bytes);
 
356
      return NULL;
 
357
    }
 
358
 
 
359
  if (! success)
 
360
    {
 
361
      g_object_unref (brush);
 
362
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
363
                   _("Fatal parse error in brush file '%s': "
 
364
                     "File appears truncated."),
 
365
                   gimp_filename_to_utf8 (filename));
 
366
      return NULL;
 
367
    }
 
368
 
 
369
  brush->spacing  = header.spacing;
 
370
  brush->x_axis.x = header.width  / 2.0;
 
371
  brush->x_axis.y = 0.0;
 
372
  brush->y_axis.x = 0.0;
 
373
  brush->y_axis.y = header.height / 2.0;
 
374
 
 
375
  return brush;
 
376
}
 
377
 
 
378
GList *
 
379
gimp_brush_load_abr (const gchar  *filename,
 
380
                     GError      **error)
 
381
{
 
382
  FILE      *file;
 
383
  AbrHeader  abr_hdr;
 
384
  GList     *brush_list = NULL;
 
385
 
 
386
  g_return_val_if_fail (filename != NULL, NULL);
 
387
  g_return_val_if_fail (g_path_is_absolute (filename), NULL);
 
388
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
389
 
 
390
  file = g_fopen (filename, "rb");
 
391
 
 
392
  if (! file)
 
393
    {
 
394
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
 
395
                   _("Could not open '%s' for reading: %s"),
 
396
                   gimp_filename_to_utf8 (filename), g_strerror (errno));
 
397
      return NULL;
 
398
    }
 
399
 
 
400
  abr_hdr.version = abr_read_short (file);
 
401
  abr_hdr.count   = abr_read_short (file);
 
402
 
 
403
  /* g_print("version: %d  count: %d\n", abr_hdr.version, abr_hdr.count); */
 
404
 
 
405
  if (abr_hdr.version > 1)
 
406
    {
 
407
      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
408
                   _("Fatal parse error in brush file '%s': "
 
409
                     "unable to decode abr format version %d."),
 
410
                   gimp_filename_to_utf8 (filename), abr_hdr.version);
 
411
    }
 
412
  else
 
413
    {
 
414
      gint i;
 
415
 
 
416
      for (i = 0; i < abr_hdr.count; i++)
 
417
        {
 
418
          GimpBrush *brush;
 
419
 
 
420
          brush = gimp_brush_load_abr_brush (file, i, filename, error);
 
421
 
 
422
          if (! brush)
 
423
            {
 
424
              g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
 
425
                           _("Fatal parse error in brush file '%s'"),
 
426
                           gimp_filename_to_utf8 (filename));
 
427
              break;
 
428
            }
 
429
 
 
430
          brush_list = g_list_prepend (brush_list, brush);
 
431
        }
 
432
    }
 
433
 
 
434
  fclose (file);
 
435
 
 
436
  return g_list_reverse (brush_list);
 
437
}
 
438
 
 
439
 
 
440
/*  private functions  */
 
441
 
 
442
static GimpBrush *
 
443
gimp_brush_load_abr_brush (FILE         *file,
 
444
                           gint          index,
 
445
                           const gchar  *filename,
 
446
                           GError      **error)
 
447
{
 
448
  GimpBrush      *brush = NULL;
 
449
  AbrBrushHeader  abr_brush_hdr;
 
450
 
 
451
  g_return_val_if_fail (filename != NULL, NULL);
 
452
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
453
 
 
454
  abr_brush_hdr.type = abr_read_short (file);
 
455
  abr_brush_hdr.size = abr_read_long (file);
 
456
 
 
457
  /*  g_print(" + BRUSH\n | << type: %i  block size: %i bytes\n",
 
458
   *          abr_brush_hdr.type, abr_brush_hdr.size);
 
459
   */
 
460
 
 
461
  switch (abr_brush_hdr.type)
 
462
    {
 
463
    case 1: /* computed brush */
 
464
      /* FIXME: support it!
 
465
       *
 
466
       * We can probabaly feed the info into the generated brush code
 
467
       * and get a useable brush back. It seems to support the same
 
468
       * types -akl
 
469
       */
 
470
      g_printerr ("WARNING: computed brush unsupported, skipping.\n");
 
471
      fseek (file, abr_brush_hdr.size, SEEK_CUR);
 
472
      break;
 
473
 
 
474
    case 2: /* sampled brush */
 
475
      {
 
476
        AbrSampledBrushHeader  abr_sampled_brush_hdr;
 
477
        gint                   width, height;
 
478
        gint                   bytes;
 
479
        gint                   size;
 
480
        guchar                *mask;
 
481
        gint                   i;
 
482
        gchar                 *name;
 
483
        gchar                 *tmp;
 
484
        gshort                 compress;
 
485
 
 
486
        abr_sampled_brush_hdr.misc         = abr_read_long (file);
 
487
        abr_sampled_brush_hdr.spacing      = abr_read_short (file);
 
488
        abr_sampled_brush_hdr.antialiasing = abr_read_char (file);
 
489
 
 
490
        for (i = 0; i < 4; i++)
 
491
          abr_sampled_brush_hdr.bounds[i] = abr_read_short (file);
 
492
        for (i = 0; i < 4; i++)
 
493
          abr_sampled_brush_hdr.bounds_long[i] = abr_read_long (file);
 
494
 
 
495
        abr_sampled_brush_hdr.depth = abr_read_short (file);
 
496
 
 
497
        height = (abr_sampled_brush_hdr.bounds_long[2] -
 
498
                  abr_sampled_brush_hdr.bounds_long[0]); /* bottom - top */
 
499
        width  = (abr_sampled_brush_hdr.bounds_long[3] -
 
500
                  abr_sampled_brush_hdr.bounds_long[1]); /* right - left */
 
501
        bytes  = abr_sampled_brush_hdr.depth >> 3;
 
502
 
 
503
        /* g_print("width %i  height %i\n", width, height); */
 
504
 
 
505
        abr_sampled_brush_hdr.wide = height > 16384;
 
506
 
 
507
        if (abr_sampled_brush_hdr.wide)
 
508
          {
 
509
            /* FIXME: support wide brushes */
 
510
 
 
511
            g_printerr ("WARING: wide brushes not supported\n");
 
512
            return NULL;
 
513
          }
 
514
 
 
515
        tmp = g_filename_display_basename (filename);
 
516
        name = g_strdup_printf ("%s-%03d", tmp, index);
 
517
        g_free (tmp);
 
518
 
 
519
        brush = g_object_new (GIMP_TYPE_BRUSH,
 
520
                              "name",      name,
 
521
                              /*  FIXME: MIME type!!  */
 
522
                              "mime-type", "application/x-photoshop-abr",
 
523
                              NULL);
 
524
 
 
525
        g_free (name);
 
526
 
 
527
        brush->spacing  = abr_sampled_brush_hdr.spacing;
 
528
        brush->x_axis.x = width / 2.0;
 
529
        brush->x_axis.y = 0.0;
 
530
        brush->y_axis.x = 0.0;
 
531
        brush->y_axis.y = height / 2.0;
 
532
        brush->mask     = temp_buf_new (width, height,
 
533
                                        1, 0, 0, NULL);
 
534
 
 
535
        mask = temp_buf_data (brush->mask);
 
536
        size = width * height * bytes;
 
537
 
 
538
        compress = abr_read_char (file);
 
539
 
 
540
        /* g_print(" | << size: %dx%d %d bit (%d bytes) %s\n",
 
541
         *         width, height, abr_sampled_brush_hdr.depth, size,
 
542
         *         comppres ? "compressed" : "raw");
 
543
         */
 
544
 
 
545
        if (! compress)
 
546
          {
 
547
            fread (mask, size, 1, file);
 
548
          }
 
549
        else
 
550
          {
 
551
            gint16 *cscanline_len;
 
552
            gint32  n;
 
553
            gchar   ch;
 
554
            gint    i, j, c;
 
555
 
 
556
            /* read compressed size foreach scanline */
 
557
            cscanline_len = g_new0 (gshort, height);
 
558
            for (i = 0; i < height; i++)
 
559
              cscanline_len[i] = abr_read_short (file);
 
560
 
 
561
            /* unpack each scanline data */
 
562
            for (i = 0; i < height; i++)
 
563
              {
 
564
                for (j = 0; j < cscanline_len[i];)
 
565
                  {
 
566
                    n = abr_read_char (file);
 
567
                    j++;
 
568
                    if (n >= 128)       /* force sign */
 
569
                      n -= 256;
 
570
 
 
571
                    if (n < 0)
 
572
                      {
 
573
                        /* copy the following char -n + 1 times */
 
574
 
 
575
                        if (n == -128)    /* it's a nop */
 
576
                          continue;
 
577
 
 
578
                        n = -n + 1;
 
579
                        ch = abr_read_char (file);
 
580
                        j++;
 
581
                        for (c = 0; c < n; c++, mask++)
 
582
                          *mask = ch;
 
583
                      }
 
584
                    else
 
585
                      {
 
586
                        /* read the following n + 1 chars (no compr) */
 
587
 
 
588
                        for (c = 0; c < n + 1; c++, j++, mask++)
 
589
                          *mask = (guchar) abr_read_char (file);
 
590
                      }
 
591
                  }
 
592
              }
 
593
 
 
594
            g_free (cscanline_len);
 
595
          }
 
596
      }
 
597
      break;
 
598
 
 
599
    default:
 
600
      g_printerr ("WARNING: unknown brush type, skipping.\n");
 
601
      fseek (file, abr_brush_hdr.size, SEEK_CUR);
 
602
      break;
 
603
    }
 
604
 
 
605
  return brush;
 
606
}
 
607
 
 
608
static gchar
 
609
abr_read_char (FILE *file)
 
610
{
 
611
  return fgetc (file);
 
612
}
 
613
 
 
614
static gint16
 
615
abr_read_short (FILE *file)
 
616
{
 
617
  gint16 val;
 
618
 
 
619
  fread (&val, sizeof (val), 1, file);
 
620
 
 
621
  return GINT16_FROM_BE (val);
 
622
}
 
623
 
 
624
static gint32
 
625
abr_read_long (FILE *file)
 
626
{
 
627
  gint32 val;
 
628
 
 
629
  fread (&val, sizeof (val), 1, file);
 
630
 
 
631
  return GINT32_FROM_BE (val);
 
632
}