Tuesday, August 23, 2016

Trying to write a G'Mic plug-in on Windows.

So I have G'Mic 1.7.5 installed. (1.7.1 which i had earlier didn't seem to want to read from user.gmic file).
And I have a file named user.gmic in my %AppData% folder
which is when I type echo %AppData% in command prompt
it shows C:\Users\Tin Tran\AppData\Roaming

And I am trying to write a simple plug in that allows multiple threshold to be selected at the same time.
The idea is this I have multiple thresholds, stack on top of each other, and then for each layer I delete the white area produce by threshold call and change the black area to a different color.
So far i got threshold to work .... still investigating on how to get it to cut away white or make it transparent so other thresholds would show through and replacing the color... and final step would be to produce a preview that shows the merged results of these layers.
This is what i have so far. (in the user.gmic file)

#@gmic
#@gimp .{development filters}

#@gimp Multi Thresholds : multi_threshold, multi_threshold
#@gimp : Threshold_1 = int(20,1,256)
#@gimp : Threshold_2 = int(40,1,256)
#@gimp : Threshold_3 = int(60,1,256)
multi_threshold :
 --luminance[0] -threshold[-1] $1 -normalize[-1] 0,255 -to_colormode[-1] 4 -if {R==255} A=0 -endif
 --luminance[0] -threshold[-1] $2 -normalize[-1] 0,255 -to_colormode[-1] 4
    -luminance[0] -threshold[0] $3 -normalize[0] 0,255 -to_colormode[0] 4
 

#@gimp _
The if at the end on the first line of command is just me try to get at the pixel data's Red value and see if it's white 255 and set the Alpha to 0 to make it full transparent so far no luck with this.