/// <summary> /// Creates a base image with the preset setting of Amplitede and Width /// </summary> /// <param name="basePic">The base for the disordered image</param> /// <returns>The according to the settings disordered image</returns> public override Bitmap StaticPic(Bitmap basePic) { Reset(); Bitmap NewOne = new Bitmap(basePic); //NewOne gets overwritten with the disordered image. //_Breite * i sets the start of the to move setction. //_Breite sets how thick the to move section is. //_IArr[i % 16] says how many pixel to move the image to the right. for (int i = 0; i *_width < NewOne.Height; i++) { NewOne = BitmapEffects.MoveLine((_width * i), _width, _IArr[i % 16] / 2, NewOne, Direction); } if (!EnableTable) { return(NewOne); } using (Graphics g = Graphics.FromImage(NewOne)) { int totalCount = 0; foreach (var entry in EnabledWaveCollection) { int height = entry.LineCount; if (!entry.Value) { if (NewOne.Height <= totalCount + height) { height = NewOne.Height - totalCount; } var rec = Original.Clone(new Rectangle(0, totalCount, NewOne.Width, height), NewOne.PixelFormat); g.DrawImage(rec, 0, totalCount); } totalCount += height; if (totalCount >= NewOne.Height) { break; } } /* * if (totalCount < bm.Height) * g.DrawImage( * _yEffect.Original.Clone(new Rectangle(0, totalCount, bm.Width, (bm.Height - totalCount)), * bm.PixelFormat), 0, totalCount);*/ } return(NewOne); }
public override Bitmap NextAnimateFrame(Bitmap basePic) { Bitmap newBM = new Bitmap(basePic); int offset = 0; foreach (var bar in Bars) { Bitmap single; int index = (int)(bar.Multiplier * Frame) % _frames.Length; if (_frames[index] == null) { single = BitmapEffects.MoveLine(0, basePic.Height, index, basePic, Orientation.Left); _frames[index] = single; } else { single = _frames[index]; } using (Graphics g = Graphics.FromImage(newBM)) { int scanlines = 0; if (offset + bar.Scanline >= basePic.Height) { scanlines = basePic.Height - offset; } else { scanlines = bar.Scanline; } Rectangle rect = new Rectangle(0, offset, basePic.Width, scanlines); g.SetClip(rect); g.Clear(Color.Transparent); //delete the part to be moved before drawing over it. g.ResetClip(); g.DrawImageUnscaled(single.Clone(rect, basePic.PixelFormat), rect); } offset += bar.Scanline; if (offset >= basePic.Height) { break; } } Frame++; return(newBM); }
/// <summary> /// Creates a Bitmap depending on the settings and the internal counter, which also get's increased at the end. /// </summary> /// <param name="basePic">The still (unchanged) image.</param> /// <returns>Depending on the settings moved image.</returns> public override Bitmap NextAnimateFrame(Bitmap basePic) { Bitmap NewOne; try { int index = (int)(Frame * _speed) % _animationFrames.Length; //only calculate new frame if we don't have one yet. if (_animationFrames[index] == null) { NewOne = new Bitmap(basePic); for (int i = 0; i *_width < NewOne.Height; i++) { //NewOne gets overwritten with the disordered image. //_Breite * i sets the start of the to move setction. //_Breite sets how thick the to move section is. //_IArr[(i + _rounds) % 16] says how many pixel to move the image to the right. NewOne = BitmapEffects.MoveLine((_width * i), _width, _IArr[(i + index) % 16] / 2, NewOne, Direction); } _animationFrames[index] = NewOne; } else { //load frame from memory NewOne = _animationFrames[index]; } //SPEED_FACTOR multiplication because _speed < 1. So it would get reeeaaally slow. //_dRounds = (_dRounds + (_speed * SPEED_FACTOR)) % 16; //actual _rounds only increases ever so often due to cast. //_rounds = (int)_dRounds; Frame++; if (!EnableTable) { return(NewOne); } Bitmap img = new Bitmap(NewOne.Width, NewOne.Height); using (Graphics g = Graphics.FromImage(img)) { int totalCount = 0; foreach (var entry in EnabledWaveCollection) { int height = entry.LineCount; Bitmap toUse = entry.Value ? NewOne : basePic; if (img.Height <= totalCount + height) { height = img.Height - totalCount; } var rec = toUse.Clone(new Rectangle(0, totalCount, img.Width, height), toUse.PixelFormat); g.DrawImage(rec, 0, totalCount); totalCount += height; if (totalCount >= img.Height) { break; } } if (totalCount < img.Height) { g.DrawImage( basePic.Clone(new Rectangle(0, totalCount, img.Width, (img.Height - totalCount)), img.PixelFormat), 0, totalCount); } } return(img); } catch (Exception ex) { ThrowExceptionEvent(ex); return(StaticPic(basePic)); } }