예제 #1
0
 public Imaging.BitmapSampler <T> AsBitmapSampler(Imaging.ColorEncoding encoding)
 {
     return(Imaging.BitmapSampler <T> .From(this, encoding));
 }
예제 #2
0
        public static unsafe PixelFormat GetFormat <TPixel>(Imaging.ColorEncoding encoding)
            where TPixel : unmanaged
        {
            if (sizeof(TPixel) == 1)
            {
                if (encoding == Imaging.ColorEncoding.A)
                {
                    return(Pixel.Alpha8.Format);
                }
                return(Pixel.Luminance8.Format);
            }

            if (sizeof(TPixel) == 2)
            {
                return(Pixel.Luminance16.Format);
            }

            if (sizeof(TPixel) == 3)
            {
                if (encoding == Imaging.ColorEncoding.BGR)
                {
                    return(Pixel.BGR24.Format);
                }
                if (encoding == Imaging.ColorEncoding.BGRA)
                {
                    return(Pixel.BGR24.Format);
                }
                return(Pixel.RGB24.Format);
            }

            if (sizeof(TPixel) == 4)
            {
                if (typeof(TPixel) == typeof(float))
                {
                    if (encoding == Imaging.ColorEncoding.L)
                    {
                        return(Pixel.Luminance32F.Format);
                    }
                }
                else
                {
                    if (encoding == Imaging.ColorEncoding.RGB)
                    {
                        return(Pixel.RGBA32.Format);
                    }
                    if (encoding == Imaging.ColorEncoding.BGR)
                    {
                        return(Pixel.BGRA32.Format);
                    }
                    if (encoding == Imaging.ColorEncoding.BGRA)
                    {
                        return(Pixel.BGRA32.Format);
                    }
                    if (encoding == Imaging.ColorEncoding.RGBA)
                    {
                        return(Pixel.RGBA32.Format);
                    }
                    if (encoding == Imaging.ColorEncoding.ARGB)
                    {
                        return(Pixel.ARGB32.Format);
                    }
                }
            }

            if (typeof(TPixel) == typeof(Vector3))
            {
                if (encoding == Imaging.ColorEncoding.BGR)
                {
                    return(Pixel.BGR96F.Format);
                }
                if (encoding == Imaging.ColorEncoding.BGRA)
                {
                    return(Pixel.BGR96F.Format);
                }
                return(Pixel.RGB96F.Format);
            }

            if (typeof(TPixel) == typeof(Vector4))
            {
                if (encoding == Imaging.ColorEncoding.BGR)
                {
                    return(Pixel.BGRA128F.Format);
                }
                if (encoding == Imaging.ColorEncoding.BGRA)
                {
                    return(Pixel.BGRA128F.Format);
                }
                return(Pixel.RGBA128F.Format);
            }

            throw new NotImplementedException();
        }
예제 #3
0
 public Imaging.TensorBitmap <T> AsTensorBitmap(Imaging.ColorEncoding encoding)
 {
     return(new Imaging.TensorBitmap <T>(this, encoding));
 }