CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    9

    How to display canvas thumbnails.

    Hi,

    I am working on a WPF application. In this we will change the position of the components on the canvas. Every time we change the positions of the components on the canvas, we have to display a thumbnails of the canvas.

    I have a procedure to create the images of the canvas.

    http://blogs.msdn.com/saveenr/archiv...ng-bitmap.aspx

    Now I have to display the images of the thumbnail as canvas dynamically as thumbnails.

    If anyone have any idea to solve this please reply me.


    Thanks in Advance

  2. #2
    Join Date
    Jan 2009
    Posts
    36

    Re: How to display canvas thumbnails.

    I may not fully understand the question, but here is one method to display an image dynamically (in code):

    I assume that you have an Image control defined somewhere where you want to display the thumbnail? In this example, I have this defined in XAML:

    Code:
    <Image x:Name="image" />
    I have an image saved to disk that I load into memory by doing the following:

    Code:
    FileInfo fileInf = new FileInfo("out.png");
    byte[] imageBytes = File.ReadAllBytes(fileInf.FullName);
    Then, when I want to display the image I do the following:
    Code:
    using (MemoryStream ms = new MemoryStream(imageBytes))
    {
        BitmapImage img = new BitmapImage();
        img.BeginInit();
        img.CacheOption = BitmapCacheOption.OnLoad;
        img.StreamSource = ms;
        img.EndInit();
    
        this.image.Source = img;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured