create controlP5 button.
in
Contributed Library Questions
•
1 year ago
hay everyone, i'm using java language in processing.org.
i wanna creat button to convert rgb image to grayscale image, here my code:
this to create the button in windowControl:
- Controller Button3 = controlP5.addButton("grayscale", 0, 40, 150, 50, 18);
- Button3.setWindow(windowControl);
and this to convert rgb image to grayscale:
- public void grayscale(PImage img) {
- for (int j = 0; j < img.height; j++) {
- for (int i = 0; i < img.width; i++) {
- color c=get(i, j);
- float r = red(c);
- float g = green(c);
- float b = blue(c);
- int grayscale= (int)(r+g+b)/3;
- color grayscale2 = color(grayscale, grayscale, grayscale);
- set(i, j, grayscale2);
- }
- }
- }
my problem is, when i click the grayscale button, there is no change in the image.
please help me..thanks, Bland1t.
1