From lewing@isc.tamu.edu Mon Apr 21 08:19:34 1997 Date: Sun, 20 Apr 1997 16:43:06 -0500 (CDT) From: Larry Ewing To: GIMP Development Discussion List Subject: [gimp-devel]patch: add version 1 loading to gbr plugin All, This adds support to the gbr plugin to allow it to load version 1 .gbr files. It does not support saving version 1 brushes. --Larry --- gbr.c.orig Sun Apr 20 17:15:06 1997 +++ gbr.c Sun Apr 20 17:32:26 1997 @@ -209,20 +209,42 @@ ph.bytes = ntohl(ph.bytes); ph.magic_number = ntohl(ph.magic_number); ph.spacing = ntohl(ph.spacing); + + if (ph.magic_number != GBRUSH_MAGIC) { + /* The one circustance where this is okay is when ph.version == 1 */ + if (ph.version != 1) + { + close (fd); + return -1; + } + } - if (ph.magic_number != GBRUSH_MAGIC || ph.version != 2 || - ph.header_size <= sizeof(ph)) { - close(fd); + + if (ph.version != FILE_VERSION) + { + if (ph.version == 1) + { + /* NOTE: spacing is not defined in version 1 */ + /* ph.spacing = 25; */ + g_warning("gbr: Old Version 1 style brush\n"); + } + else + { + close (fd); + g_warning("gbr: Unsupported brush version, load failed\n"); return -1; - } + } + } + /* seek to the begining of the image data */ if (lseek(fd, ph.header_size - sizeof(ph), SEEK_CUR) != ph.header_size) { close(fd); return -1; } - - /* Now there's just raw data left. */ + + + /* Now there's just raw data left. */ /* * Create a new image of the proper size and associate the filename with it.