C++/CLI: ColorMatrix for applying an Alpha Threshold

Would anyone know how to specify a ColorMatrix (Specifically a System::Drawing::Imaging::ColorMatrix in C++/CLI) to set an alpha threshold? For example if I were to use 10 (10/255) as my threshold then any pixel with an RGBA Alpha of 10 or less would have 0.0f Alpha and every pixel above would get 1.0f.

I'm trying to implement ColorID picking in a 2D scene editor as I'm sick of using my current unwieldy method of reversing my drawing transformations to determine which pixel of a given bitmap the mouse is pointing at. So what I want to do instead is do a ColorID rendering pass like in OpenGL as described here http://content.gpwiki.org/index.php/OpenGL_Selection_Using_Unique_Color_IDs However I can't just compare the locations of bitmaps onscreen as most of them include tons of white-space that I don't want being picked up by mouse picking which leaves me with color-picking.

For now my ColorMatrix looks like

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0
R G B 0 1

following Hans' answer to GDI+: Set all pixels to given color while retaining existing alpha value but I'd like it to also apply a threshold to the Alpha component (provided that's even possible using a ColorMatrix)


也许你正在寻找ImageAttributes.SetThreshold方法。

链接地址: http://www.djcxy.com/p/29188.html

上一篇: PIXI.js不是为阶段中的所有子对象使用colormatrix

下一篇: C ++ / CLI:应用Alpha阈值的ColorMatrix