Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

wpf net 3.0 Changing Colors in a bitmap

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rolf Welskes - 28 Oct 2007 23:29 GMT
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
Walter Wang [MSFT] - 29 Oct 2007 04:44 GMT
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 (wawang@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.
Rolf Welskes - 29 Oct 2007 16:52 GMT
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

> Hi Rolf,
>
[quoted text clipped - 19 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Rolf Welskes - 29 Oct 2007 22:48 GMT
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

> Hi Rolf,
>
[quoted text clipped - 19 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Walter Wang [MSFT] - 30 Oct 2007 11:36 GMT
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 (wawang@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.
Rolf Welskes - 31 Oct 2007 01:31 GMT
Hello,
thank you for you help - was a realy help for me.
Thank you and best regards
Rolf Welskes

> Hi Rolf,
>
[quoted text clipped - 50 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.