Example #1
0
		public override Draw.Image Shift(Geometry2D.Integer.Size offset)
		{
			Raster.Image result = null;
			if (this is Monochrome)
				result = new Monochrome(this.Size);
			else if (this is Bgr)
				result = new Bgr(this.Size);
			else if (this is Bgra)
				result = new Bgra(this.Size);
			else if (this is Yuyv)
				result = new Yuyv(this.Size);
			int offsetX = Kean.Math.Integer.Modulo(this is Yuyv && Kean.Math.Integer.Modulo(offset.Width, 2) != 0 ? offset.Width + 1 : offset.Width, this.Size.Width);
			int length = (this.Size.Width - offsetX) * this.BytesPerPixel;
			int line = this.Size.Width * this.BytesPerPixel;
			for (int y = 0; y < this.Size.Height; y++)
				{
					int destination = Kean.Math.Integer.Modulo(y + offset.Height, this.Size.Height) * this.Stride;
					result.Buffer.CopyFrom(this.Buffer, this.Stride * y, destination + offsetX * this.BytesPerPixel, length);
					result.Buffer.CopyFrom(this.Buffer, this.Stride * y + length, destination, line - length);
				}
			return result;
		}
Example #2
0
		protected Yuyv(Yuyv original) :
			base(original) { }