Expression > Home page del forum > Deep Zoom Composer > How to arrange images of different sizes into a Grid
Formula una domandaFormula una domanda
 

DomandaHow to arrange images of different sizes into a Grid

  • giovedì 18 giugno 2009 9.38PeriDeepika Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     

    Hi,

    I have a set of about 1000 photos which i have to arrange into Deep Zoom. They are of various sizes.
    In the deep zoom composer i can arrange them in a proper order.
    But when i want to shuffle the images or to sort by tag, the images not being of the same size, are not aligned properly.
    I had earlier tried for images of same sizes and arranged them into a grid format using the following code


            private void ArrangeIntoGrid(List<MultiScaleSubImage> imagesList)
            {
                int totalImagesAdded = 0;
                int imagesCount = imagesList.Count;

                if (imagesCount > 1)
                {
                    columns = 0;
                    columns = (int)Math.Ceiling(Math.Sqrt(imagesCount));
                    rows = imagesCount / (columns - 1);
                    for (int i = 0; i < rows; i++)
                    {
                        for (int j = 0; j < columns; j++)
                        {
                            if (imagesCount != totalImagesAdded)
                            {
                                MultiScaleSubImage currentImage = imagesList[totalImagesAdded];

                                Point currentPosition = currentImage.ViewportOrigin;
                                Point futurePosition = new Point(-1.02 * j, -0.77 * i);

                                //Creating the Animation
                                Storyboard moveStoryboard = new Storyboard();

                                PointAnimationUsingKeyFrames moveAnimation = new PointAnimationUsingKeyFrames();

                                SplinePointKeyFrame startKeyframe = new SplinePointKeyFrame();
                                startKeyframe.Value = currentPosition;
                                startKeyframe.KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero);

                                startKeyframe = new SplinePointKeyFrame();
                                startKeyframe.Value = futurePosition;
                                startKeyframe.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1));

                                KeySpline ks = new KeySpline();
                                ks.ControlPoint1 = new Point(0, 1);
                                ks.ControlPoint2 = new Point(1, 1);
                                startKeyframe.KeySpline = ks;
                                moveAnimation.KeyFrames.Add(startKeyframe);

                                Storyboard.SetTarget(moveAnimation, currentImage);
                                Storyboard.SetTargetProperty(moveAnimation, new PropertyPath("ViewportOrigin"));

                                moveStoryboard.Children.Add(moveAnimation);

                                moveStoryboard.Begin();

                                totalImagesAdded++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    MultiScaleSubImage currentImage = imagesList[0];
                    currentImage.ViewportOrigin = new Point(0, 0);
                }
            }

    This is fine for images of same size, but i am stuck arranging images of different shapes.
    Can anyone help?

    Thanks in advance,

    -Deepika

     

Tutte le risposte