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): enter image description here 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). enter image description here

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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -