Пример #1
0
        protected override void RenderEffectByLocation(int numFrames, PixelLocationFrameBuffer frameBuffer)
        {
            var nodes    = frameBuffer.ElementLocations.OrderBy(x => x.X).ThenBy(x => x.Y).GroupBy(x => x.X);
            var bufferHt = BufferHt;
            var bufferWi = BufferWi;

            for (int frame = 0; frame < numFrames; frame++)
            {
                frameBuffer.CurrentFrame = frame;
                _level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
                using (var bitmap = new Bitmap(bufferWi, bufferHt))
                {
                    InitialRender(frame, bitmap, bufferHt, bufferWi);
                    FastPixel.FastPixel fp = new FastPixel.FastPixel(bitmap);
                    fp.Lock();
                    foreach (IGrouping <int, ElementLocation> elementLocations in nodes)
                    {
                        foreach (var elementLocation in elementLocations)
                        {
                            CalculatePixel(elementLocation.X, elementLocation.Y, ref bufferHt, fp, frameBuffer);
                        }
                    }
                    fp.Unlock(false);
                    fp.Dispose();
                }
            }
        }
Пример #2
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            var bufferHt = BufferHt;
            var bufferWi = BufferWi;

            using (var bitmap = new Bitmap(bufferWi, bufferHt))
            {
                InitialRender(frame, bitmap, bufferHt, bufferWi);
                if (_text.Count == 0 && !UseBaseColor)
                {
                    return;
                }
                _level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
                FastPixel.FastPixel fp = new FastPixel.FastPixel(bitmap);
                fp.Lock();
                // copy to frameBuffer
                for (int x = 0; x < bufferWi; x++)
                {
                    for (int y = 0; y < bufferHt; y++)
                    {
                        CalculatePixel(x, y, ref bufferHt, fp, frameBuffer);
                    }
                }
                fp.Unlock(false);
                fp.Dispose();
            }
        }
Пример #3
0
 protected override void CleanUpRender()
 {
     _fp?.Dispose();
     _fp = null;
     if (_reader != null)
     {
         _reader.Close();
         _reader.Dispose();
         _reader = null;
     }
     _processVideo = true;
 }
Пример #4
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (_image == null)
            {
                Logging.Error("Image object is null");
                return;
            }
            var dir = 360 - Direction;
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
            int speedFactor = 4;
            int state = MovementRate * frame;
            if (Type != EffectType.RenderPictureTiles && Type != EffectType.RenderPictureNone)
            {
                _position = ((GetEffectTimeIntervalPosition(frame) * Speed) % 1);
            }
            else if (frame == 0)
            {
                _position = ((GetEffectTimeIntervalPosition(frame + 1) * Speed) % 1);
            }

            CalculateImageNumberByPosition((GetEffectTimeIntervalPosition(frame)*GifSpeed)%1);
            _image.SelectActiveFrame(_dimension, (int) _currentGifImageNum);
            _scaledImage = ScaleToGrid
                ? ScalePictureImage(_image, BufferWi, BufferHt)
                : ScaleImage(_image, (double) ScalePercent/100);

            if (ColorEffect == ColorEffect.GreyScale)
            {
                _scaledImage = (Bitmap) ConvertToGrayScale(_scaledImage);
            }
            _fp = new FastPixel.FastPixel(_scaledImage);

            if (_fp != null)
            {
                int imageWidth = _fp.Width;
                int imageHeight = _fp.Height;
                double deltaX = 0;
                double deltaY = 0;
                double angleOffset;

                if (dir > 45 && dir <= 90)
                    angleOffset = -(dir - 90);
                else if (dir > 90 && dir <= 135)
                    angleOffset = dir - 90;
                else if (dir > 135 && dir <= 180)
                    angleOffset = -(dir - 180);
                else if (dir > 180 && dir <= 225)
                    angleOffset = dir - 180;
                else if (dir > 225 && dir <= 270)
                    angleOffset = -(dir - 270);
                else if (dir > 270 && dir <= 315)
                    angleOffset = dir - 270;
                else if (dir > 315 && dir <= 360)
                    angleOffset = -(dir - 360);
                else
                    angleOffset = dir;

                double imageSpeed = _position*(imageWidth/(Math.Cos((Math.PI/180)*angleOffset)));

                //Moving left and right
                if (dir > 0 && dir <= 90)
                {
                    deltaX = ((double) dir/90)*(imageSpeed);
                }
                else if (dir > 90 && dir <= 180)
                {
                    deltaX = ((double) Math.Abs(dir - 180)/90)*(imageSpeed);
                }
                else if (dir > 180 && dir <= 270)
                {
                    deltaX = -1*(((double) Math.Abs(dir - 180)/90)*(imageSpeed));
                }
                else if (dir > 270 && dir <= 360)
                {
                    deltaX = -1*(((double) Math.Abs(dir - 360)/90)*(imageSpeed));
                }

                //Moving up and down
                if (dir >= 0 && dir <= 90)
                {
                    deltaY = (((double) Math.Abs(dir - 90)/90))*(imageSpeed);
                }
                else if (dir > 90 && dir <= 180)
                {
                    deltaY = -1*(((double) Math.Abs(dir - 90)/90)*(imageSpeed));
                }
                else if (dir > 180 && dir <= 270)
                {
                    deltaY = -1*(((double) Math.Abs(dir - 270)/90)*(imageSpeed));
                }
                else if (dir > 270 && dir <= 360)
                {
                    deltaY = ((double) Math.Abs(270 - dir)/90)*(imageSpeed);
                }

                _movementX += deltaX;
                _movementY += deltaY;

                _fp.Lock();
                Color fpColor = new Color();

                int yoffset = (BufferHt + imageHeight)/2;
                int xoffset = (imageWidth - BufferWi)/2;
                int xOffsetAdj = XOffset*BufferWi/100;
                int yOffsetAdj = YOffset*BufferHt/100;
                int imageHt = imageHeight;
                int imageWi = imageWidth;

                switch (Type)
                {
                    case EffectType.RenderPicturePeekaboo0:
                    case EffectType.RenderPicturePeekaboo180:
                        //Peek a boo
                        yoffset = -(BufferHt) + (int) ((BufferHt + 5)*_position*2);
                        if (yoffset > 10)
                        {
                            yoffset = -yoffset + 10; //reverse direction
                        }
                        else if (yoffset >= -1)
                        {
                            yoffset = -1; //pause in middle
                        }
                        break;
                    case EffectType.RenderPictureWiggle:
                        if (_position >= 0.5)
                        {
                            xoffset += (int) (BufferWi*((1.0 - _position)*2.0 - 0.5));
                        }
                        else
                        {
                            xoffset += (int) (BufferWi*(_position*2.0 - 0.5));
                        }
                        break;
                    case EffectType.RenderPicturePeekaboo90: //peekaboo 90
                    case EffectType.RenderPicturePeekaboo270: //peekaboo 270
                        if (Orientation == StringOrientation.Vertical)
                        {
                            yoffset = (imageHt - BufferWi)/2; //adjust offsets for other axis
                        }
                        else
                        {
                            yoffset = (imageWi - BufferHt)/2; //adjust offsets for other axis
                        }

                        if (Orientation == StringOrientation.Vertical)
                        {
                            xoffset = -(BufferHt) + (int) ((BufferHt + 5)*_position*2);
                        }
                        else
                        {
                            xoffset = -(BufferWi) + (int) ((BufferWi + 5)*_position*2);
                        }
                        if (xoffset > 10)
                        {
                            xoffset = -xoffset + 10; //reverse direction
                        }
                        else if (xoffset >= -1)
                        {
                            xoffset = -1; //pause in middle
                        }

                        break;
                    case EffectType.RenderPictureTiles:
                        imageHt = BufferHt;
                        imageWi = BufferWi;
                        break;

                }
                for (int x = 0; x < imageWi; x++)
                {
                    for (int y = 0; y < imageHt; y++)
                    {
                        if (Type != EffectType.RenderPictureTiles) // change this so only when tiles are disabled
                        {
                            fpColor = _fp.GetPixel(x, y);
                        }

                        var hsv = HSV.FromRGB(fpColor);
                        double tempV = hsv.V*level*((double) (IncreaseBrightness)/10);
                        if (tempV > 1)
                            tempV = 1;
                        hsv.V = tempV;

                        switch (Type)
                        {
                            case EffectType.RenderPicturePeekaboo0:

                                if (fpColor != Color.Transparent)
                                {
                                    //Peek a boo
                                    hsv = CustomColor(hsv, frame, level, fpColor);
                                    frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y + yOffsetAdj, hsv);
                                }
                                break;
                            case EffectType.RenderPictureWiggle:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo90:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, x - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo180:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo270:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - x + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureLeft:
                                // left
                                int leftX = x + (BufferWi - (int) (_position*(imageWi + BufferWi)));
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureRight:
                                // right
                                int rightX = x + -imageWi + (int) (_position*(imageWi + BufferWi));
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUp:
                                // up
                                int upY = (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureUpleft:
                                int upLeftY = (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + BufferWi - (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor) + xOffsetAdj,
                                    upLeftY + yOffsetAdj, hsv);
                                break; // up-left
                            case EffectType.RenderPictureDownleft:
                                int downLeftY = BufferHt + imageHt - (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + BufferWi - (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor) + xOffsetAdj,
                                    downLeftY + yOffsetAdj, hsv);
                                break; // down-left
                            case EffectType.RenderPictureUpright:
                                int upRightY = (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor - imageWi) + xOffsetAdj,
                                    upRightY + yOffsetAdj, hsv);
                                break; // up-right
                            case EffectType.RenderPictureDownright:
                                int downRightY = BufferHt + imageHt - (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor - imageWi) + xOffsetAdj,
                                    downRightY + yOffsetAdj, hsv);
                                break; // down-right
                            case EffectType.RenderPictureDown:
                                // down
                                int downY = (BufferHt + imageHt - 1) - (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureNone:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureTiles:
                                int colorX = x + Convert.ToInt32(_movementX) - (XOffset*BufferWi/100);
                                int colorY = y + Convert.ToInt32(_movementY) + (YOffset*BufferHt/100);

                                if (colorX >= 0)
                                {
                                    colorX = colorX%imageWidth;
                                }
                                else if (colorX < 0)
                                {
                                    colorX = Convert.ToInt32(colorX%imageWidth) + imageWidth - 1;
                                }

                                if (colorY >= 0)
                                {
                                    colorY = Convert.ToInt32((colorY%imageHeight));
                                }
                                else if (colorY < 0)
                                {
                                    colorY = Convert.ToInt32(colorY%imageHeight) + imageHeight - 1;
                                }
                                if (colorX <= _fp.Width && colorY <= _fp.Height)
                                {
                                    fpColor = _fp.GetPixel(colorX, colorY);

                                    hsv = HSV.FromRGB(fpColor);
                                    hsv = CustomColor(hsv, frame, level, fpColor);
                                    frameBuffer.SetPixel(x, BufferHt - y - 1, hsv);
                                }
                                break;
                        }
                    }
                }
                _fp.Unlock(false);
                _fp.Dispose();
                _scaledImage.Dispose();
            }
        }
Пример #5
0
        public void RenderMovie(int dir, string dataFilePath, int movieSpeed)
        {
            const int speedfactor = 4;

            if (_moviePicturesFileList == null || State == 0) {
                LoadMoviePictureFileList(dataFilePath);
            }

            // If we don't have any pictures, do nothing!
            if (_moviePicturesFileList == null || !_moviePicturesFileList.Any())
                return;

            int pictureCount = _moviePicturesFileList.Count;

            if (movieSpeed > 0) {
                currentMovieImageNum += ((movieSpeed*.01) + 1);
            }
            else if (movieSpeed < 0) {
                currentMovieImageNum += (100 + movieSpeed)*.01;
            }
            else {
                currentMovieImageNum++;
            }

            int currentImage = Convert.ToInt32(currentMovieImageNum);
            if (currentImage >= pictureCount || currentImage < 0)
                currentMovieImageNum = currentImage= 0;

            var currentMovieImage = new FastPixel.FastPixel(new Bitmap(Image.FromFile(_moviePicturesFileList[currentImage])));

            int imgwidth = currentMovieImage.Width;
            int imght = currentMovieImage.Height;
            int yoffset = (BufferHt + imght)/2;
            int xoffset = (imgwidth - BufferWi)/2;
            int limit = (dir < 2) ? imgwidth + BufferWi : imght + BufferHt;
            int movement = Convert.ToInt32((State%(limit*speedfactor))/speedfactor);

            // copy image to buffer
            currentMovieImage.Lock();
            Color fpColor = new Color();
            for (int x = 0; x < imgwidth; x++) {
                for (int y = 0; y < imght; y++) {
                    fpColor = currentMovieImage.GetPixel(x, y);
                    if (fpColor != Color.Transparent && fpColor != Color.Black) {
                        switch (dir) {
                            case 1:
                                // left
                                SetPixel(x + BufferWi - movement, yoffset - y, fpColor);
                                break;
                            case 2:
                                // right
                                SetPixel(x + movement - imgwidth, yoffset - y, fpColor);
                                break;
                            case 3:
                                // up
                                SetPixel(x - xoffset, movement - y, fpColor);
                                break;
                            case 4:
                                // down
                                SetPixel(x - xoffset, BufferHt + imght - y - movement, fpColor);
                                break;
                            default:
                                // no movement - centered
                                SetPixel(x - xoffset, yoffset - y, fpColor);
                                break;
                        }
                    }
                }
            }
            currentMovieImage.Unlock(false);
            currentMovieImage.Dispose();
        }
Пример #6
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double position = (GetEffectTimeIntervalPosition(frame) * Speed) % 1;
            double level    = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            // If we don't have any pictures, do nothing!
            if (_moviePicturesFileList == null || !_moviePicturesFileList.Any())
            {
                return;
            }

            int pictureCount = _moviePicturesFileList.Count;

            if (PlayBackSpeed > 0)
            {
                _currentMovieImageNum += ((PlayBackSpeed * .01) + 1);
            }
            else if (PlayBackSpeed < 0)
            {
                _currentMovieImageNum += (100 + PlayBackSpeed) * .01;
            }
            else
            {
                _currentMovieImageNum++;
            }

            int currentImage = Convert.ToInt32(_currentMovieImageNum);

            if (currentImage >= pictureCount || currentImage < 0)
            {
                _currentMovieImageNum = currentImage = 0;
            }

            // copy image to buffer
            Bitmap resizeImage = new Bitmap(Image.FromFile(_moviePicturesFileList[currentImage]));

            FastPixel.FastPixel currentMovieImage = new FastPixel.FastPixel(new Bitmap(resizeImage));

            int imgwidth   = currentMovieImage.Width;
            int imght      = currentMovieImage.Height;
            int yoffset    = (BufferHt + imght) / 2;
            int xoffset    = (imgwidth - BufferWi) / 2;
            int xOffsetAdj = XOffset * BufferWi / 100;
            int yOffsetAdj = YOffset * BufferHt / 100;

            switch (Type)
            {
            case EffectType.RenderPicturePeekaboo0:
            case EffectType.RenderPicturePeekaboo180:
                //Peek a boo
                yoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                if (yoffset > 10)
                {
                    yoffset = -yoffset + 10;                             //reverse direction
                }
                else if (yoffset >= -1)
                {
                    yoffset = -1;                             //pause in middle
                }

                break;

            case EffectType.RenderPictureWiggle:
                if (position >= 0.5)
                {
                    xoffset += (int)(BufferWi * ((1.0 - position) * 2.0 - 0.5));
                }
                else
                {
                    xoffset += (int)(BufferWi * (position * 2.0 - 0.5));
                }
                break;

            case EffectType.RenderPicturePeekaboo90:                     //peekaboo 90
            case EffectType.RenderPicturePeekaboo270:                    //peekaboo 270
                if (Orientation == StringOrientation.Vertical)
                {
                    yoffset = (imght - BufferWi) / 2;                             //adjust offsets for other axis
                    xoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                }
                else
                {
                    yoffset = (imgwidth - BufferHt) / 2;                             //adjust offsets for other axis
                    xoffset = -(BufferWi) + (int)((BufferWi + 5) * position * 2);
                }
                if (xoffset > 10)
                {
                    xoffset = -xoffset + 10;                             //reverse direction
                }
                else if (xoffset >= -1)
                {
                    xoffset = -1;                             //pause in middle
                }

                break;
            }

            currentMovieImage.Lock();
            Color fpColor = new Color();

            for (int x = 0; x < imgwidth; x++)
            {
                for (int y = 0; y < imght; y++)
                {
                    fpColor = currentMovieImage.GetPixel(x, y);
                    if (fpColor != Color.Transparent && fpColor != Color.Black)
                    {
                        var    hsv   = HSV.FromRGB(fpColor);
                        double tempV = hsv.V * level * ((double)(IncreaseBrightness) / 10);
                        if (tempV > 1)
                        {
                            tempV = 1;
                        }
                        hsv.V = tempV;
                        int leftX, rightX, upY, downY;
                        switch (_data.EffectType)
                        {
                        case EffectType.RenderPictureLeft:
                            // left
                            leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));

                            frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureRight:
                            // right
                            rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                            frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureUp:
                            // up
                            upY = (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureDown:
                            // down
                            downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureUpleft:
                            // up-left
                            leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));
                            upY   = (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(leftX + xOffsetAdj, upY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureDownleft:
                            // down-left
                            leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));
                            downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(leftX + xOffsetAdj, downY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureUpright:
                            // up-right
                            upY    = (int)((imght + BufferHt) * position) - y;
                            rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                            frameBuffer.SetPixel(rightX + xOffsetAdj, upY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureDownright:
                            // down-right
                            downY  = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;
                            rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                            frameBuffer.SetPixel(rightX + xOffsetAdj, downY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPicturePeekaboo0:
                            // Peek a boo 0
                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureWiggle:
                            // Wiggle
                            frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPicturePeekaboo90:
                            // Peekaboo90
                            frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, x - yoffset + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPicturePeekaboo180:
                            // Peekaboo180
                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPicturePeekaboo270:
                            // Peekaboo270
                            frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - x + yOffsetAdj, hsv);
                            break;

                        default:
                            // no movement - centered
                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;
                        }
                    }
                }
            }
            currentMovieImage.Unlock(false);
            currentMovieImage.Dispose();
            resizeImage.Dispose();
        }
Пример #7
0
 protected override void CleanUpRender()
 {
     _fp?.Dispose();
     _fp           = null;
     _processVideo = true;
 }
Пример #8
0
        protected override void RenderEffect(int frame, ref PixelFrameBuffer frameBuffer)
        {
            if (_image == null)
            {
                return;
            }
            const int speedfactor = 4;
            double    position    = (GetEffectTimeIntervalPosition(frame) * Speed) % 1;
            double    level       = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            CalculateImageNumberByPosition(position);
            _image.SelectActiveFrame(_dimension, (int)_currentGifImageNum);

            _scaledImage = ScaleToGrid ? ScaleImage(_image, BufferWi, BufferHt) : ScaleImage(_image, _image.Width * ScalePercent / 100, _image.Height * ScalePercent / 100);
            _fp          = new FastPixel.FastPixel(_scaledImage);

            int imgwidth   = _fp.Width;
            int imght      = _fp.Height;
            int yoffset    = (BufferHt + imght) / 2;
            int xoffset    = (imgwidth - BufferWi) / 2;
            int state      = Speed * frame;
            int xOffsetAdj = XOffset * BufferWi / 100;
            int yOffsetAdj = YOffset * BufferHt / 100;

            switch (Type)
            {
            case EffectType.RenderPicturePeekaboo0:
            case EffectType.RenderPicturePeekaboo180:
                //Peek a boo
                yoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                if (yoffset > 10)
                {
                    yoffset = -yoffset + 10;                             //reverse direction
                }
                else if (yoffset >= -1)
                {
                    yoffset = -1;                             //pause in middle
                }

                break;

            case EffectType.RenderPictureWiggle:
                if (position >= 0.5)
                {
                    xoffset += (int)(BufferWi * ((1.0 - position) * 2.0 - 0.5));
                }
                else
                {
                    xoffset += (int)(BufferWi * (position * 2.0 - 0.5));
                }
                break;

            case EffectType.RenderPicturePeekaboo90:                     //peekaboo 90
            case EffectType.RenderPicturePeekaboo270:                    //peekaboo 270
                if (Orientation == StringOrientation.Vertical)
                {
                    yoffset = (imght - BufferWi) / 2;                           //adjust offsets for other axis
                }
                else
                {
                    yoffset = (imgwidth - BufferHt) / 2;                             //adjust offsets for other axis
                }

                if (Orientation == StringOrientation.Vertical)
                {
                    xoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                }
                else
                {
                    xoffset = -(BufferWi) + (int)((BufferWi + 5) * position * 2);
                }
                if (xoffset > 10)
                {
                    xoffset = -xoffset + 10;                             //reverse direction
                }
                else if (xoffset >= -1)
                {
                    xoffset = -1;                             //pause in middle
                }

                break;
            }

            _fp.Lock();
            for (int x = 0; x < imgwidth; x++)
            {
                for (int y = 0; y < imght; y++)
                {
                    //if (!image.IsTransparent(x,y))
                    Color color = _fp.GetPixel(x, y);


                    if (color != Color.Transparent)
                    {
                        var hsv = HSV.FromRGB(color);
                        hsv.V = hsv.V * level;
                        switch (Type)
                        {
                        case EffectType.RenderPictureLeft:
                            // left
                            int leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));

                            frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureRight:
                            // right
                            int rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                            frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureUp:
                            // up
                            int upY = (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureDown:
                            // down
                            int downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureUpleft:
                            int upLeftY = (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(Convert.ToInt32(x + BufferWi - (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor) + xOffsetAdj, upLeftY + yOffsetAdj, hsv);
                            break;                                     // up-left

                        case EffectType.RenderPictureDownleft:
                            int downLeftY = BufferHt + imght - (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(Convert.ToInt32(x + BufferWi - (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor) + xOffsetAdj, downLeftY + yOffsetAdj, hsv);
                            break;                                     // down-left

                        case EffectType.RenderPictureUpright:
                            int upRightY = (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(Convert.ToInt32(x + (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor - imgwidth) + xOffsetAdj, upRightY + yOffsetAdj, hsv);
                            break;                                     // up-right

                        case EffectType.RenderPictureDownright:
                            int downRightY = BufferHt + imght - (int)((imght + BufferHt) * position) - y;

                            frameBuffer.SetPixel(Convert.ToInt32(x + (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor - imgwidth) + xOffsetAdj, downRightY + yOffsetAdj, hsv);
                            break;                                     // down-right

                        case EffectType.RenderPicturePeekaboo0:
                            //Peek a boo
                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPictureWiggle:
                            frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPicturePeekaboo90:
                            frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, x - yoffset + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPicturePeekaboo180:
                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
                            break;

                        case EffectType.RenderPicturePeekaboo270:
                            frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - x + yOffsetAdj, hsv);
                            break;

                        default:
                            // no movement - centered
                            frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                            break;
                        }
                    }
                }
            }
            _fp.Unlock(false);
            _fp.Dispose();
            _scaledImage.Dispose();
        }
Пример #9
0
 /// <inheritdoc />
 protected override void CleanUpRender()
 {
     _fp.Unlock(false);
     _fp.Dispose();
 }
Пример #10
0
		protected override void RenderEffect(int frame, ref PixelFrameBuffer frameBuffer)
		{
			if (_image == null) return;
			const int speedfactor = 4;
			double position = (GetEffectTimeIntervalPosition(frame) * Speed) % 1;
			double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
			
			CalculateImageNumberByPosition(position);
			_image.SelectActiveFrame(_dimension,(int) _currentGifImageNum);
				
			_scaledImage = ScaleToGrid ? ScaleImage(_image, BufferWi, BufferHt) : ScaleImage(_image, _image.Width * ScalePercent / 100, _image.Height * ScalePercent / 100);
			_fp = new FastPixel.FastPixel(_scaledImage);
			
			int imgwidth = _fp.Width;
			int imght = _fp.Height;
			int yoffset = (BufferHt + imght) / 2;
			int xoffset = (imgwidth - BufferWi) / 2;
			int state = Speed * frame;
			int xOffsetAdj = XOffset*BufferWi/100;
			int yOffsetAdj = YOffset*BufferHt/100;

			switch (Type)
			{
				case EffectType.RenderPicturePeekaboo0:
				case EffectType.RenderPicturePeekaboo180:
					//Peek a boo
					yoffset = -(BufferHt) + (int)((BufferHt+5)*position*2);
					if (yoffset > 10)
					{
						yoffset = -yoffset + 10; //reverse direction
					}
					else if (yoffset >= -1)
					{
						yoffset = -1; //pause in middle
					}
					
					break;
				case EffectType.RenderPictureWiggle:
					if (position >= 0.5)
					{
						xoffset += (int)(BufferWi * ((1.0 - position) * 2.0 - 0.5));
					}
					else
					{
						xoffset += (int)(BufferWi * (position * 2.0 - 0.5));
					}
					break;
				case EffectType.RenderPicturePeekaboo90: //peekaboo 90
				case EffectType.RenderPicturePeekaboo270: //peekaboo 270
					if (Orientation == StringOrientation.Vertical)
					{
						yoffset = (imght - BufferWi)/2; //adjust offsets for other axis
					}
					else
					{
						yoffset = (imgwidth - BufferHt) / 2; //adjust offsets for other axis	
					}

					if (Orientation == StringOrientation.Vertical)
					{
						xoffset = -(BufferHt) + (int) ((BufferHt + 5)*position*2);
					}
					else
					{
						xoffset = -(BufferWi) + (int)((BufferWi + 5) * position * 2);
					}
					if (xoffset > 10)
					{
						xoffset = -xoffset + 10; //reverse direction
					}
					else if (xoffset >= -1)
					{
						xoffset = -1; //pause in middle
					}
					
					break;
			}

			_fp.Lock();
			for (int x = 0; x < imgwidth; x++)
			{
				for (int y = 0; y < imght; y++)
				{
					//if (!image.IsTransparent(x,y))
					Color color = _fp.GetPixel(x, y);
					

					if (color != Color.Transparent)
					{
						var hsv = HSV.FromRGB(color);
						hsv.V = hsv.V * level;
						switch (Type)
						{
							case EffectType.RenderPictureLeft:
								// left
								int leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));
								
								frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
								break;
							case EffectType.RenderPictureRight:
								// right
								int rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));
								
								frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
								break;
							case EffectType.RenderPictureUp:
								// up
								int upY = (int)((imght + BufferHt) *position) - y;
								
								frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
								break;
							case EffectType.RenderPictureDown:
								// down
								int downY = (BufferHt + imght-1)  - (int)((imght + BufferHt) * position) - y;
								
								frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY+yOffsetAdj, hsv);
								break;
							case EffectType.RenderPictureUpleft:
								int upLeftY = (int)((imght + BufferHt) * position) - y;
								
								frameBuffer.SetPixel(Convert.ToInt32(x + BufferWi - (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor) + xOffsetAdj, upLeftY+yOffsetAdj, hsv);
								break; // up-left
							case EffectType.RenderPictureDownleft:
								int downLeftY = BufferHt + imght - (int)((imght + BufferHt) * position) - y;
								
								frameBuffer.SetPixel(Convert.ToInt32(x + BufferWi - (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor) + xOffsetAdj, downLeftY+yOffsetAdj, hsv);
								break; // down-left
							case EffectType.RenderPictureUpright:
								int upRightY = (int)((imght + BufferHt) * position) - y;
								
								frameBuffer.SetPixel(Convert.ToInt32(x + (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor - imgwidth)+xOffsetAdj, upRightY+yOffsetAdj, hsv);
								break; // up-right
							case EffectType.RenderPictureDownright:
								int downRightY = BufferHt + imght - (int)((imght + BufferHt) * position) - y;
								
								frameBuffer.SetPixel(Convert.ToInt32(x + (state % ((imgwidth + BufferWi) * speedfactor)) / speedfactor - imgwidth) + xOffsetAdj, downRightY+yOffsetAdj, hsv);
								break; // down-right
							case EffectType.RenderPicturePeekaboo0:
								//Peek a boo
								frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y+yOffsetAdj, hsv);
								break;
							case EffectType.RenderPictureWiggle:
								frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
								break;
							case EffectType.RenderPicturePeekaboo90:
								frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, x - yoffset + yOffsetAdj, hsv);	
								break;
							case EffectType.RenderPicturePeekaboo180:
								frameBuffer.SetPixel(x - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
								break;
							case EffectType.RenderPicturePeekaboo270:
								frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - x + yOffsetAdj, hsv);
								break;
							default:
								// no movement - centered
								frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
								break;
						}
					}
				}
			}
			_fp.Unlock(false);
			_fp.Dispose();
			_scaledImage.Dispose();
		}
Пример #11
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double position = (GetEffectTimeIntervalPosition(frame) * Speed) % 1;
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            // If we don't have any pictures, do nothing!
            if (_moviePicturesFileList == null || !_moviePicturesFileList.Any())
                return;

            int pictureCount = _moviePicturesFileList.Count;

            if (PlayBackSpeed > 0)
            {
                _currentMovieImageNum += ((PlayBackSpeed * .01) + 1);
            }
            else if (PlayBackSpeed < 0)
            {
                _currentMovieImageNum += (100 + PlayBackSpeed) * .01;
            }
            else
            {
                _currentMovieImageNum ++;
            }

            int currentImage = Convert.ToInt32(_currentMovieImageNum);
            if (currentImage >= pictureCount || currentImage < 0)
                _currentMovieImageNum = currentImage = 0;

            // copy image to buffer
            Bitmap resizeImage = new Bitmap(Image.FromFile(_moviePicturesFileList[currentImage]));
            FastPixel.FastPixel currentMovieImage = new FastPixel.FastPixel(new Bitmap(resizeImage));

            int imgwidth = currentMovieImage.Width;
            int imght = currentMovieImage.Height;
            int yoffset = (BufferHt + imght) / 2;
            int xoffset = (imgwidth - BufferWi) / 2;
            int xOffsetAdj = XOffset * BufferWi / 100;
            int yOffsetAdj = YOffset * BufferHt / 100;

            switch (Type)
            {
                case EffectType.RenderPicturePeekaboo0:
                case EffectType.RenderPicturePeekaboo180:
                    //Peek a boo
                    yoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                    if (yoffset > 10)
                    {
                        yoffset = -yoffset + 10; //reverse direction
                    }
                    else if (yoffset >= -1)
                    {
                        yoffset = -1; //pause in middle
                    }

                    break;
                case EffectType.RenderPictureWiggle:
                    if (position >= 0.5)
                    {
                        xoffset += (int)(BufferWi * ((1.0 - position) * 2.0 - 0.5));
                    }
                    else
                    {
                        xoffset += (int)(BufferWi * (position * 2.0 - 0.5));
                    }
                    break;
                case EffectType.RenderPicturePeekaboo90: //peekaboo 90
                case EffectType.RenderPicturePeekaboo270: //peekaboo 270
                    if (Orientation == StringOrientation.Vertical)
                    {
                        yoffset = (imght - BufferWi) / 2; //adjust offsets for other axis
                        xoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                    }
                    else
                    {
                        yoffset = (imgwidth - BufferHt) / 2; //adjust offsets for other axis
                        xoffset = -(BufferWi) + (int)((BufferWi + 5) * position * 2);
                    }
                    if (xoffset > 10)
                    {
                        xoffset = -xoffset + 10; //reverse direction
                    }
                    else if (xoffset >= -1)
                    {
                        xoffset = -1; //pause in middle
                    }

                    break;
            }

            currentMovieImage.Lock();
            Color fpColor = new Color();
            for (int x = 0; x < imgwidth; x++)
            {
                for (int y = 0; y < imght; y++)
                {
                    fpColor = currentMovieImage.GetPixel(x, y);
                    if (fpColor != Color.Transparent && fpColor != Color.Black)
                    {
                        var hsv = HSV.FromRGB(fpColor);
                        double tempV = hsv.V * level * ((double)(IncreaseBrightness)/10);
                        if (tempV > 1)
                            tempV = 1;
                        hsv.V = tempV;
                        int leftX, rightX, upY, downY;
                        switch (_data.EffectType)
                        {
                            case EffectType.RenderPictureLeft:
                                // left
                                leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));

                                frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureRight:
                                // right
                                rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                                frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUp:
                                // up
                                upY = (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureDown:
                                // down
                                downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUpleft:
                                // up-left
                                leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));
                                upY = (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(leftX + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureDownleft:
                                // down-left
                                leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));
                                downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(leftX + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUpright:
                                // up-right
                                upY = (int)((imght + BufferHt) * position) - y;
                                rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                                frameBuffer.SetPixel(rightX + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureDownright:
                                // down-right
                                downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;
                                rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                                frameBuffer.SetPixel(rightX + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo0:
                                // Peek a boo 0
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureWiggle:
                                // Wiggle
                                frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo90:
                                // Peekaboo90
                                frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, x - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo180:
                                // Peekaboo180
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo270:
                                // Peekaboo270
                                frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - x + yOffsetAdj, hsv);
                                break;
                            default:
                                // no movement - centered
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                        }
                    }
                }
            }
            currentMovieImage.Unlock(false);
            currentMovieImage.Dispose();
            resizeImage.Dispose();
        }
Пример #12
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (_image != null)
            {
                var    dir                = 360 - Direction;
                var    intervalPos        = GetEffectTimeIntervalPosition(frame);
                var    intervalPosFactor  = intervalPos * 100;
                double level              = LevelCurve.GetValue(intervalPosFactor) / 100;
                double adjustedBrightness = (double)(CalculateIncreaseBrightness(intervalPosFactor)) / 10;

                int speedFactor = 4;
                int state       = MovementRate * frame;
                if (Type != EffectType.RenderPictureTiles && Type != EffectType.RenderPictureNone)
                {
                    _position = ((GetEffectTimeIntervalPosition(frame) * Speed) % 1);
                }
                else if (frame == 0)
                {
                    _position = ((GetEffectTimeIntervalPosition(frame + 1) * Speed) % 1);
                }

                CalculateImageNumberByPosition((GetEffectTimeIntervalPosition(frame) * GifSpeed) % 1);
                _image.SelectActiveFrame(_dimension, (int)_currentGifImageNum);
                _scaledImage = ScaleToGrid
                                        ? ScalePictureImage(_image, BufferWi, BufferHt)
                                        : ScaleImage(_image, (double)ScalePercent / 100);

                if (ColorEffect == ColorEffect.GreyScale)
                {
                    _scaledImage = (Bitmap)ConvertToGrayScale(_scaledImage);
                }
                _fp = new FastPixel.FastPixel(_scaledImage);

                if (_fp != null)
                {
                    int    imageWidth  = _fp.Width;
                    int    imageHeight = _fp.Height;
                    double deltaX      = 0;
                    double deltaY      = 0;
                    double angleOffset;

                    if (dir > 45 && dir <= 90)
                    {
                        angleOffset = -(dir - 90);
                    }
                    else if (dir > 90 && dir <= 135)
                    {
                        angleOffset = dir - 90;
                    }
                    else if (dir > 135 && dir <= 180)
                    {
                        angleOffset = -(dir - 180);
                    }
                    else if (dir > 180 && dir <= 225)
                    {
                        angleOffset = dir - 180;
                    }
                    else if (dir > 225 && dir <= 270)
                    {
                        angleOffset = -(dir - 270);
                    }
                    else if (dir > 270 && dir <= 315)
                    {
                        angleOffset = dir - 270;
                    }
                    else if (dir > 315 && dir <= 360)
                    {
                        angleOffset = -(dir - 360);
                    }
                    else
                    {
                        angleOffset = dir;
                    }

                    double imageSpeed = _position * (imageWidth / (Math.Cos((Math.PI / 180) * angleOffset)));

                    //Moving left and right
                    if (dir > 0 && dir <= 90)
                    {
                        deltaX = ((double)dir / 90) * (imageSpeed);
                    }
                    else if (dir > 90 && dir <= 180)
                    {
                        deltaX = ((double)Math.Abs(dir - 180) / 90) * (imageSpeed);
                    }
                    else if (dir > 180 && dir <= 270)
                    {
                        deltaX = -1 * (((double)Math.Abs(dir - 180) / 90) * (imageSpeed));
                    }
                    else if (dir > 270 && dir <= 360)
                    {
                        deltaX = -1 * (((double)Math.Abs(dir - 360) / 90) * (imageSpeed));
                    }

                    //Moving up and down
                    if (dir >= 0 && dir <= 90)
                    {
                        deltaY = (((double)Math.Abs(dir - 90) / 90)) * (imageSpeed);
                    }
                    else if (dir > 90 && dir <= 180)
                    {
                        deltaY = -1 * (((double)Math.Abs(dir - 90) / 90) * (imageSpeed));
                    }
                    else if (dir > 180 && dir <= 270)
                    {
                        deltaY = -1 * (((double)Math.Abs(dir - 270) / 90) * (imageSpeed));
                    }
                    else if (dir > 270 && dir <= 360)
                    {
                        deltaY = ((double)Math.Abs(270 - dir) / 90) * (imageSpeed);
                    }

                    _movementX += deltaX;
                    _movementY += deltaY;

                    _fp.Lock();
                    Color fpColor = new Color();

                    int yoffset    = (BufferHt + imageHeight) / 2;
                    int xoffset    = (imageWidth - BufferWi) / 2;
                    int xOffsetAdj = CalculateXOffset(intervalPosFactor) * BufferWi / 100;
                    int yOffsetAdj = CalculateYOffset(intervalPosFactor) * BufferHt / 100;
                    int imageHt    = imageHeight;
                    int imageWi    = imageWidth;

                    switch (Type)
                    {
                    case EffectType.RenderPicturePeekaboo0:
                    case EffectType.RenderPicturePeekaboo180:
                        //Peek a boo
                        yoffset = -(BufferHt) + (int)((BufferHt + 5) * _position * 2);
                        if (yoffset > 10)
                        {
                            yoffset = -yoffset + 10;                                     //reverse direction
                        }
                        else if (yoffset >= -1)
                        {
                            yoffset = -1;                                     //pause in middle
                        }
                        break;

                    case EffectType.RenderPictureWiggle:
                        if (_position >= 0.5)
                        {
                            xoffset += (int)(BufferWi * ((1.0 - _position) * 2.0 - 0.5));
                        }
                        else
                        {
                            xoffset += (int)(BufferWi * (_position * 2.0 - 0.5));
                        }
                        break;

                    case EffectType.RenderPicturePeekaboo90:                             //peekaboo 90
                    case EffectType.RenderPicturePeekaboo270:                            //peekaboo 270
                        if (Orientation == StringOrientation.Vertical)
                        {
                            yoffset = (imageHt - BufferWi) / 2;                                   //adjust offsets for other axis
                        }
                        else
                        {
                            yoffset = (imageWi - BufferHt) / 2;                                   //adjust offsets for other axis
                        }

                        if (Orientation == StringOrientation.Vertical)
                        {
                            xoffset = -(BufferHt) + (int)((BufferHt + 5) * _position * 2);
                        }
                        else
                        {
                            xoffset = -(BufferWi) + (int)((BufferWi + 5) * _position * 2);
                        }
                        if (xoffset > 10)
                        {
                            xoffset = -xoffset + 10;                                     //reverse direction
                        }
                        else if (xoffset >= -1)
                        {
                            xoffset = -1;                                     //pause in middle
                        }

                        break;

                    case EffectType.RenderPictureTiles:
                        imageHt = BufferHt;
                        imageWi = BufferWi;
                        break;
                    }
                    for (int x = 0; x < imageWi; x++)
                    {
                        for (int y = 0; y < imageHt; y++)
                        {
                            if (Type != EffectType.RenderPictureTiles)                             // change this so only when tiles are disabled
                            {
                                fpColor = _fp.GetPixel(x, y);
                            }

                            var    hsv   = HSV.FromRGB(fpColor);
                            double tempV = hsv.V * level * adjustedBrightness;
                            if (tempV > 1)
                            {
                                tempV = 1;
                            }
                            hsv.V = tempV;

                            switch (Type)
                            {
                            case EffectType.RenderPicturePeekaboo0:

                                if (fpColor != Color.Transparent)
                                {
                                    //Peek a boo
                                    hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                    frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y + yOffsetAdj, hsv);
                                }
                                break;

                            case EffectType.RenderPictureWiggle:
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPicturePeekaboo90:
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, BufferHt - x - yoffset + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPicturePeekaboo180:
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                if (StringOrientation == StringOrientation.Vertical)
                                {
                                    frameBuffer.SetPixel((BufferWi - x) - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
                                }
                                else
                                {
                                    frameBuffer.SetPixel((BufferWi - x) - xoffset + xOffsetAdj - (BufferWi / 2), y - yoffset + yOffsetAdj, hsv);
                                }

                                break;

                            case EffectType.RenderPicturePeekaboo270:
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - (BufferHt - x) + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureLeft:
                                // left
                                int leftX = x + (BufferWi - (int)(_position * (imageWi + BufferWi)));
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureRight:
                                // right
                                int rightX = x + -imageWi + (int)(_position * (imageWi + BufferWi));
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureUp:
                                // up
                                int upY = (int)((imageHt + BufferHt) * _position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureUpleft:
                                int upLeftY = (int)((imageHt + BufferHt) * _position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + BufferWi - (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor) + xOffsetAdj,
                                    upLeftY + yOffsetAdj, hsv);
                                break;                                         // up-left

                            case EffectType.RenderPictureDownleft:
                                int downLeftY = BufferHt + imageHt - (int)((imageHt + BufferHt) * _position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + BufferWi - (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor) + xOffsetAdj,
                                    downLeftY + yOffsetAdj, hsv);
                                break;                                         // down-left

                            case EffectType.RenderPictureUpright:
                                int upRightY = (int)((imageHt + BufferHt) * _position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor - imageWi) + xOffsetAdj,
                                    upRightY + yOffsetAdj, hsv);
                                break;                                         // up-right

                            case EffectType.RenderPictureDownright:
                                int downRightY = BufferHt + imageHt - (int)((imageHt + BufferHt) * _position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor - imageWi) + xOffsetAdj,
                                    downRightY + yOffsetAdj, hsv);
                                break;                                         // down-right

                            case EffectType.RenderPictureDown:
                                // down
                                int downY = (BufferHt + imageHt - 1) - (int)((imageHt + BufferHt) * _position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureNone:
                                hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureTiles:
                                int colorX = x + Convert.ToInt32(_movementX) - (xOffsetAdj * BufferWi / 100);
                                int colorY = y + Convert.ToInt32(_movementY) + (yOffsetAdj * BufferHt / 100);

                                if (colorX >= 0)
                                {
                                    colorX = colorX % imageWidth;
                                }
                                else if (colorX < 0)
                                {
                                    colorX = Convert.ToInt32(colorX % imageWidth) + imageWidth - 1;
                                }

                                if (colorY >= 0)
                                {
                                    colorY = Convert.ToInt32((colorY % imageHeight));
                                }
                                else if (colorY < 0)
                                {
                                    colorY = Convert.ToInt32(colorY % imageHeight) + imageHeight - 1;
                                }
                                if (colorX <= _fp.Width && colorY <= _fp.Height)
                                {
                                    fpColor = _fp.GetPixel(colorX, colorY);

                                    hsv = HSV.FromRGB(fpColor);
                                    hsv = CustomColor(hsv, frame, level, fpColor, adjustedBrightness);
                                    frameBuffer.SetPixel(x, BufferHt - y - 1, hsv);
                                }
                                break;
                            }
                        }
                    }
                    _fp.Unlock(false);
                    _fp.Dispose();
                    _scaledImage.Dispose();
                }
            }
        }