How to smooth after manual altering pixels?
in
Programming Questions
•
3 years ago
Hi, for detecting the intersection of two overlapping forms and then coloring them, I use the following code sniplet:
Both PGraphics, g1 and g2 were smoothed before that process. When being manuall altered, the smoothing for sure gets lost. Is there any way to do again Anti-Aliasing on the final image g2 again, so also the manually altered pixels get smoothed?
Thank you very much!
P.s.: I know that using the awt.Color-Object is very uncommon, but I had problems to retrieve the one from the Processing library (using eclipse)...
- //Get the Graphics object from both shape objects
PGraphics g1 = null;
PGraphics g2 = null;
try {
g1 = (PGraphics) r1.getGraphics().clone();
g2 = (PGraphics) r2.getGraphics().clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//load their pixel arrays
g1.loadPixels();
g2.loadPixels();
//when they're both different from the bg at the same position, they must intersect
for(int i=0; i<g1.pixels.length; i++){
//if they intersect, colorize them in the given way
if(g1.pixels[i]!=0 && g2.pixels[i]!=0){
g1.pixels[i] = color(intersectC.getRed(), intersectC.getGreen(), intersectC.getBlue(), intersectC.getAlpha());
}
}
//blend them together
g2.beginDraw();
g2.image(g1,0,0);
g2.endDraw();
return g2;
Both PGraphics, g1 and g2 were smoothed before that process. When being manuall altered, the smoothing for sure gets lost. Is there any way to do again Anti-Aliasing on the final image g2 again, so also the manually altered pixels get smoothed?
Thank you very much!
P.s.: I know that using the awt.Color-Object is very uncommon, but I had problems to retrieve the one from the Processing library (using eclipse)...
2
