diff --git a/ChangeLog b/ChangeLog index 104af2525b..3d8b5dd8c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +1999-08-18 Tor Lillqvist + + * app/gimpbrushhose.c (gimp_brush_hose_load): Fix it. Now the hose + itself, interpreted as a pixmap brush (which the hose is a + subclass of), is the first brush in its list. The rest of the + pixmap brushes in the list are separately allocated ones. Don't + read the pattern names into dummy buffers, just seek past. + + * app/pixmapbrush.c (pixmapbrush_motion): Now works better, and + actually steps through the pixmaps in the hose's list. The + paint_core->brush (which points to a brush hose in the cases we're + interested in) is temporarily replaced with the current pixmap + brush to use, and restored after applying the pixmap brush. + + * app/makefile.{cygwin,msc}: Add new files. + Tue Aug 17 16:36:54 1999 ape@gandalf.spacetec.no (Asbjorn Pettersen) * libgimp/gimp.c (gimp_uninstall_temp_proc): Prevent calling free with diff --git a/app/gimpbrushhose.c b/app/gimpbrushhose.c index 357767014f..b324c0c873 100644 --- a/app/gimpbrushhose.c +++ b/app/gimpbrushhose.c @@ -37,8 +37,6 @@ gimp_brush_hose_class_init (GimpBrushHoseClass *klass) parent_class = gtk_type_class (GIMP_TYPE_BRUSH_PIXMAP); object_class->destroy = gimp_brush_hose_destroy; - - } void @@ -74,29 +72,27 @@ gimp_brush_hose_load (char *file_name) GimpBrushHose *hose; GimpBrushPixmap *brush; GimpBrushList *list; + GimpObject o; FILE *fp; unsigned char buf[sz_BrushHeader]; gchar buf2[1024]; BrushHeader header; int bn_size; unsigned int *hp; - char *nothing; int i; int num_of_brushes; int brush_count=0; hose = GIMP_BRUSH_HOSE(gimp_type_new(gimp_brush_hose_get_type())); GIMP_BRUSH_HOSE(hose)->filename = g_strdup(file_name); - // hose = gimp_brush_hose_new - brush = GIMP_BRUSH_PIXMAP(gimp_type_new(gimp_brush_pixmap_get_type())); - GIMP_BRUSH(brush)->filename = g_strdup(file_name); + brush = GIMP_BRUSH (hose); list = gimp_brush_list_new(); - printf("filename: %s\n list->num_brushes: %i", file_name, list->num_brushes); + printf("opening hose: %s\n", file_name); - if ((fp =fopen(file_name, "rb")) == NULL) + if ((fp = fopen(file_name, "rb")) == NULL) return NULL; /* the file format starts with a painfully simple text header @@ -132,11 +128,16 @@ gimp_brush_hose_load (char *file_name) if ((fread (buf, 1, sz_BrushHeader, fp)) < sz_BrushHeader) { fclose (fp); + gimp_object_destroy (hose); gimp_object_destroy (brush); return NULL; } + if (brush_count > 0) + brush = GIMP_BRUSH_PIXMAP(gimp_type_new(gimp_brush_pixmap_get_type())); + GIMP_BRUSH(brush)->filename = g_strdup(file_name); + /* rearrange the bytes in each unsigned int */ hp = (unsigned int *) &header; for (i = 0; i < (sz_BrushHeader / 4); i++) @@ -151,6 +152,7 @@ gimp_brush_hose_load (char *file_name) if (header.version != 1) { fclose (fp); + gimp_object_destroy (hose); gimp_object_destroy (brush); return NULL; } @@ -175,6 +177,7 @@ gimp_brush_hose_load (char *file_name) { g_message ("Error in GIMP brush file...aborting."); fclose (fp); + gimp_object_destroy (hose); gimp_object_destroy (brush); return NULL; } @@ -204,6 +207,7 @@ gimp_brush_hose_load (char *file_name) header.version, file_name); fclose (fp); + gimp_object_destroy (hose); gimp_object_destroy (brush); return NULL; } @@ -213,6 +217,8 @@ gimp_brush_hose_load (char *file_name) if ((fread (buf, 1, sz_PatternHeader, fp)) < sz_PatternHeader) { fclose (fp); + gimp_object_destroy (hose); + gimp_object_destroy (brush); return NULL; } @@ -229,26 +235,16 @@ gimp_brush_hose_load (char *file_name) 0, 0, NULL); - /* Read in the pattern name */ + /* Skip the pattern name */ if ((bn_size = (header.header_size - sz_PatternHeader))) - { - - nothing = (char *) g_malloc (sizeof (char) * bn_size); - if ((fread (nothing, 1, bn_size, fp)) < bn_size) - { - g_message ("Error in GIMP pattern file...aborting."); - fclose (fp); - - return NULL; - } - - } - else - { - - nothing = g_strdup ("Unnamed"); - } - + if ((fseek (fp, bn_size, SEEK_CUR)) < 0) + { + g_message ("Error in GIMP pattern file...aborting."); + fclose (fp); + gimp_object_destroy (hose); + gimp_object_destroy (brush); + return NULL; + } if ((fread (temp_buf_data (brush->pixmap_mask), 1, header.width * header.height * header.bytes, fp)) @@ -256,8 +252,7 @@ gimp_brush_hose_load (char *file_name) g_message ("GIMP pattern file appears to be truncated."); - if(brush != NULL) - gimp_brush_list_add(list,GIMP_BRUSH(brush)); + gimp_brush_list_add(list,GIMP_BRUSH(brush)); printf("got here brush_count: %i\n", brush_count); printf("brush_list_count: %i \n", gimp_brush_list_length(list)); @@ -268,8 +263,13 @@ gimp_brush_hose_load (char *file_name) } fclose (fp); - brush =GIMP_BRUSH_PIXMAP((gimp_brush_list_get_brush_by_index(list,0))); + + if (!GIMP_IS_BRUSH_HOSE(hose)) + g_print ("Is not BRUSH_HOSE???\n"); +#if 0 + brush = GIMP_BRUSH_PIXMAP((gimp_brush_list_get_brush_by_index(list,0))); hose->pixmap_brush = *brush; +#endif hose->brush_list = list; /* random test code */ @@ -277,4 +277,3 @@ gimp_brush_hose_load (char *file_name) return hose; } - diff --git a/app/makefile.cygwin b/app/makefile.cygwin index 769efa5c9c..146f59a0f9 100644 --- a/app/makefile.cygwin +++ b/app/makefile.cygwin @@ -135,6 +135,7 @@ gimp_OBJECTS = \ gimage_mask_cmds.o \ gimpbrush.o \ gimpbrushgenerated.o \ + gimpbrushhose.o \ gimpbrushlist.o \ gimpbrushpixmap.o \ gimpcontext.o \ diff --git a/app/makefile.msc b/app/makefile.msc index 08a439196b..603a01f2b2 100644 --- a/app/makefile.msc +++ b/app/makefile.msc @@ -142,6 +142,7 @@ gimp_OBJECTS = \ gimage_mask_cmds.obj \ gimpbrush.obj \ gimpbrushgenerated.obj \ + gimpbrushhose.obj \ gimpbrushlist.obj \ gimpbrushpixmap.obj \ gimpcontext.obj \ diff --git a/app/pixmapbrush.c b/app/pixmapbrush.c index 14ad17e226..6653f9ff87 100644 --- a/app/pixmapbrush.c +++ b/app/pixmapbrush.c @@ -44,7 +44,16 @@ static void pixmapbrush_motion (PaintCore *, GimpDrawable *); /* static Argument * pixmapbrush_extended_gradient_invoker (Argument *); */ - +static void paint_line_pixmap_mask (GImage *dest, + GimpDrawable *drawable, + GimpBrushPixmap *brush, + unsigned char *d, + int x, + int offset_x, + int y, + int offset_y, + int bytes, + int width); /* defines */ @@ -200,36 +209,35 @@ pixmapbrush_motion (PaintCore *paint_core, GimpDrawable *drawable) { GImage *gimage; - TempBuf * area = NULL; - /* unsigned char col[MAX_CHANNELS]; */ - void * pr; + GimpBrush *saved_brush; + TempBuf * area; int opacity; - GimpBrushHose *brush; + static int index = 0; - pr = NULL; - - if(GIMP_IS_BRUSH_PIXMAP(paint_core->brush)){ - printf("looks like were a pixmap\n"); - } - - if(!( GIMP_IS_BRUSH_HOSE(paint_core->brush))){ - printf("not gimpbrushhose apparently...but why not i have no idea\n"); - } - - // brush = GIMP_BRUSH_HOSE(paint_core->brush); - - - //paint_core->brush = gimp_brush_list_get_brush_by_index(&(GIMP_BRUSH_HOSE(brush))->brush_list, 0); - /* We always need a destination image */ if (! (gimage = drawable_gimage (drawable))) return; - - /* Get a region which can be used to p\\aint to */ - + if(!( GIMP_IS_BRUSH_HOSE(paint_core->brush))){ + g_print("not gimpbrushhose apparently...but why not i have no idea\n"); + return; + } else + { + saved_brush = paint_core->brush; + /* Set paint_core->brush, restore below before returning. + * I wonder if this is wise? + */ + paint_core->brush = gimp_brush_list_get_brush_by_index(GIMP_BRUSH_HOSE(paint_core->brush)->brush_list, index++); + if (index == gimp_brush_list_length (GIMP_BRUSH_HOSE(saved_brush)->brush_list)) + index = 0; + } + + /* Get a region which can be used to paint to */ if (! (area = paint_core_get_paint_area (paint_core, drawable))) - return; + { + paint_core->brush = saved_brush; + return; + } color_area_with_pixmap(gimage, drawable, area, paint_core->brush); @@ -242,6 +250,8 @@ pixmapbrush_motion (PaintCore *paint_core, (int) (gimp_context_get_opacity (NULL) * 255), gimp_context_get_paint_mode (NULL), SOFT, INCREMENTAL); + + paint_core->brush = saved_brush; } @@ -323,7 +333,7 @@ color_area_with_pixmap (GImage *dest, } -void +static void paint_line_pixmap_mask (GImage *dest, GimpDrawable *drawable, GimpBrushPixmap *brush,