RSS/Atom feed Twitter
Site is read-only, email is disabled

gimp-drawable-curves-spline

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

gimp-drawable-curves-spline Maurizio Loreti 24 Feb 15:49
  gimp-drawable-curves-spline Simon Budig 24 Feb 15:59
   gimp-drawable-curves-spline Maurizio Loreti 24 Feb 16:07
Maurizio Loreti
2016-02-24 15:49:12 UTC (about 8 years ago)

gimp-drawable-curves-spline

On 24 feb 2016, at 16:29, Kevin Payne > wrote:

(which appear to be mostly the same, other than the control points have changed from being INT to FLOAT)

OK - well, my scheme knowledge is not enough :-( Here is the relevant section of the code:

(define (spline) (let* ((a (cons-array 8 'byte))) (set-pt a 0 0 0)
(set-pt a 1 63 60)
(set-pt a 2 191 194)
(set-pt a 3 255 255)
a))
(define (set-pt a index x y)
(prog1
(aset a (* index 2) x)
(aset a (+ (* index 2) 1) y)))
(gimp-curves-spline inDrw 0 8 (spline))

Just changing the procedure name in the last line to gimp-drawable-curves-spline is not enough. If I understand correctly, the program allocates an array of 8 bytes where 8 integer values (0,0; 63,60; 191,194; 155.255) are stored. The memory to be allocated should be adequate for 8 floating point values (8 * 32 bytes?), and the values stored there. Is set-pt adequate? Or intended for integer values only? May somebody help me?

Maurizio Loreti   -   Maurizio.Loreti@gmail.com
Simon Budig
2016-02-24 15:59:12 UTC (about 8 years ago)

gimp-drawable-curves-spline

Maurizio Loreti (maurizio.loreti@gmail.com) wrote:

(let* ((a (cons-array 8 'byte)))

Just changing the procedure name in the last line to gimp-drawable-curves-spline is not enough. If I understand correctly, the program allocates an array of 8 bytes where 8 integer values (0,0; 63,60; 191,194; 155.255) are stored.

To be more specific: the program allocates an 8 entry array, where each entry contains a byte.

The memory to be allocated
should be adequate for 8 floating point values (8 * 32 bytes?), and the values stored there. Is set-pt adequate? Or intended for integer values only? May somebody help me?

Allocate an array with 8 entries where each entry contains a "double"-float-value:

(cons-array 8 'double)

You might need to change the scale of the values in there - instead from 0 to 255 they might be normalized to 0.0 to 1.0.

I hope this helps, Simon

simon@budig.de              http://simon.budig.de/
Maurizio Loreti
2016-02-24 16:07:21 UTC (about 8 years ago)

gimp-drawable-curves-spline

On 24 feb 2016, at 16:59, Simon Budig wrote:

Maurizio Loreti (maurizio.loreti@gmail.com) wrote:

(let* ((a (cons-array 8 'byte)))

Just changing the procedure name in the last line to gimp-drawable-curves-spline is not enough. If I understand correctly, the program allocates an array of 8 bytes where 8 integer values (0,0; 63,60; 191,194; 155.255) are stored.

To be more specific: the program allocates an 8 entry array, where each entry contains a byte.

The memory to be allocated
should be adequate for 8 floating point values (8 * 32 bytes?), and the values stored there. Is set-pt adequate? Or intended for integer values only? May somebody help me?

Allocate an array with 8 entries where each entry contains a "double"-float-value:

(cons-array 8 'double)

You might need to change the scale of the values in there - instead from 0 to 255 they might be normalized to 0.0 to 1.0.

It works indeed; the new code is the following:

(define (spline) (let* ((a (cons-array 8 'double))) (set-pt a 0 0.0 0.0)
(set-pt a 1 0.24706 0.23529)
(set-pt a 2 0.74902 0.76078)
(set-pt a 3 1.0 1.0)
a))
(define (set-pt a index x y)
(prog1
(aset a (* index 2) x)
(aset a (+ (* index 2) 1) y)))
(gimp-drawable-curves-spline inDrw 0 8 (spline))

(gimp-image-undo-group-end inImg) (gimp-displays-flush)
)

Thank you for the quick answer, and thank you all for working on such a wonderful program as GIMP.

Maurizio Loreti   -   Maurizio.Loreti@gmail.com