It is currently Thu Aug 20, 2026 4:47 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: help invert color
PostPosted: Sun May 29, 2016 11:49 pm  (#21) 
Offline
GimpChat Member

Joined: Feb 21, 2016
Posts: 34
trandoductin wrote:
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.
Successful, Thank you for your kind help and answers


Top
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group