[Gimp-developer] Format of GIMP gradient files
Hi, What is the format of the GIMP gradient files? For example, the gradient default which goes from black-white with a grey midpoint has the following text format: GIMP Gradient 1 0.00 0.50 1.00 0.00 0.00 0.00 1.00 1.00 1.00 1.00 1.00 0 0 and the gradient French flag has the format: GIMP Gradient 3 0.00 0.17 0.33 0.00 0.00 1.00 1.00 0.00 0.00 1.00 1.00 0 0 0.33 0.50 0.67 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0 0 0.67 0.83 1.00 1.00 0.00 0.00 1.00 1.00 0.00 0.00 1.00 0 0 So the first number is obviously the number of segments in the gradient, and therefore each line must describe one segment. The first three values are the left/middle/right end points of the segments respectively. this leaves me with 8 floating point numbers and 2 integers to describe the three colours - the first 3 numbers seem to be the RGB values of the left end point. But what the heck are the remaining numbers? They don't seem to correspond to anything ! Any help appreciated... -- Dr. Gordon F Royle, http://www.cs.uwa.edu.au/~gordon, [EMAIL PROTECTED] -- ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Format of GIMP gradient files
On 30 May 2002, at 17:44, Gordon Royle wrote: What is the format of the GIMP gradient files? For example, the gradient default which goes from black-white with a grey midpoint has the following text format: GIMP Gradient 1 0.00 0.50 1.00 0.00 0.00 0.00 1.00 1.00 1.00 1.00 1.00 0 0 and the gradient French flag has the format: GIMP Gradient 3 0.00 0.17 0.33 0.00 0.00 1.00 1.00 0.00 0.00 1.00 1.00 0 0 0.33 0.50 0.67 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0 0 0.67 0.83 1.00 1.00 0.00 0.00 1.00 1.00 0.00 0.00 1.00 0 0 So the first number is obviously the number of segments in the gradient, and therefore each line must describe one segment. The first three values are the left/middle/right end points of the segments respectively. this leaves me with 8 floating point numbers and 2 integers to describe the three colours - the first 3 numbers seem to be the RGB values of the left end point. But what the heck are the remaining numbers? They don't seem to correspond to anything ! What helps for me usually is look at the code for loading and saving GIMPy things, in this case gradients. It depends a bit on who coded and how well-chosen variable names are, but most of the time numbers are loaded in the order they are written and you should be able to make some sense of them by looking at the variable names. If you don't want to download the GIMP's source, you can study it through http://cvs.gnome.org. Another way of finding out may be to look at the PDB (Toolbox/Xtns/Database Browser..., if I am not mistaken) and see if there are any public functions for manipulating I am sorry if this is not very helpful, but I am busy. Perhaps someone else could give a more exact answer. -- branko collin [EMAIL PROTECTED] ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Format of GIMP gradient files
Hi, Gordon Royle [EMAIL PROTECTED] writes: What is the format of the GIMP gradient files? this routine saves the gradient. You should be able to determine the format from this info: for (seg = gradient-segments; seg; seg = seg-next) { gchar buf[11][G_ASCII_DTOSTR_BUF_SIZE]; g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-left); g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-middle); g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-right); g_ascii_formatd (buf[3], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-left_color.r); g_ascii_formatd (buf[4], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-left_color.g); g_ascii_formatd (buf[5], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-left_color.b); g_ascii_formatd (buf[6], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-left_color.a); g_ascii_formatd (buf[7], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-right_color.r); g_ascii_formatd (buf[8], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-right_color.g); g_ascii_formatd (buf[9], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-right_color.b); g_ascii_formatd (buf[10], G_ASCII_DTOSTR_BUF_SIZE, %f, seg-right_color.a); fprintf (file, %s %s %s %s %s %s %s %s %s %s %s %d %d\n, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], (gint) seg-type, (gint) seg-color); } Salut, Sven ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Format of GIMP gradient files
Gordon Royle wrote: Hi, What is the format of the GIMP gradient files? For example, the gradient default which goes from black-white with a grey midpoint has the following text format: GIMP Gradient 1 0.00 0.50 1.00 0.00 0.00 0.00 1.00 1.00 1.00 1.00 1.00 0 0 and the gradient French flag has the format: GIMP Gradient 3 0.00 0.17 0.33 0.00 0.00 1.00 1.00 0.00 0.00 1.00 1.00 0 0 0.33 0.50 0.67 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0 0 0.67 0.83 1.00 1.00 0.00 0.00 1.00 1.00 0.00 0.00 1.00 0 0 So the first number is obviously the number of segments in the gradient, and therefore each line must describe one segment. The first three values are the left/middle/right end points of the segments respectively. this leaves me with 8 floating point numbers and 2 integers to describe the three colours - the first 3 numbers seem to be the RGB values of the left end point. But what the heck are the remaining numbers? They don't seem to correspond to anything ! The format seems to be start middle end [range 0...1] R G B A left endpoint R G B A right endpoint type where type is one of linear (0), curved, sine, sphere_increasing and shere_decreasing coloring, one of rgb, hsv_ccw, hsv_cw The type colouring are accessible to the gradient editor (the user, I mean) in the blending function for segment and Colouring type for segment menus of the gradient editor menu. This information is available in app/gradient.c and app/gradient_header.h. Dave. -- David Neary, Marseille, France E-Mail: [EMAIL PROTECTED] ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Format of GIMP gradient files
Sven Neumann wrote: Hi, Gordon Royle [EMAIL PROTECTED] writes: What is the format of the GIMP gradient files? this routine saves the gradient. You should be able to determine the format from this info: snip routine Really? In 1.2, it appears to be this... fprintf (file, %d\n, num_segments); for (seg = grad-segments; seg; seg = seg-next) fprintf (file, %f %f %f %f %f %f %f %f %f %f %f %d %d\n, seg-left, seg-middle, seg-right, seg-r0, seg-g0, seg-b0, seg-a0, seg-r1, seg-g1, seg-b1, seg-a1, (int) seg-type, (int) seg-color); Why the huge change? Dave. -- David Neary, Marseille, France E-Mail: [EMAIL PROTECTED] ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Format of GIMP gradient files
On Thu, May 30, 2002 at 02:25:04PM +0200, David Neary wrote: Really? In 1.2, it appears to be this... fprintf (file, %d\n, num_segments); for (seg = grad-segments; seg; seg = seg-next) fprintf (file, %f %f %f %f %f %f %f %f %f %f %f %d %d\n, seg-left, seg-middle, seg-right, seg-r0, seg-g0, seg-b0, seg-a0, seg-r1, seg-g1, seg-b1, seg-a1, (int) seg-type, (int) seg-color); Why the huge change? That's hardly a huge change from the original, is it? /* Steinar */ -- Homepage: http://www.sesse.net/ ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Format of GIMP gradient files
Hi, David Neary [EMAIL PROTECTED] writes: snip routine Really? In 1.2, it appears to be this... fprintf (file, %d\n, num_segments); for (seg = grad-segments; seg; seg = seg-next) fprintf (file, %f %f %f %f %f %f %f %f %f %f %f %d %d\n, seg-left, seg-middle, seg-right, seg-r0, seg-g0, seg-b0, seg-a0, seg-r1, seg-g1, seg-b1, seg-a1, (int) seg-type, (int) seg-color); Why the huge change? because the string representaion of doubles and floats is locale-dependent. In GIMP-1.2 we had to explicitely set LC_NUMERIC to C to make it work. Since this is a bad idea we changed to the locale-indenpendent g_ascii_formatd() / g_ascii_dtostr() in GIMP-1.3. You might have noticed that numbers are displayed with the digits-seperator specified by your locale in GIMP-1.3 while in GIMP-1.2 it's always '.' as defined the C locale. Salut, Sven ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Format of GIMP gradient files
David Neary [EMAIL PROTECTED] writes: Sven Neumann wrote: Hi, Gordon Royle [EMAIL PROTECTED] writes: What is the format of the GIMP gradient files? this routine saves the gradient. You should be able to determine the format from this info: snip routine Really? In 1.2, it appears to be this... fprintf (file, %d\n, num_segments); for (seg = grad-segments; seg; seg = seg-next) fprintf (file, %f %f %f %f %f %f %f %f %f %f %f %d %d\n, seg-left, seg-middle, seg-right, seg-r0, seg-g0, seg-b0, seg-a0, seg-r1, seg-g1, seg-b1, seg-a1, (int) seg-type, (int) seg-color); Why the huge change? I don't see any change in the file format except the following: In GIMP 1.3, gradients have an extension .ggr and don't encode thair name in the filename anymore but inside the .ggr file: GIMP Gradient Name: Abstract 1 6 0.00 0.286311 0.572621 0.269543 0.259267 1.00 1.00 0.215635 0.407414 0.984953 1.00 0 0 0.572621 0.657763 0.716194 0.215635 0.407414 0.984953 1.00 0.040368 0.83 0.619375 1.00 0 0 0.716194 0.734558 0.749583 0.040368 0.83 0.619375 1.00 0.680490 0.355264 0.977430 1.00 0 0 0.749583 0.784641 0.824708 0.680490 0.355264 0.977430 1.00 0.553909 0.351853 0.977430 1.00 0 0 0.824708 0.853088 0.876461 0.553909 0.351853 0.977430 1.00 1.00 0.00 1.00 1.00 0 0 0.876461 0.943172 1.00 1.00 0.00 1.00 1.00 1.00 1.00 0.00 1.00 0 0 Which is still so ugly that i think we should never allow the new format to become used, but port it to a GimpConfig style format: proposal # GIMP Gradient file (GimpGradient Abstract 1 (segment 0.00 0.286311 0.572621 (left-color (gimp-rgba 0.269543 0.259267 1.00 1.00)) (right-color (gimp-rgba 0.215635 0.407414 0.984953 1.00)) (blending-function linear) (coloring-type rgb)) (segment ...) ... (segment ...)) /proposal Of course, GIMP would continue to read the old files. ciao, --mitch ___ Gimp-developer mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer