Exemplo n.º 1
0
        public static bool TryGetPixelFormat(STBWRITE.ColorComponents components, out PixelFormat fmt)
        {
            switch (components)
            {
            case STBWRITE.ColorComponents.Grey: fmt = Pixel.Luminance8.Format; return(true);

            //case STBREAD.ColorComponents.GreyAlpha:;
            case STBWRITE.ColorComponents.RedGreenBlue: fmt = Pixel.RGB24.Format; return(true);

            case STBWRITE.ColorComponents.RedGreenBlueAlpha: fmt = Pixel.RGBA32.Format; return(true);
            }

            fmt = default;
            return(false);
        }
Exemplo n.º 2
0
        private static bool _ExtractPixels(SpanBitmap bmp, out BitmapInfo rinfo, out Byte[] rdata, out STBWRITE.ColorComponents rcmps)
        {
            rinfo = default;
            rdata = null;
            rcmps = default;

            rcmps = _Implementation.GetCompatibleFormat(bmp.PixelFormat);
            if (!_Implementation.TryGetPixelFormat(rcmps, out var rfmt))
            {
                return(false);
            }

            rinfo = new BitmapInfo(bmp.Width, bmp.Height, rfmt);
            rdata = new Byte[rinfo.BitmapByteSize];

            new SpanBitmap(rdata, rinfo).SetPixels(0, 0, bmp);

            return(true);
        }