Exemple #1
0
        protected override Tuple <Bitmap.Image, Tuple <string, object>[]> Generate(int frame)
        {
            Bitmap.Image result = new Bitmap.Bgra(this.resolution);
            int          width  = result.Size.Width;

            unsafe
            {
                byte *pointer = (byte *)result.Pointer;
                for (int x = 0; x < result.Size.Width; x++)
                {
                    for (int y = 0; y < result.Size.Height; y++)
                    {
                        int    pixel = (x + y * result.Size.Width) * 4;
                        double value =
                            (Math.Sin(Convert.ToSingle((x + frame * 10) % result.Size.Width) / Convert.ToSingle(result.Size.Width) * 2.0 * Math.PI * 7) +
                             Math.Sin(Convert.ToSingle(y) / Convert.ToSingle(result.Size.Height) * 2.0 * Math.PI * 5) + 2.0)
                            / 4.0 * 254.0;
                        byte byteValue = Convert.ToByte(value * (Math.Sin(Convert.ToSingle(y * 0.005 + frame * 0.5)) + 1.0) / 2.0);
                        byte red       = byteValue;
                        byte green     = 0;
                        byte blue      = Convert.ToByte(255 - byteValue);
                        pointer[4 * (y * width + x) + 0] = blue;
                        pointer[4 * (y * width + x) + 1] = green;
                        pointer[4 * (y * width + x) + 2] = red;
                        pointer[4 * (y * width + x) + 3] = 255;
                    }
                }
            }
            return(Tuple.Create <Bitmap.Image, Tuple <string, object>[]>(result, null));
        }
Exemple #2
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;
		}
Exemple #3
0
		protected Bgra(Bgra original) :
			base(original) { }
Exemple #4
0
		public Raster.Image Read()
		{
			Raster.Image result = null;
			switch (this.Type)
			{
				default:
				case TextureType.Rgba:
					result = new Raster.Bgra(this.Size);
					break;
				case TextureType.Rgb:
					result = new Raster.Bgr(this.Size);
					break;
				case TextureType.Monochrome:
					result = new Raster.Monochrome(this.Size);
					break;
			}
			this.Use();
			this.Read(result.Pointer);
			this.UnUse();
			return result;
		}