public static bool Resize(SKBitmap dst, SKBitmap src, SKBitmapResizeMethod method) { using (var srcPix = src.PeekPixels()) using (var dstPix = dst.PeekPixels()) { return(SKPixmap.Resize(dstPix, srcPix, method)); // && dst.InstallPixels (dstPix); } }
public static SKBitmap ResizeBitmap( [InputPin(PropertyMode = PropertyMode.Never)] SKBitmap bitmap, [InputPin(PropertyMode = PropertyMode.Default)] int width = 256, [InputPin(PropertyMode = PropertyMode.Default)] int height = 256, [InputPin(PropertyMode = PropertyMode.Default)] SKBitmapResizeMethod method = SKBitmapResizeMethod.Lanczos3 ) { if (bitmap.ColorType != SKImageInfo.PlatformColorType) { using (var platformBitmap = new SKBitmap()) { if (!bitmap.CopyTo(platformBitmap, SKImageInfo.PlatformColorType)) { throw new Exception($"Could not convert input image ({bitmap.ColorType}) to SKIA platform color type ({SKImageInfo.PlatformColorType})."); } var destinationInfo = platformBitmap.Info; destinationInfo.Width = width; destinationInfo.Height = height; return(platformBitmap.Resize(destinationInfo, method)); } } else { SKBitmap result = new SKBitmap(width, height, bitmap.ColorType, bitmap.AlphaType); bitmap.Resize(result, method); return(result); } }
protected override Task OnInit() { methods = Enum.GetValues(typeof(SKBitmapResizeMethod)).Cast <SKBitmapResizeMethod>().ToList(); method = methods[0]; using (var stream = new SKManagedStream(SampleMedia.Images.AdobeDng)) { bitmap = SKBitmap.Decode(stream); } return(base.OnInit()); }
public static bool Resize(SKPixmap dst, SKPixmap src, SKBitmapResizeMethod method) { if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (src == null) { throw new ArgumentNullException(nameof(src)); } return(src.ScalePixels(dst, method.ToFilterQuality())); }
protected override void OnTapped() { var idx = methods.IndexOf(method) + 1; if (idx >= methods.Count) { idx = 0; } method = methods[idx]; Refresh(); base.OnTapped(); }
public SKBitmap Resize(SKImageInfo info, SKBitmapResizeMethod method) { var dst = new SKBitmap(info); var result = Resize(dst, this, method); if (result) { return(dst); } else { dst.Dispose(); return(null); } }
public static SKFilterQuality ToFilterQuality (this SKBitmapResizeMethod method) { switch (method) { case SKBitmapResizeMethod.Box: case SKBitmapResizeMethod.Triangle: return SKFilterQuality.Low; case SKBitmapResizeMethod.Lanczos3: return SKFilterQuality.Medium; case SKBitmapResizeMethod.Hamming: case SKBitmapResizeMethod.Mitchell: return SKFilterQuality.High; default: return SKFilterQuality.Medium; } }
protected override Task OnInit() { methods = new List <SKBitmapResizeMethod> { SKBitmapResizeMethod.Box, SKBitmapResizeMethod.Triangle, SKBitmapResizeMethod.Lanczos3, SKBitmapResizeMethod.Hamming, SKBitmapResizeMethod.Mitchell, }; method = methods[0]; using (var stream = new SKManagedStream(SampleMedia.Images.Baboon)) { bitmap = SKBitmap.Decode(stream); } return(base.OnInit()); }
public bool Resize(SKBitmap dst, SKBitmapResizeMethod method) { return(Resize(dst, this, method)); }
static bool ResizeImageAndEncode(SKBitmap originalImg, int width, int height, SKBitmapResizeMethod resizeMethod, SKEncodedImageFormat format, int quality, Stream outStream) { using (var scaled = originalImg.Resize(new SKImageInfo(width, height), resizeMethod)) { using (var stream = new SKManagedWStream(outStream)) { return(scaled.Encode(stream, format, quality)); } } }
public static bool Resize(SKPixmap dst, SKPixmap src, SKBitmapResizeMethod method) { return(SkiaApi.sk_bitmapscaler_resize(dst.Handle, src.Handle, method)); }
public static bool Resize(SKBitmap dst, SKBitmap src, SKBitmapResizeMethod method) => src.ScalePixels(dst, method.ToFilterQuality());
public SKBitmap Resize(SKImageInfo info, SKBitmapResizeMethod method) => Resize(info, method.ToFilterQuality());