|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
wpf net 3.0 Changing Colors in a bitmapHello,
because there are no news group for window presentation foundation and one has told me I can use this, here my problem: I have a bitmap in wpf for example using BitmapImage. Now I want to change brightness, Colors etc. In gdi+ this was done by using a color-matrix, in windows presentation foundation do not find any way to do this. For example to change a green to a brighter geen, in gdi+ I had colormatrix to change color angles. Thank you for any help. Best Regards Rolf Welskes Hi Rolf,
In WPF, you can use BitmapEffect to apply visual effects. We have 5 built-in effects: Blur, DropShadow, OuterGlow, Bevel, Emboss. However, we currently don't have a built-in effect to change brightness or contrast, but you can create a custom BitmapEffect to do this: #WPF Bitmap Effects http://msdn2.microsoft.com/en-us/library/ms735322.aspx#related_topics Hope this helps. Regards, Walter Wang (waw***@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hello,
thank you for your informations, but this is very problematic. Because all is in software no accelaration by the graphic card. Think on a 3D-Scene, I have a gray think, whatever. Now I take a light which changes from red to blue, This I this is possible as animation, so the think looks first red and then slowly goes over to blue. But this I cannot do with a simple 2D bitmap - is this reality? Thank you and best regards Rolf Welskes ""Walter Wang [MSFT]"" <waw***@online.microsoft.com> schrieb im Newsbeitrag Show quote news:D65V63dGIHA.540@TK2MSFTNGHUB02.phx.gbl... > Hi Rolf, > > In WPF, you can use BitmapEffect to apply visual effects. We have 5 > built-in effects: Blur, DropShadow, OuterGlow, Bevel, Emboss. However, we > currently don't have a built-in effect to change brightness or contrast, > but you can create a custom BitmapEffect to do this: > > #WPF Bitmap Effects > http://msdn2.microsoft.com/en-us/library/ms735322.aspx#related_topics > > > Hope this helps. > > > Regards, > Walter Wang (waw***@online.microsoft.com, remove 'online.') > Microsoft Online Community Support > > ================================================== > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no > rights. > Hello,
I have tried the Bitmap Effect sample. But I get an AccessViolationException: try to access secured memory or similar. Does the example not work? Thank You Rolf Welskes ""Walter Wang [MSFT]"" <waw***@online.microsoft.com> schrieb im Newsbeitrag Show quote news:D65V63dGIHA.540@TK2MSFTNGHUB02.phx.gbl... > Hi Rolf, > > In WPF, you can use BitmapEffect to apply visual effects. We have 5 > built-in effects: Blur, DropShadow, OuterGlow, Bevel, Emboss. However, we > currently don't have a built-in effect to change brightness or contrast, > but you can create a custom BitmapEffect to do this: > > #WPF Bitmap Effects > http://msdn2.microsoft.com/en-us/library/ms735322.aspx#related_topics > > > Hope this helps. > > > Regards, > Walter Wang (waw***@online.microsoft.com, remove 'online.') > Microsoft Online Community Support > > ================================================== > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no > rights. > Hi Rolf,
I tested the sample and did find the issue you mentioned. The code should be corrected to: public class RGBFilterBitmapEffect : BitmapEffect { unsafe protected override SafeHandle CreateUnmanagedEffect() { const uint CLSCTX_INPROC_SERVER = 1; Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046"); Guid guidEffectCLSID = new Guid("84CF07CC-34C4-460f-B435-3184F5F2FF2A"); SafeHandle wrapper = BitmapEffect.CreateBitmapEffectOuter(); COMSafeHandle unmanagedEffect; uint hresult = Ole32Methods.CoCreateInstance( ref guidEffectCLSID, wrapper.DangerousGetHandle(), CLSCTX_INPROC_SERVER, ref IID_IUnknown, out unmanagedEffect); if (hresult != 0) throw new Exception("Cannot instantiate effect. HRESULT = " + hresult.ToString()); InitializeBitmapEffect(wrapper, unmanagedEffect); return wrapper; } Also, you need to manually register RGBFilterEffect\RGBFilterEffectLib\Debug\RGBFilterEffectLib.dll using regsvr32.exe. ---------- For your another question about the performance, currently WPF version 1.0 BitmapEffect is only using software mode. Therefore the performance issue does exist. Please feel free to submit your feedback here: http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220. Regards, Walter Wang (waw***@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hello,
thank you for you help - was a realy help for me. Thank you and best regards Rolf Welskes ""Walter Wang [MSFT]"" <waw***@online.microsoft.com> schrieb im Newsbeitrag Show quote news:vwfe6CuGIHA.7444@TK2MSFTNGHUB02.phx.gbl... > Hi Rolf, > > I tested the sample and did find the issue you mentioned. The code should > be corrected to: > > public class RGBFilterBitmapEffect : BitmapEffect > { > > unsafe protected override SafeHandle CreateUnmanagedEffect() > { > const uint CLSCTX_INPROC_SERVER = 1; > Guid IID_IUnknown = new > Guid("00000000-0000-0000-C000-000000000046"); > Guid guidEffectCLSID = new > Guid("84CF07CC-34C4-460f-B435-3184F5F2FF2A"); > SafeHandle wrapper = BitmapEffect.CreateBitmapEffectOuter(); > > COMSafeHandle unmanagedEffect; > uint hresult = Ole32Methods.CoCreateInstance( > ref guidEffectCLSID, > wrapper.DangerousGetHandle(), > CLSCTX_INPROC_SERVER, > ref IID_IUnknown, > out unmanagedEffect); > if (hresult != 0) > throw new Exception("Cannot instantiate effect. HRESULT = " > + hresult.ToString()); > InitializeBitmapEffect(wrapper, unmanagedEffect); > return wrapper; > > } > > > Also, you need to manually register > RGBFilterEffect\RGBFilterEffectLib\Debug\RGBFilterEffectLib.dll using > regsvr32.exe. > > > > ---------- > > > For your another question about the performance, currently WPF version 1.0 > BitmapEffect is only using software mode. Therefore the performance issue > does exist. Please feel free to submit your feedback here: > http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220. > > > > Regards, > Walter Wang (waw***@online.microsoft.com, remove 'online.') > Microsoft Online Community Support > > ================================================== > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no > rights. > |
|||||||||||||||||||||||