Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. multiple big images on canvas in WPF - rendering problems

multiple big images on canvas in WPF - rendering problems

Scheduled Pinned Locked Moved WPF
adobehelpcsharpwpfperformance
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gruberdominik
    wrote on last edited by
    #1

    I am trying to put several images dynamically onto a canvas. The images are of bigger size (e.g. 9 MB on disc, 200 MB of physical memory when decoded, resolution of 10200 x 7019, 600DPI). If I add 2 images, everything is working fine. If I try to add another image, the Image is there on the canvas (meaning it reacts on mouse events) but it is not rendered - meaning it is invisible. I have about 1 GB of free physical memory available. When 2 images are loaded I still have 600 MB of free physical memory - but I cant load any more images. I tried to set the images' DecodeBitmapWith/Height attributes to have a smaller rendersize, but images are rendered black or look weird. Image.Rendersize attribute doesnt work in this context. I have tried combining 3 big sized images with IrfanView -> same problem. Adobe Photoshop on the other side can handle all 3 Images and display them though PS also consumes nearly 700 MB of phys. memory. I assume it has something to do with memory management. For better understanding here is my code:

    ofd = new OpenFileDialog();
    if ((bool)ofd.ShowDialog(this))
    {
    string[] images = ofd.FileNames;
    foreach (string image in images)
    {
    Uri imgsource = new Uri(image);
    BitmapImage bim = new BitmapImage();
    bim.BeginInit();
    //bim.DecodePixelWidth = 3509;
    bim.DecodePixelHeight = 10200;
    bim.CacheOption = BitmapCacheOption.OnLoad;
    bim.UriSource = imgsource;
    bim.EndInit();
    Image img = new Image();
    img.Source = bim
    canvas1.Children.Add(img);
    img.AllowDrop = true;
    Canvas.SetLeft(img, (canvas1.Children.Count)* 20);
    Canvas.SetTop(img, (canvas1.Children.Count) * 20);
    }

    I hope anyone can help me with this. Thanks in advance and best regards Nick

    I 1 Reply Last reply
    0
    • G gruberdominik

      I am trying to put several images dynamically onto a canvas. The images are of bigger size (e.g. 9 MB on disc, 200 MB of physical memory when decoded, resolution of 10200 x 7019, 600DPI). If I add 2 images, everything is working fine. If I try to add another image, the Image is there on the canvas (meaning it reacts on mouse events) but it is not rendered - meaning it is invisible. I have about 1 GB of free physical memory available. When 2 images are loaded I still have 600 MB of free physical memory - but I cant load any more images. I tried to set the images' DecodeBitmapWith/Height attributes to have a smaller rendersize, but images are rendered black or look weird. Image.Rendersize attribute doesnt work in this context. I have tried combining 3 big sized images with IrfanView -> same problem. Adobe Photoshop on the other side can handle all 3 Images and display them though PS also consumes nearly 700 MB of phys. memory. I assume it has something to do with memory management. For better understanding here is my code:

      ofd = new OpenFileDialog();
      if ((bool)ofd.ShowDialog(this))
      {
      string[] images = ofd.FileNames;
      foreach (string image in images)
      {
      Uri imgsource = new Uri(image);
      BitmapImage bim = new BitmapImage();
      bim.BeginInit();
      //bim.DecodePixelWidth = 3509;
      bim.DecodePixelHeight = 10200;
      bim.CacheOption = BitmapCacheOption.OnLoad;
      bim.UriSource = imgsource;
      bim.EndInit();
      Image img = new Image();
      img.Source = bim
      canvas1.Children.Add(img);
      img.AllowDrop = true;
      Canvas.SetLeft(img, (canvas1.Children.Count)* 20);
      Canvas.SetTop(img, (canvas1.Children.Count) * 20);
      }

      I hope anyone can help me with this. Thanks in advance and best regards Nick

      I Offline
      I Offline
      Insincere Dave
      wrote on last edited by
      #2

      Im guessing you are hitting the memory limit of the GPU. You might want to try TransformedBitmap and scale it that way, I quickly tested this with BitmapCacheOption.None and it seemed to only take up memory for the scaled image. As for the images looking wierd it may be due to a bug in WIC you may need get an updated version. Try Vista SP2 and the Platform Update For Windows Vista

      modified on Wednesday, May 5, 2010 3:00 PM

      G 1 Reply Last reply
      0
      • I Insincere Dave

        Im guessing you are hitting the memory limit of the GPU. You might want to try TransformedBitmap and scale it that way, I quickly tested this with BitmapCacheOption.None and it seemed to only take up memory for the scaled image. As for the images looking wierd it may be due to a bug in WIC you may need get an updated version. Try Vista SP2 and the Platform Update For Windows Vista

        modified on Wednesday, May 5, 2010 3:00 PM

        G Offline
        G Offline
        gruberdominik
        wrote on last edited by
        #3

        Thank you very much for your input. I was also thinking about only having a scaled image in memory and discarding the original sized one. But this would require a lot of additional calculation. What I am trying to do is implementing an application that is capable of combining single images into one image. E.g. an architect's plan (ANSI C) is scanned in into 3 ANSI B paper sized images. Those images are now loaded into my app, repositioned and then combined. The result should be the original plan with respect to its original size, DPI etc. I was hoping there is another soluion, since Adobe Photoshop is capable of holding all 3 images in memory keeping the original sizes. But I am starting working on algorithms that will work on scaled images. best Regards Dominik

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups