Hard shadow on top of soft shadow

image_pdfimage_print


   
 


<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.Window1" Title="Text Shadow Samples"
  Background="FloralWhite">
  <StackPanel>

      <TextBlock FontSize="64" Text="asdf" Foreground="Yellow">
        <TextBlock.BitmapEffect>
          <BitmapEffectGroup>
            <DropShadowBitmapEffect ShadowDepth="5" Direction="330" Color="Orange"
              Opacity="0.75"
              Softness="0.50" />
            <DropShadowBitmapEffect
              ShadowDepth="2"
              Direction="330"
              Color="Red"
              Opacity="0.5"
              Softness="0.0" />
          </BitmapEffectGroup>
        </TextBlock.BitmapEffect>
      </TextBlock>


  </StackPanel>
</Window>

   
     


Hard shadow on top of noisy shadow

image_pdfimage_print


   
 


<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.Window1" Title="Text Shadow Samples"
  Background="FloralWhite">
  <StackPanel>

      <TextBlock FontSize="64"
        Text="asdf"
        Foreground="Silver"
        Grid.Column="1" Grid.Row="3">
        <TextBlock.BitmapEffect>
          <BitmapEffectGroup>
            <DropShadowBitmapEffect
              ShadowDepth="3"
              Direction="330"
              Color="Black"
              Opacity="0.75"
              Softness="0.0" />
            <DropShadowBitmapEffect
              Noise="0.75"
              ShadowDepth="6"
              Direction="330"
              Color="Black"
              Opacity="0.35"
              Softness="0.25" />
          </BitmapEffectGroup>
        </TextBlock.BitmapEffect>
      </TextBlock>


  </StackPanel>
</Window>

   
     


Shadow effect by creating an outer glow

image_pdfimage_print


   
 

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.Window1" Title="Text Shadow Samples"
  Background="FloralWhite">
  <StackPanel>

      <TextBlock FontSize="64" Text="{Binding Path=Text, ElementName=textblockMaster}"
        Foreground="SteelBlue" Grid.Column="1" Grid.Row="4">
        <TextBlock.BitmapEffect>
          <OuterGlowBitmapEffect
            GlowSize="1.0"
            GlowColor="Orange"
            Opacity="1.0"/>
        </TextBlock.BitmapEffect>
      </TextBlock>

  </StackPanel>
</Window>

   
     


Create Full Color Bitmap

image_pdfimage_print

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

public class CreateFullColorBitmap : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new CreateFullColorBitmap());
}
public CreateFullColorBitmap()
{
int[] array = new int[256 * 256];

for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) { int b = x; int g = 0; int r = y; array[256 * y + x] = b | (g << 8) | (r << 16); } BitmapSource bitmap= BitmapSource.Create(256, 256, 96, 96, PixelFormats.Bgr32, null, array, 256 * 4); Image img = new Image(); img.Source = bitmap; Content = img; } } [/csharp]

Draw Graphics On Bitmap

image_pdfimage_print
   
 

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

    public class DrawGraphicsOnBitmap : Window
    {
        [STAThread]
        public static void Main()
        {
            Application app = new Application();
            app.Run(new DrawGraphicsOnBitmap());
        }
        public DrawGraphicsOnBitmap()
        {
            Background = Brushes.Khaki;
            RenderTargetBitmap renderbitmap = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Default);
            DrawingVisual drawvis = new DrawingVisual();
            DrawingContext dc = drawvis.RenderOpen();
            dc.DrawRoundedRectangle(Brushes.Blue, new Pen(Brushes.Red, 10),new Rect(25, 25, 50, 50), 10, 10);
            dc.Close();
            renderbitmap.Render(drawvis);
            Image img = new Image();
            img.Source = renderbitmap;

            Content = img;
        }
    }

   
     


Draw Buttons On Bitmap

image_pdfimage_print

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

public class DrawButtonsOnBitmap : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new DrawButtonsOnBitmap());
}
public DrawButtonsOnBitmap()
{
UniformGrid unigrid = new UniformGrid();
unigrid.Columns = 4;

for (int i = 0; i < 32; i++) { ToggleButton btn = new ToggleButton(); btn.Width = 96; btn.Height = 24; btn.IsChecked = true; unigrid.Children.Add(btn); } unigrid.Measure(new Size(Double.PositiveInfinity,Double.PositiveInfinity)); Size szGrid = unigrid.DesiredSize; unigrid.Arrange(new Rect(new Point(0, 0), szGrid)); RenderTargetBitmap renderbitmap = new RenderTargetBitmap((int)Math.Ceiling(szGrid.Width), (int)Math.Ceiling(szGrid.Height), 96, 96, PixelFormats.Default); renderbitmap.Render(unigrid); Image img = new Image(); img.Source = renderbitmap; Content = img; } } [/csharp]

Create Indexed Bitmap

image_pdfimage_print

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

public class CreateIndexedBitmap : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new CreateIndexedBitmap());
}
public CreateIndexedBitmap()
{
List colors = new List();

for (int r = 0; r < 256; r += 17) for (int b = 0; b < 256; b += 17) colors.Add(Color.FromRgb((byte)r, 0, (byte)b)); BitmapPalette palette = new BitmapPalette(colors); byte[] array = new byte[256 * 256]; for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) array[256 * y + x] = (byte)(((int)Math.Round(y / 17.0) << 4) | (int)Math.Round(x / 17.0)); BitmapSource bitmap = BitmapSource.Create(256, 256, 96, 96, PixelFormats.Indexed8,palette, array, 256); Image img = new Image(); img.Source = bitmap; Content = img; } } [/csharp]