try this, it'll check to see if numch is 4 means there's alpha and will also work if there's no alpha channel.
(define (script-fu-test-color-by-pixel
image
drawable
)
(let*
(
(RGBvalues 0)
(REDvalue 0)
(GREENvalue 0)
(BLUEvalue 0)
(numch 0)
(x-coord 100)
(y-coord 100)
)
(set! RGBvalues (cadr (gimp-drawable-get-pixel drawable x-coord y-coord)))
(set! numch (car (gimp-drawable-get-pixel drawable x-coord y-coord)))
(set! REDvalue (aref RGBvalues 0))
(set! GREENvalue (aref RGBvalues 1))
(set! BLUEvalue (aref RGBvalues 2))
(define my_pixel (list (- 255 REDvalue) (- 255 GREENvalue) (- 255 BLUEvalue) 255))
(if (= numch 4)
(begin ;if numch = 4 means drawable has an alpha channel we just add whatever that is to our pixel
(set! my_pixel (append my_pixel (list (aref RGBvalues 3))))
)
(begin ;else do nothing
)
)
;(gimp-message (string-append "RED = " (number->string REDvalue)))
(gimp-drawable-set-pixel drawable x-coord y-coord numch (list->vector my_pixel))
(gimp-drawable-update drawable 0 0 (car (gimp-drawable-width drawable)) (car (gimp-drawable-height drawable)))
(gimp-displays-flush)
;;; and so on ....
) ; end let
) ; end define
(script-fu-register "script-fu-test-color-by-pixel"
_"<Image>/Script-Fu/Test/test-color-by-pixel"
"test getting RGB from a pixel"
"D.N"
"2016"
"2016"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
Thank trandoductin.