コード例 #1
0
 public bool ReadPixels(SKPixmap pixmap)
 {
     return(ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, 0, 0, SKTransferFunctionBehavior.Respect));
 }
コード例 #2
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY)
 {
     return(ReadPixels(pixmap, srcX, srcY, SKImageCachingHint.Allow));
 }
コード例 #3
0
 public bool ScalePixels(SKPixmap dst, SKFilterQuality quality)
 {
     return(ScalePixels(dst, quality, SKImageCachingHint.Allow));
 }
コード例 #4
0
 protected override SKData OnEncode(SKPixmap pixmap)
 {
     return(onEncode?.Invoke(pixmap) ?? null);
 }
コード例 #5
0
 public static SKImage FromPixels(SKPixmap pixmap, SKImageRasterReleaseDelegate releaseProc)
 {
     return(FromPixels(pixmap, releaseProc, null));
 }
コード例 #6
0
 public bool InstallPixels(SKPixmap pixmap)
 {
     return(SkiaApi.sk_bitmap_install_pixels_with_pixmap(Handle, pixmap.Handle));
 }
コード例 #7
0
 public static bool Resize(SKPixmap dst, SKPixmap src, SKBitmapResizeMethod method)
 {
     return(SkiaApi.sk_bitmapscaler_resize(dst.Handle, src.Handle, method));
 }
コード例 #8
0
ファイル: SKImage.cs プロジェクト: gisdevelope/SkiaSharp
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY, SKImageCachingHint cachingHint)
 {
     if (pixmap == null)
         throw new ArgumentNullException(nameof(pixmap)); }
コード例 #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));
     }
 }
コード例 #10
0
 public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality)
 {
     using (var pixmap = new SKPixmap()) {
         return(PeekPixels(pixmap) && pixmap.Encode(dst, format, quality));
     }
 }
コード例 #11
0
 protected abstract SKData OnEncode(SKPixmap pixmap);
コード例 #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);
        }
コード例 #13
0
 public bool ReadPixels(SKPixmap pixmap) =>
 ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, 0, 0);
コード例 #14
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY) =>
 ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, srcX, srcY);
コード例 #15
0
 public static SKSurface Create(SKPixmap pixmap, SKSurfaceProps props) =>
 Create(pixmap, new SKSurfaceProperties(props));
コード例 #16
0
 public bool ReadPixels(SKPixmap pixmap) =>
 ReadPixels(pixmap, 0, 0, SKImageCachingHint.Allow);
コード例 #17
0
 public static SKSurface Create(SKPixmap pixmap) =>
 Create(pixmap, null);
コード例 #18
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY) =>
 ReadPixels(pixmap, srcX, srcY, SKImageCachingHint.Allow);
コード例 #19
0
 public bool Encode(SKWStream dst, SKEncodedImageFormat format, int quality)
 {
     return(SKPixmap.Encode(dst, this, format, quality));
 }
コード例 #20
0
 public static SKImage FromPixels(SKPixmap pixmap)
 {
     return(FromPixels(pixmap, null, null));
 }
コード例 #21
0
 public bool ReadPixels(SKPixmap pixmap, int srcX, int srcY)
 {
     return(ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, srcX, srcY));
 }
コード例 #22
0
 public bool ReadPixels(SKPixmap pixmap)
 {
     return(ReadPixels(pixmap.Info, pixmap.GetPixels(), pixmap.RowBytes, 0, 0));
 }