Since this was much to slow I tried to work with tint.
tint(255,(int)Math.round(afactor*255));
image(g,0,0);
This one would work, but since I need to write the output to graphics and not to the screen this is also no option for me. So this is what I tried next:
graphics.tint(255,(int)Math.round(afactor*255));
graphics.image(g,0,0);
And this finally got me a NullPointerException. I really don't understand where that came from, especially since it is not really different from the example before.
So if anybody knows what went wrong, I really dont konw what to do next.