c# - Blending an image together with a control's background -
i'm trying blend image reduced opacity control's background. code i'm using following one:
colormatrix matrix = new colormatrix(new float[][]{ new float[] {1f, 0, 0, 0, 0}, new float[] {0, 1f, 0, 0, 0}, new float[] {0, 0, 1f, 0, 0}, new float[] {0, 0, 0, opacity, 0}, //opacity in rage [0 1] new float[] {0, 0, 0, 0, 1f}}); imageattributes imageattributes = new imageattributes(); imageattributes.setcolormatrix(matrix); g.compositingmode = compositingmode.sourceover; g.compositingquality = compositingquality.highquality; //g comes background painted on it; img bitmap g.drawimage(img, new rectangle(0, 0, img.width, img.height), 0, 0, img.width, img.height, graphicsunit.pixel, imageattributes);
speed performance quality has problems dark images. following 2 images background (left) , foreground(right): when using opacity of 0.9 foreground produce output on left here below. same images photoshop , 90% opacity on foreground produce more consistent result (right).
am doing wrong or limitation of imageattribute
method? if problem method i'm using, can please suggest alternatives still keep in mind performances? possibly, alternative should consider receive background painted on graphics
object.
edit make clear, problem @ 90% of opacity dark portions (only those!) of image transparent. if hold color, apply factor opacity value, light colors works (see light bulb) , dark not.
did try compositingquality.gammacorrected? looks me if compositing not gamma corrected.
you may wish experiment imageattributes.setgamma method.
Comments
Post a Comment