Exemplo n.º 1
0
        /* Iterate through each frame, generating the animation frame and copying over
         * all the frames (including keyframes) into the imageB2 path folder.
         */
        private void iterFiles()
        {
            //Get all the image files from the provided directories
            framesA1 = Directory.GetFiles(pathA1);
            framesA2 = Directory.GetFiles(pathA2);
            framesB1 = Directory.GetFiles(pathB1);
            Array.Sort(framesA1);
            Array.Sort(framesA2);
            Array.Sort(framesB1);

            //Set keyframe values
            int          startKeyIndex = 0;
            int          endKeyIndex   = startKeyIndex + 1;
            int          startKeyNum   = parseFrameFromName(framesA1[startKeyIndex]);
            int          endKeyNum     = parseFrameFromName(framesA1[endKeyIndex]);
            ImageAnalogy startAnalogy  = createAnalogy(framesA1[startKeyIndex], framesA2[startKeyIndex]);
            ImageAnalogy endAnalogy    = createAnalogy(framesA1[endKeyIndex], framesA2[endKeyIndex]);

            //Copy the current keyframes to destination directory
            copyFrame(framesA2[startKeyIndex]);
            copyFrame(framesA2[endKeyIndex]);

            //Iterate through the in-between frames, creating a new frame for each
            foreach (string frame in framesB1)
            {
                //Adjust current start and end key frames if the in-between we're on
                //is not between them.
                int currentFrameNum = parseFrameFromName(frame);
                if (currentFrameNum > endKeyNum)
                {
                    startKeyIndex++;
                    endKeyIndex++;

                    //We've reached the end
                    if (endKeyIndex >= framesA1.Count())
                    {
                        return;
                    }

                    //Change values for keyframes
                    startKeyNum  = parseFrameFromName(framesA1[startKeyIndex]);
                    endKeyNum    = parseFrameFromName(framesA1[endKeyIndex]);
                    startAnalogy = endAnalogy;
                    endAnalogy   = createAnalogy(framesA1[endKeyIndex], framesA2[endKeyIndex]);

                    //Make sure keyframes get copied over as the index increases
                    copyFrame(framesA2[endKeyIndex]);
                }

                Utilities.print("CREATING IN-BETWEEN FRAME: " + Path.GetFileName(frame));


                //FOR TESTING PURPOSES WE'RE JUST DOING ONE TO SEE IF WE GET THE SAME RESULTS USING THIS NEW SYSTEM
                Color[,] imageFromStart = createImage(startAnalogy, frame);
                //Color[,] imageFromEnd = createImage(endAnalogy, frame);

                //FOR NOW, BLEND 50-50 BETWEEN START AND END. IN THE FUTURE, WE'LL WEIGHT BASED
                //ON HOW CLSE THE IN BETWEEN IS TO THE START AND END KEYFRAMES
                //Color[,] average = Utilities.averageArrays(imageFromStart, imageFromEnd, 0.50f);
                //writeImage(average, frame);
                writeImage(imageFromStart, frame);
            }
        }
Exemplo n.º 2
0
 /* Creates an animation frame using the provided analogy, image, and parameters */
 private Color[,] createImage(ImageAnalogy ia, string frameB1)
 {
     Color[,] imageB1 = Utilities.createImageArrayFromFile(frameB1);
     Color[,] imageB2 = ia.CreateImageAnalogy(imageB1, randAmount);
     return(imageB2);
 }