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. C#
  4. load images dynamically in to sysetem resourses

load images dynamically in to sysetem resourses

Scheduled Pinned Locked Moved C#
graphicshelpgame-devquestion
10 Posts 3 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.
  • Z Offline
    Z Offline
    Zap Man
    wrote on last edited by
    #1

    my application requires me to load tons of images dynamically based on a path set at run time. right now I have something that looks like this.

    private Image mybtn;

    public Image MyBtn{
    get{return = mybtn;}
    set{mybtn = value;}
    }

    public static void SetButtonImage(string imgPath){
    MyBtn = new Bitmap(imgPath);
    }

    the problem is that the images are slow. Slow loading, slow reloading a hover image. I have found that if I use a pictureBox instead its faster but not fast enough. The question is, is there a was to load these in like a temp resouce file that will enable every thing to run faster. Im looking into using DirectX and load them as sprites but not sure if its really going to help much. Please Let me know what you all think. Mike

    Richard Andrew x64R N 2 Replies Last reply
    0
    • Z Zap Man

      my application requires me to load tons of images dynamically based on a path set at run time. right now I have something that looks like this.

      private Image mybtn;

      public Image MyBtn{
      get{return = mybtn;}
      set{mybtn = value;}
      }

      public static void SetButtonImage(string imgPath){
      MyBtn = new Bitmap(imgPath);
      }

      the problem is that the images are slow. Slow loading, slow reloading a hover image. I have found that if I use a pictureBox instead its faster but not fast enough. The question is, is there a was to load these in like a temp resouce file that will enable every thing to run faster. Im looking into using DirectX and load them as sprites but not sure if its really going to help much. Please Let me know what you all think. Mike

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Right now, are you loading the images from resources inside your EXE, or are these discrete files on disk? Nevermind, I failed to read carefully enough!

      1 Reply Last reply
      0
      • Z Zap Man

        my application requires me to load tons of images dynamically based on a path set at run time. right now I have something that looks like this.

        private Image mybtn;

        public Image MyBtn{
        get{return = mybtn;}
        set{mybtn = value;}
        }

        public static void SetButtonImage(string imgPath){
        MyBtn = new Bitmap(imgPath);
        }

        the problem is that the images are slow. Slow loading, slow reloading a hover image. I have found that if I use a pictureBox instead its faster but not fast enough. The question is, is there a was to load these in like a temp resouce file that will enable every thing to run faster. Im looking into using DirectX and load them as sprites but not sure if its really going to help much. Please Let me know what you all think. Mike

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Zap-Man wrote:

        my application requires me to load tons of images dynamically

        First question is why? Do you really need all the images at once? Can you load them on demand?


        only two letters away from being an asset

        Z 1 Reply Last reply
        0
        • N Not Active

          Zap-Man wrote:

          my application requires me to load tons of images dynamically

          First question is why? Do you really need all the images at once? Can you load them on demand?


          only two letters away from being an asset

          Z Offline
          Z Offline
          Zap Man
          wrote on last edited by
          #4

          The system goes through a file and sets all parameters at that point. The graphics are read off several different files. at the time when starting the project. I thought that loading the Images into a Image variable would be faster than loading them into a string aka path. That way it would not have to go get the file then convert it over to an Image at the time of display. right now I have panels working as screens. when one screen is displayed the others remain at size(0,0). The panels are preset at when loading the program and all the controls that belong to the panel, where the images are sitting and what size. so when a new srceen is shown all it has to do is resize the panel to the correct size from 0,0. I understand that windows has to repaint all these when displayed but im just trying to speed it up. The whole program runs on images.

          N 1 Reply Last reply
          0
          • Z Zap Man

            The system goes through a file and sets all parameters at that point. The graphics are read off several different files. at the time when starting the project. I thought that loading the Images into a Image variable would be faster than loading them into a string aka path. That way it would not have to go get the file then convert it over to an Image at the time of display. right now I have panels working as screens. when one screen is displayed the others remain at size(0,0). The panels are preset at when loading the program and all the controls that belong to the panel, where the images are sitting and what size. so when a new srceen is shown all it has to do is resize the panel to the correct size from 0,0. I understand that windows has to repaint all these when displayed but im just trying to speed it up. The whole program runs on images.

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            This senerio has your app using a lot more memory and thus contributing to reducing the overall performance of the machine, not making it faster. I would consider loading the images on demand. Even if all of your panels are used during each session they are not all displayed at the same time. You could prefetch the next set of images when displaying a panel to reduce the load time. I wouldn't load all the panels and set them to 0,0 either. Regardless of the display size they are still using resources that may not be necessary. Use User Controls and dynamically add or remove them if nothing else. Finally, if your entire app runs on images, I'd consider a different environment, like WPF or an out of browser Silverlight app, or a different design to not be so reliant on images.


            only two letters away from being an asset

            Z 3 Replies Last reply
            0
            • N Not Active

              This senerio has your app using a lot more memory and thus contributing to reducing the overall performance of the machine, not making it faster. I would consider loading the images on demand. Even if all of your panels are used during each session they are not all displayed at the same time. You could prefetch the next set of images when displaying a panel to reduce the load time. I wouldn't load all the panels and set them to 0,0 either. Regardless of the display size they are still using resources that may not be necessary. Use User Controls and dynamically add or remove them if nothing else. Finally, if your entire app runs on images, I'd consider a different environment, like WPF or an out of browser Silverlight app, or a different design to not be so reliant on images.


              only two letters away from being an asset

              Z Offline
              Z Offline
              Zap Man
              wrote on last edited by
              #6

              ok this is the information I need. Again Mark I say thanks. Have you used WPF? would all my code be transferable, meaning Im I going to have to learn a new language or does it render C#. Im looking at a few sites that give information on WPF but before I decide to transfer to it or something like it I need to know how fast I can implemt the application over. my app is finished and sold yesterday. I cant spend tons of time changing it over right now. maybe in a couple of months but not sure. The bad thing is if I kept up on things maybe I could have suggested WPF but instead I just did what I was told and never gave it a second thought.

              N 1 Reply Last reply
              0
              • Z Zap Man

                ok this is the information I need. Again Mark I say thanks. Have you used WPF? would all my code be transferable, meaning Im I going to have to learn a new language or does it render C#. Im looking at a few sites that give information on WPF but before I decide to transfer to it or something like it I need to know how fast I can implemt the application over. my app is finished and sold yesterday. I cant spend tons of time changing it over right now. maybe in a couple of months but not sure. The bad thing is if I kept up on things maybe I could have suggested WPF but instead I just did what I was told and never gave it a second thought.

                N Offline
                N Offline
                Not Active
                wrote on last edited by
                #7

                Zap-Man wrote:

                Im I going to have to learn a new language or does it render C#.

                The code is C# yes but the layout is XMAL.

                Zap-Man wrote:

                how fast I can implemt the application over.

                Can't answer that question, it's up to how fast you can pickup the skills and what code you do have. If the app was structured with independent layers and loosely coupled then it should be a matter of changing the presentation, nothing else.


                only two letters away from being an asset

                1 Reply Last reply
                0
                • N Not Active

                  This senerio has your app using a lot more memory and thus contributing to reducing the overall performance of the machine, not making it faster. I would consider loading the images on demand. Even if all of your panels are used during each session they are not all displayed at the same time. You could prefetch the next set of images when displaying a panel to reduce the load time. I wouldn't load all the panels and set them to 0,0 either. Regardless of the display size they are still using resources that may not be necessary. Use User Controls and dynamically add or remove them if nothing else. Finally, if your entire app runs on images, I'd consider a different environment, like WPF or an out of browser Silverlight app, or a different design to not be so reliant on images.


                  only two letters away from being an asset

                  Z Offline
                  Z Offline
                  Zap Man
                  wrote on last edited by
                  #8

                  ok I answered many of my questions. I downloaded a sample project that they had and yes they used tons of C#. a could other files that I could not open like vail. Im still searching for a download the link to blend isn't working so im still searching. lol Thanks again for all your help Mark.

                  N 1 Reply Last reply
                  0
                  • Z Zap Man

                    ok I answered many of my questions. I downloaded a sample project that they had and yes they used tons of C#. a could other files that I could not open like vail. Im still searching for a download the link to blend isn't working so im still searching. lol Thanks again for all your help Mark.

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #9

                    Your're welcome. Please remember to vote on the answers, good or bad, so it will help others who may have similar problems find a sufficient answer also


                    only two letters away from being an asset

                    1 Reply Last reply
                    0
                    • N Not Active

                      This senerio has your app using a lot more memory and thus contributing to reducing the overall performance of the machine, not making it faster. I would consider loading the images on demand. Even if all of your panels are used during each session they are not all displayed at the same time. You could prefetch the next set of images when displaying a panel to reduce the load time. I wouldn't load all the panels and set them to 0,0 either. Regardless of the display size they are still using resources that may not be necessary. Use User Controls and dynamically add or remove them if nothing else. Finally, if your entire app runs on images, I'd consider a different environment, like WPF or an out of browser Silverlight app, or a different design to not be so reliant on images.


                      only two letters away from being an asset

                      Z Offline
                      Z Offline
                      Zap Man
                      wrote on last edited by
                      #10

                      ok I have given up on the wpf. I spent all day yesterday trying to install a trial version an kept reciving errors. And none of the links to install it actually work. So far im not impressed by it. I think I'll just stick to c# vs for now. probably will just be inserting some DirectX into the code to render my images as sprites. This should free up a little stress on the cpu. It sounds like there are alot of others out there using wpf but I think theres more that just got tired of all the crap and errors that I went through.

                      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