HighTechTalks DotNet Forums  

wpf net 3.0 Changing Colors in a bitmap

Dotnet Framework microsoft.public.dotnet.framework


Discuss wpf net 3.0 Changing Colors in a bitmap in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Rolf Welskes
 
Posts: n/a

Default wpf net 3.0 Changing Colors in a bitmap - 10-28-2007 , 06:29 PM






Hello,
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



Reply With Quote
  #2  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: wpf net 3.0 Changing Colors in a bitmap - 10-28-2007 , 11:44 PM






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/lib...related_topics


Hope this helps.


Regards,
Walter Wang (wawang (AT) online (DOT) 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.


Reply With Quote
  #3  
Old   
Rolf Welskes
 
Posts: n/a

Default Re: wpf net 3.0 Changing Colors in a bitmap - 10-29-2007 , 11:52 AM



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]"" <wawang (AT) online (DOT) microsoft.com> schrieb im Newsbeitrag
news65V63dGIHA.540 (AT) TK2MSFTNGHUB02 (DOT) phx.gbl...
Quote:
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/lib...related_topics


Hope this helps.


Regards,
Walter Wang (wawang (AT) online (DOT) 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.




Reply With Quote
  #4  
Old   
Rolf Welskes
 
Posts: n/a

Default Re: wpf net 3.0 Changing Colors in a bitmap - 10-29-2007 , 05:48 PM



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]"" <wawang (AT) online (DOT) microsoft.com> schrieb im Newsbeitrag
news65V63dGIHA.540 (AT) TK2MSFTNGHUB02 (DOT) phx.gbl...
Quote:
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/lib...related_topics


Hope this helps.


Regards,
Walter Wang (wawang (AT) online (DOT) 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.




Reply With Quote
  #5  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default Re: wpf net 3.0 Changing Colors in a bitmap - 10-30-2007 , 06:36 AM



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\RGBFilter EffectLib.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/co...ContentID=2220.



Regards,
Walter Wang (wawang (AT) online (DOT) 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.


Reply With Quote
  #6  
Old   
Rolf Welskes
 
Posts: n/a

Default Re: wpf net 3.0 Changing Colors in a bitmap - 10-30-2007 , 08:31 PM



Hello,
thank you for you help - was a realy help for me.
Thank you and best regards
Rolf Welskes


""Walter Wang [MSFT]"" <wawang (AT) online (DOT) microsoft.com> schrieb im Newsbeitrag
news:vwfe6CuGIHA.7444 (AT) TK2MSFTNGHUB02 (DOT) phx.gbl...
Quote:
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\RGBFilter EffectLib.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/co...ContentID=2220.



Regards,
Walter Wang (wawang (AT) online (DOT) 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.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.