Quantcast
Viewing all articles
Browse latest Browse all 40524

Cannot maintain a constant 60 fps when doing color filtering on ofImage

if you are using openFrameworks 0.9 you can do:

ofColor filterColor = ofColor::green;
for(auto line: imageBuffer.getPixels().getLines()){
    for(auto pixel: line.getPixels()){
            float tintPercentage = .25;
            pixel[0] = pixel[0] + (tintPercentage * (filterColor.r - pixel[0]));
            pixel[1] = pixel[1] + (tintPercentage * (filterColor.g - pixel[1]));
            pixel[2] = pixel[2] + (tintPercentage * (filterColor.b - pixel[2]));
    }
}

which is slightly faster than the method you are using. in any case the fastest way to do this would be to use a shader to apply the tint to the images.

Also drawing an image like:

ofSetColor(filterColor);
image.draw(x,y);

applies a tint to the image when drawing it although not exactly with the same algorithm you are using


Viewing all articles
Browse latest Browse all 40524

Trending Articles