0

I am trying this method of double image buffering, it is a for each loop which loops through the whole array and if the int is an even number it will add it to the end string variable and then display that image in StarImage however if it is an odd number it will do the same but this time display in the Image2.. for some reason it displays the strings in the 2 text boxes whether that was an even number or an odd number but for some reason the image is not showing in the imagebox's even though this is the correct path for the images, here is what I have so far:

string[] images = new string[] { "Star_00001.png", "Star_00002.png", "Star_00003.png", "Star_00004.png", "Star_00005.png", "Star_00006.png", "Star_00007.png", "Star_00008.png",
                                         "Star_00009.png", "Star_00010.png", "Star_00011.png", "Star_00012.png", "Star_00013.png", "Star_00014.png", "Star_00015.png", "Star_00016.png",
                                         "Star_00017.png", "Star_00018.png", "Star_00019.png", "Star_00021.png", "Star_00022.png", "Star_00023.png", "Star_00024.png", "Star_00025.png",};

        int num = 0;

        string path = "Assets/Star/Star_0000";

            foreach(string file in images)
            {
                num = num + 1;
                if ((num & 1) == 0)
                {

                    string num2 = num.ToString();
                    string end = path + num2;
                    BitmapImage Image = new BitmapImage();
                    Image.UriSource = new Uri(this.BaseUri, end);
                    StarImage.Source = Image;
                    TxtBlock1.Text = end;
                    await Task.Delay(46);

                }
                else
                {


                    string num2 = num.ToString();
                    string end = path + num2;
                    BitmapImage Image3 = new BitmapImage();
                    Image3.UriSource = new Uri(this.BaseUri, end);
                    Image2.Source = Image3;
                    TxtBlock2.Text = end;
                    await Task.Delay(46);

                }
              }

Does anyone understand what I am doing wrong, or perhaps any alternatives to double buffering?

Jermain Defo
  • 189
  • 1
  • 1
  • 11
  • Why do you iterate over the list of files, but use a number instead of the filename? – Willem Van Onsem Feb 15 '15 at 17:08
  • @CommuSoft Good question! You see, I don't know a better way of doing it, I don't understand how to create a foreach loop that will only loop a certain amount of times :/ – Jermain Defo Feb 15 '15 at 17:10
  • I'm sorry where exactly is the `double-buffering`? If both `StarImage` and `Image2` are always visible on screen then you are really just animating two pictures with a series of stills. –  Feb 15 '15 at 17:17
  • @MickyDuncan Sorry for making it hard to understand but I am trying my own alternative of double-buffering, I am trying to load the odd numbered in 1 image box and make that visible whilst the even numbered is loaded in the other image box if you get what I mean – Jermain Defo Feb 15 '15 at 17:20
  • @JermainDefo Ah I see, goodo –  Feb 15 '15 at 17:34
  • @MickyDuncan Do you think it is a good idea? I don't know any other methods of doing it unfortunately! I was thinking for each image create a new imagebox and place each image in the box and then delete it, but would that be a bad idea? – Jermain Defo Feb 15 '15 at 17:37
  • @JermainDefo I think so. Keep the imageboxes around as they are just containers, the only thing that is changing is the source image in the `Source` property. Adding and removing screen elements (imageboxes, pictureboxes, buttons etc) can cause flicker if not just an expensive exercise anyway. The other alternative is a true double buffer where you render what-ever offscreen then draw the entire offscreen bitmap to the screen in one go. –  Feb 15 '15 at 17:45
  • @MickyDuncan Hmm I've been trying to find the true double buffer but I honestly dont know what it is to know what I am suppose to be looking for – Jermain Defo Feb 15 '15 at 17:50

1 Answers1

1

I am developing a vb project in asp.net with vb. At the beginning time long ago once pictures were show during debugging process. But after on images were not shown in imagebox and imagebutton. finnally I succeeded to publish on the web the project. But I find all images in both imagebox and imagebutton were not shown though correct imageurls were indicated. Perhaps it a bug of new version of ASP.NET 4.6 or otherwise some settings in windows management or IIs is blocking streamings of imagedata to be delivered to client windows system. MS members are updating the platform everyday.... So they will fix it soon...