Wpf highlight image? - wpf

Is there any effect in WPF I could Make an image shiny etc.?
(I want to use it for a hovered image)
A mask or something like this would be great.

Try applying a BitmapEffect to the image, just keep in mind that they can be expensive to use.
OuterGlowBitmapEffect might help you.

It depends on what do you mean by "shiny". A simple way is to have each image opacity set to 0.5 and change it to 1 when mouse is in.

Related

A nice-looking WPF knob control source code?

I am trying to make some rotary knob with WPF and C#, .NET3.5; So right now what I am having is:
but instead, I really want to have something like these:
Anyone has any idea how I can make it look nicer? I am writing the WPF code from scratch. Thanks a lot.
You are using SolidColorBrush right now. Play with RadialGradientBrush instead to achieve the look.
You can create such an effect by finding a nice pictue of a knob, and then apply a rotatetransform on it.
If the picture contains the scale, you will need to edit that out to an other image, which can be under the knob picture.

Rectangular shaped Gradient Fill

I'm currently looking to achieve a gradient effect a bit like the rectangle in http://pjnicholson.com/Fireworks/fillgradients.htm
If I compromise a little I can get close to this using RadialGradientBrush... but is there any (not too painful) way to achieve the rectangular effect?
Use an ImageBrush instead and use this image (or a similar image generated using some image editor) for the background of your rectangle.
One solution a colleague and I came with was to derive a new Panel that used a WriteableBitmap as the source for its background.
The panel will give you the dimensions you need to make your WriteableBitmap. Using whatever algorithm you want you can fill it appropriately. In our case, we needed a radial or cone gradient, but the same concept applies.
Additionally, you can create several properties on your new control to specify the colors for the gradient. We adapted a LinearGradientBrush for our needs, but if you're working on just two colors, simple properties may suffice.
I don't have the code handy but will try to find it and post an update later. But the above should get you going.

Make part of an image transparent

I want to put an image on a button, but I want part of the image to be transparent. How do I do this?
Try the Image.OpacityMask property. You can give it a brush that specifies the region you want to be transparent.
EDIT: From MSDN:
There is no direct support for
color-keying a bitmap in WPF.
However, it is fairly easy to
implement on your own. Dwayne has
implemented a ColorKeyBitmap on his
blog:
http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx
I believe it links to the code on
Codeplex as well. You could also
accomplish this simply by reading your
bitmap into system memory, iterating
through all the pixels and setting
their values yourself, and
constructing a new bitmap out of that
array.
Use a paint program (I use Paint.Net) to change the area you want transparent to an alha=0 color. Then save the image (mine was JPG) as a PNG. Seemed to work fine for me in the WPF Image control.

Change pixels to fill with color in a WPF image

I'm trying to fill an area of an image in WPF. Something similar to the bucket in Paint. How should I do this? I'm thinking of getting the pixel color under the mouse, and change all the pixels with the same color near. Is there a simpler way?
What should I use? WriteableBitmap?
Thank you
Yes, WriteableBitmap is the best way to go on this one IMHO.

Is this a good case for use of RoutedCommand?

I have a WPF page that has 2 ContentControls on it. Both of the ContentControls have an image, one being much smaller than the other. When mouse over the larger image I want to show a zoomed in view on the smaller image. Something very similar to this: http://www.trekbikes.com/us/en/bikes/urban/soho/soho/.
I think I want the larger image control to send out something that actually contains an image - which the smaller image control would pick up and display. Would this be a good place to take advantage of RoutedCommands? Can I pass along an image like that?
RoutedCommands seem a bit misplaced in this case... you'll want the mouse to respond smoothly and the last thing you want are commands to be fired off here and there.
You're probably better off using a VisualBrush. While Ian Griffith's example here is a magnifying glass (an early canonical VisualBrush example in WPF) you could easily adapt it to show a portion of your image.

Resources