Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6837559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:29:30+00:00 2026-05-26T23:29:30+00:00

I am using Silverlight 4 and am having trouble correctly generating bitmaps from UIElements

  • 0

I am using Silverlight 4 and am having trouble correctly generating bitmaps from UIElements that have a projection applied to them.

In my specific case I am using the WriteableBitmap class to capture a bitmap of an Image control which has a Matrix3DProjection applied to it. This projection represents a non-affine transform which is used to transform the Image into an arbitrary quadrilateral. The resulting bitmap is then saved for later use.

Unfortunately, projections seem to be ignored when WriteableBitmap captures a UIElement. This also seems to be the case for any RenderTransform that may be attached, although this can be addressed by using an overload on the WriteableBitmap constructor that accepts a Transform. No such consideration seems to have been made for projections.

The following contrived code example illustrates the point. It transforms a Button rather than an Image component, but the effect is the same.

The XAML:

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Button x:Name="button" Grid.Column="0" Width="100" Height="50" Click="button_Click">Render me</Button>
    <Image x:Name="image" Grid.Column="1" Width="200" Height="200" Stretch="Uniform"/>
</Grid>

The code behind:

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();

        button.Projection = new Matrix3DProjection()
        {
            ProjectionMatrix = new Matrix3D()
            {
                M11 = 0.825, M12 = -0.513, M13 = 0, M14 = 0.001,
                M21 = 0.023, M22 = 0.986, M23 = 0, M24 = -0.002,
                M31 = 0, M32 = 0, M33 = 1, M34 = 0,
                OffsetX = 0, OffsetY = 0, OffsetZ = 0, M44 = 1
            }
        }; 
    }

    private void button_Click(object sender, RoutedEventArgs e)
    {
        // Render the button as a bitmap and display
        WriteableBitmap bitmap = new WriteableBitmap(button, null);
        image.Source = bitmap;
    }
}

When run, you will find that an image of the button is rendered into the Image component, but without the distortion that is obvious on the original button itself.

I’ve tried playing around with both the constructor and Render method on WriteableBitmap, with all of their various overloads with no success. I have also tried nesting the source UIElement within other elements and applying the projection at varying levels of the tree to see if WriteableBitmap would render a projection correctly if it was as part of a larger composite structure. No luck there either.

Hopefully I am just missing something simple here, but I suspect that this just may not be possible in the current version of Silverlight.

If this is indeed a dead end, then a viable alternative to me would be to be able to directly apply the matrix transformation to a bitmap, bypassing the whole UIElement.Projection piece of silverlight altogether. However, I don’t really know where to start when it comes to taking a source bitmap, feeding it’s pixels through such a transformation, and collecting the resultant output. The fact that the transformation is non-affine suggests to me that there will be some level of interpolation involved, and that the math requirements for such a solution are probably significant.

Any help or advice is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:29:31+00:00Added an answer on May 26, 2026 at 11:29 pm

    Try using the LayoutTransformer from Silverlight Control Toolkit (System.Windows.Controls.Layout.Toolkit assembly)

    <UserControl x:Class="SilverlightApplication1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Canvas x:Name="LayoutRoot" Background="White">
            <toolkit:LayoutTransformer x:Name="lt" >
                <Button x:Name="button" Click="Button_Click">Click me</Button>
            </toolkit:LayoutTransformer>
    
            <Border BorderBrush="Red" BorderThickness="1" Canvas.Left="100" Canvas.Top="100">
                <Image x:Name="image"  Width="100" Height="100" />
            </Border>
        </Canvas>
    </UserControl>
    

    Code behind:

        public MainPage()
        {
            InitializeComponent();
            button.Projection = new Matrix3DProjection() { ProjectionMatrix = new Matrix3D() { M11 = 0.825, M12 = -0.513, M13 = 0, M14 = 0.001, M21 = 0.023, M22 = 0.986, M23 = 0, M24 = -0.002, M31 = 0, M32 = 0, M33 = 1, M34 = 0, OffsetX = 0, OffsetY = 0, OffsetZ = 0, M44 = 1 } };
        }
    
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WriteableBitmap bitmap = new WriteableBitmap(lt, null); 
            image.Source = bitmap; 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have using Silverlight and Caliburn Micro and am having a problem getting child
Using VS2008, Silverlight 4. I have created an AttachedProperty, RequiresRole, that I'm setting in
I have a Silverlight app that is using the MVVM pattern. I have a
using Silverlight I am having trouble with the following code: CultureInfo culture = new
I have a rather simple Silverlight application, lately we've been having reports from users
I have just started using silverlight 2 beta and cannot find how to or
I'm using Silverlight Beta 4 for a LOB application. After finding out today that
I am trying to protoype a silverlight 4.0 project using F#, and am having
I'm a newbie to Silverlight and I'm having some trouble finding a solution to
I have a typical Silverlight application with a WCF service and I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.