Example #1
0
        public static void FitFill <TPixel>(this Image <TPixel> target, ITextureSampler <Vector4> sampler) where TPixel : struct, IPixel <TPixel>
        {
            var scale = new Vector2(sampler.Scale.Width / (float)target.Width, sampler.Scale.Height / (float)target.Height);

            for (int dy = 0; dy < target.Height; ++dy)
            {
                var tl = default(UV);
                var tr = default(UV);
                var bl = default(UV);
                var br = default(UV);

                tl.Y = tr.Y = dy;
                bl.Y = br.Y = dy + 1;

                var c = default(TPixel);

                for (int dx = 0; dx < target.Width; ++dx)
                {
                    tl.X = bl.X = dx;
                    tr.X = br.X = dx + 1;

                    var r = sampler.GetAreaSample(tl * scale, tr * scale, br * scale, bl * scale);

                    c.PackFromVector4(r);

                    target[dx, dy] = c;
                }
            }
        }
Example #2
0
        public _PolarTransformedTextureSampler(ITextureSampler <TPixel> source, bool inverse = false) : base(source)
        {
            _Inverse = inverse;
            _Scale   = source.Scale;
            _Center  = _Scale / 2;

            _Center = _Center.RoundDown(); // todo: we could "snap" the _Center of the image to an interpixel cross.
        }
Example #3
0
 public CubemapSampler(ITextureSampler <T> f, ITextureSampler <T> b, ITextureSampler <T> l, ITextureSampler <T> r, ITextureSampler <T> top, ITextureSampler <T> bottom)
 {
     _Front  = f;
     _Back   = b;
     _Left   = l;
     _Right  = r;
     _Top    = top;
     _Bottom = bottom;
 }
Example #4
0
 public static ITextureSampler <Vector4> LerpColor(this ITextureSampler <float> source, IPixel odd, IPixel even)
 {
     return(new _LerpColorSampler(source, odd, even));
 }
Example #5
0
 public static ITextureSampler <HalfSingle> ToHalfSingle(this ITextureSampler <float> source)
 {
     return(new _FloatToHalfSingleSampler(source));
 }
Example #6
0
 public _FloatToHalfSingleSampler(ITextureSampler <float> source)
 {
     _Source = source;
 }
Example #7
0
 public _LerpColorSampler(ITextureSampler <float> source, IPixel odd, IPixel even)
 {
     _Source    = source;
     _OddColor  = odd.ToVector4();
     _EvenColor = even.ToVector4();
 }
Example #8
0
 public static ITextureSampler <TPixel> ToPolarTransform <TPixel>(this ITextureSampler <TPixel> ts, bool inverse)
 {
     return(new _PolarTransformedTextureSampler <TPixel>(ts, inverse));
 }
Example #9
0
 public _TransformedTextureSampler(ITextureSampler <TPixel> source)
 {
     _Source = source;
 }
Example #10
0
 public TextureSamplingManager(TextureSamplingQuality q)
 {
     this.Quality = q;
     if (q == TextureSamplingQuality.Linear)
     {
         this.sampler = new LinearTextureSampler();
     }
     else if (q == TextureSamplingQuality.Nearest)
     {
         this.sampler = new NearestTextureSampler();
     }
 }