Short Description: This patch extends Blender's internal paint tool for being used with multi-layer OpenEXR files.
NOTE: I posted this patch on IRC in December (2014), since I had no time at that point to go through the hassle of creating a Blender dev account here, etc. Not sure if anybody applied this patch in the meantime or not.
Revision Context: This is a patch against the Blender 2.72b tarball release version.
Background: The paint tool of Blender <= 2.72b is limited to ImageBufs with exactly 4 channels. Since most render passes (except the "combined" and "vector" passes) however are stored to and loaded from .exr files with 3 channels and less, the paint tool did not allow to paint to most render pass layers of .exr files at all and showed an error message "Image requires 4 color channels to paint" on user's brush actions instead. This patch implements generic painting on ImageBufs with arbitrary amount of channels to resolve this usability constraint regarding OpenEXR files. The old blend functions, optimized for 4 channels are still used if the provided ImageBuf is using 4 channels.
From usability point of view, I find this an important fix regarding OpenEXR compatibility with Blender. Because currently there is no open source solution at all to paint to multi-layer OpenEXR files. There is apparently an OpenEXR plugin available for Gimp, however that Gimp plugin only provides import functionality, which will truncate the color channels to 8 bit resolution, which actually renders it useless, because it destroys the purpose of the OpenEXR format of keeping the data in HDR during the entire post processing process.
See also my initial post about this issue on Stackexchange:
http://blender.stackexchange.com/questions/19600/painting-on-openexr-multilayer-images
I am using this patch for more than 3 months in production now. Encountered no negative issues so far.