Example #1
0
 public bool ReadPixels(SKPixmap pixmap)
 {
     return(ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, 0, 0, SKTransferFunctionBehavior.Respect));
 }
Example #2
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY)
 {
     return(ReadPixels(pixmap, srcX, srcY, SKImageCachingHint.Allow));
 }
Example #3
0
 public bool ScalePixels(SKPixmap dst, SKFilterQuality quality)
 {
     return(ScalePixels(dst, quality, SKImageCachingHint.Allow));
 }
Example #4
0
 protected override SKData OnEncode(SKPixmap pixmap)
 {
     return(onEncode?.Invoke(pixmap) ?? null);
 }
Example #5
0
 public static SKImage FromPixels(SKPixmap pixmap, SKImageRasterReleaseDelegate releaseProc)
 {
     return(FromPixels(pixmap, releaseProc, null));
 }
 public bool InstallPixels(SKPixmap pixmap)
 {
     return(SkiaApi.sk_bitmap_install_pixels_with_pixmap(Handle, pixmap.Handle));
 }
Example #7
0
 public static bool Resize(SKPixmap dst, SKPixmap src, SKBitmapResizeMethod method)
 {
     return(SkiaApi.sk_bitmapscaler_resize(dst.Handle, src.Handle, method));
 }
Example #8
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY, SKImageCachingHint cachingHint)
 {
     if (pixmap == null)
         throw new ArgumentNullException(nameof(pixmap)); }
Example #9
0
 public static SKImage FromPixels(SKImageInfo info, IntPtr pixels, int rowBytes)
 {
     using (var pixmap = new SKPixmap(info, pixels, rowBytes)) {
         return(FromPixels(pixmap, null, null));
     }
 }
Example #10
0
 public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality)
 {
     using (var pixmap = new SKPixmap()) {
         return(PeekPixels(pixmap) && pixmap.Encode(dst, format, quality));
     }
 }
Example #11
0
 protected abstract SKData OnEncode(SKPixmap pixmap);
Example #12
0
        public bool CopyTo(SKBitmap destination, SKColorType colorType)
        {
            // TODO: instead of working on `destination` directly, we should
            //       create a temporary bitmap and then inject the data

            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            if (!CanCopyTo(colorType))
            {
                return(false);
            }

            SKPixmap srcPM = PeekPixels();

            if (srcPM == null)
            {
                return(false);
            }

            SKImageInfo dstInfo = srcPM.Info.WithColorType(colorType);

            switch (colorType)
            {
            case SKColorType.Rgb565:
                // CopyTo() is not strict on alpha type. Here we set the src to opaque to allow
                // the call to ReadPixels() to succeed and preserve this lenient behavior.
                if (srcPM.AlphaType != SKAlphaType.Opaque)
                {
                    srcPM = srcPM.WithAlphaType(SKAlphaType.Opaque);
                }
                dstInfo.AlphaType = SKAlphaType.Opaque;
                break;

            case SKColorType.RgbaF16:
                // The caller does not have an opportunity to pass a dst color space.
                // Assume that they want linear sRGB.
                dstInfo.ColorSpace = SKColorSpace.CreateSrgbLinear();
                if (srcPM.ColorSpace == null)
                {
                    // We can't do a sane conversion to F16 without a dst color space.
                    // Guess sRGB in this case.
                    srcPM = srcPM.WithColorSpace(SKColorSpace.CreateSrgb());
                }
                break;
            }

            destination.Reset();              // TODO: is this needed?
            if (!destination.TryAllocPixels(dstInfo, colorType == SKColorType.Index8 ? ColorTable : null))
            {
                return(false);
            }

            SKPixmap dstPM = destination.PeekPixels();

            if (dstPM == null)
            {
                return(false);
            }

            // We can't do a sane conversion from F16 without a src color space. Guess sRGB in this case.
            if (srcPM.ColorType == SKColorType.RgbaF16 && dstPM.ColorSpace == null)
            {
                dstPM = dstPM.WithColorSpace(SKColorSpace.CreateSrgb());
            }

            // ReadPixels does not yet support color spaces with parametric transfer functions. This
            // works around that restriction when the color spaces are equal.
            if (colorType != SKColorType.RgbaF16 && srcPM.ColorType != SKColorType.RgbaF16 && dstPM.ColorSpace == srcPM.ColorSpace)
            {
                dstPM = dstPM.WithColorSpace(null);
                srcPM = srcPM.WithColorSpace(null);
            }

            if (!srcPM.ReadPixels(dstPM))
            {
                return(false);
            }

            return(true);
        }
Example #13
0
 public bool ReadPixels(SKPixmap pixmap) =>
 ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, 0, 0);
Example #14
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY) =>
 ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, srcX, srcY);
Example #15
0
 public static SKSurface Create(SKPixmap pixmap, SKSurfaceProps props) =>
 Create(pixmap, new SKSurfaceProperties(props));
Example #16
0
 public bool ReadPixels(SKPixmap pixmap) =>
 ReadPixels(pixmap, 0, 0, SKImageCachingHint.Allow);
Example #17
0
 public static SKSurface Create(SKPixmap pixmap) =>
 Create(pixmap, null);
Example #18
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY) =>
 ReadPixels(pixmap, srcX, srcY, SKImageCachingHint.Allow);
 public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality)
 {
     return(SKPixmap.Encode(dst, this, format, quality));
 }
Example #20
0
 public static SKImage FromPixels(SKPixmap pixmap)
 {
     return(FromPixels(pixmap, null, null));
 }
Example #21
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY)
 {
     return(ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, srcX, srcY));
 }
Example #22
0
 public bool ReadPixels(SKPixmap pixmap)
 {
     return(ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, 0, 0));
 }