locked
Rendering several canvas in thumbnails RRS feed

  • Question

  • Hi, I would like to copy the rendering results of several big canvas in a kind of summary page.(thumbnails)

    Have you any idea about the best way to solve this efficiently ?

     I tried to play with DrawingContex, DrawingVisual and RenderTargetBitmap but I have huge memory issues (.NET 3.0). It seems it's not solved yet in 3.5SP1.

    Methods I see :
    - render all canvas in XPS and show XPS doc with a small zoom value.
    - copy all canvas objects to others canvas with a small zoom value.
    - copy the renderer of the canvas (only way is RenderTargetBitmap ? If so, memory problems appear...)
    - ?

    Thanks for your help,
    Torniolle.

    Wednesday, January 14, 2009 8:18 PM

Answers

  • I think you should take a look at the VisualBrush:
    <Page  
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">  
        
      <Grid> 
        <Grid.ColumnDefinitions> 
          <ColumnDefinition/> 
          <ColumnDefinition/> 
        </Grid.ColumnDefinitions> 
          
        <Canvas x:Name="canvas" Grid.Column="0">  
          <Button Canvas.Top="25" Canvas.Left="25" 
                  Content="Button 1" 
                  Width="150" Height="150"/>  
          <Button Canvas.Top="125" Canvas.Left="125" 
                  Content="Button 2" 
                  Width="200" Height="200"/>  
        </Canvas> 
          
        <Border Grid.Column="1" Width="100" Height="100">  
          <Border.Background> 
            <VisualBrush Visual="{Binding ElementName=canvas}"/>  
          </Border.Background> 
        </Border> 
          
      </Grid> 
        
    </Page> 

    hth,
    Marcel
    • Marked as answer by Torniolle Sunday, January 18, 2009 9:39 AM
    Thursday, January 15, 2009 8:52 AM

All replies

  • I think you should take a look at the VisualBrush:
    <Page  
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">  
        
      <Grid> 
        <Grid.ColumnDefinitions> 
          <ColumnDefinition/> 
          <ColumnDefinition/> 
        </Grid.ColumnDefinitions> 
          
        <Canvas x:Name="canvas" Grid.Column="0">  
          <Button Canvas.Top="25" Canvas.Left="25" 
                  Content="Button 1" 
                  Width="150" Height="150"/>  
          <Button Canvas.Top="125" Canvas.Left="125" 
                  Content="Button 2" 
                  Width="200" Height="200"/>  
        </Canvas> 
          
        <Border Grid.Column="1" Width="100" Height="100">  
          <Border.Background> 
            <VisualBrush Visual="{Binding ElementName=canvas}"/>  
          </Border.Background> 
        </Border> 
          
      </Grid> 
        
    </Page> 

    hth,
    Marcel
    • Marked as answer by Torniolle Sunday, January 18, 2009 9:39 AM
    Thursday, January 15, 2009 8:52 AM
  • Great !

    I forgot about VisualBrush, I will have to use it with C# code and not XAML, but you're right, it's the best solution.

    Thanks for your help DutchMarcel,
    Torniolle.
    Sunday, January 18, 2009 9:38 AM