public void Create(Image image, int width, int height, ImageInterpolation interpolation) { var source = image.ToSD(); var hasAlpha = (source.Flags & (int)sdi.ImageFlags.HasAlpha) != 0; var pixelFormat = source.PixelFormat; if ( pixelFormat == sdi.PixelFormat.Indexed || pixelFormat == sdi.PixelFormat.Format1bppIndexed || pixelFormat == sdi.PixelFormat.Format4bppIndexed || pixelFormat == sdi.PixelFormat.Format8bppIndexed) { pixelFormat = hasAlpha ? sdi.PixelFormat.Format32bppArgb : sdi.PixelFormat.Format32bppRgb; } Control = new sd.Bitmap(width, height, pixelFormat); using (var graphics = sd.Graphics.FromImage(Control)) { graphics.InterpolationMode = interpolation.ToSD(); var rect = new sd.Rectangle(0, 0, width, height); if (hasAlpha) { graphics.Clear(sd.Color.Transparent); } graphics.DrawImage(source, rect); } }
public void DrawImage(Image image, float x, float y, float width, float height) { SetOffset(true); var bmp = image.ToDx(Control); Control.DrawBitmap(bmp, new s.RectangleF(x, y, width, height), 1f, ImageInterpolation.ToDx()); }
public void CreateFromImage(Bitmap image) { Control = SD.Graphics.FromImage((SD.Image)image.ControlObject); Control.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; this.Control.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; this.ImageInterpolation = Eto.Drawing.ImageInterpolation.Default; }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { var source = image.ToUI(); // todo: use interpolation Control = source.Scale(new SD.SizeF(width, height), 0f); }
static Volume <byte> Scaled(Volume <byte> source, V2d scaleFactor, ImageInterpolation ip = ImageInterpolation.Cubic) { var targetSize = (new V2d(0.5, 0.5) + scaleFactor * (V2d)source.Size.XY).ToV2l(); var target = new V3l(targetSize.X, targetSize.Y, source.Size.Z).CreateImageVolume <byte>(); for (int c = 0; c < source.Size.Z; c++) { var targetMat = target.SubXYMatrixWindow(0); var sourceMat = source.SubXYMatrixWindow(0); switch (ip) { case ImageInterpolation.Near: targetMat.SetScaledNearest(sourceMat); break; case ImageInterpolation.Linear: targetMat.SetScaledLinear(sourceMat, (s, a, b) => (byte)s.Lerp(a, b), (s, a, b) => (byte)s.Lerp(a, b)); break; case ImageInterpolation.Cubic: targetMat.SetScaledCubic(sourceMat); break; case ImageInterpolation.Lanczos: targetMat.SetScaledLanczos(sourceMat); break; default: throw new NotImplementedException(); } } return(target); }
public void DrawImage(Image image, float x, float y, float width, float height) { SetOffset(true); var bmp = image.ToDx(Control, Size.Ceiling(CurrentTransform.TransformSize(new SizeF(width, height)))); Control.DrawBitmap(bmp, new s.RectangleF(x, y, width, height), 1f, ImageInterpolation.ToDx()); }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { var source = image.ToSD(); Control = new SD.Bitmap(width, height, source.PixelFormat); using (var graphics = SD.Graphics.FromImage(Control)) { graphics.InterpolationMode = interpolation.ToSD(); var rect = new SD.Rectangle(0, 0, width, height); graphics.FillRectangle(SD.Brushes.Transparent, rect); graphics.DrawImage(source, rect); } }
public static NSImageRep Resize(this NSImageRep image, CGSize newsize, ImageInterpolation interpolation = ImageInterpolation.Default, CGSize? imageSize = null) { var newrep = new NSBitmapImageRep(IntPtr.Zero, (nint)newsize.Width, (nint)newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * (nint)newsize.Width, 32); newrep.Size = imageSize ?? newsize; var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG(); image.DrawInRect(new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, NSCompositingOperation.SourceOver, 1f, true, DrawHints); NSGraphicsContext.GlobalRestoreGraphicsState(); return newrep; }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { var imageHandler = (ImageHandler <TWidget>)image.Handler; Control = new sw.Bitmap(SDFactory.WicImagingFactory, width, height, imageHandler.Control.PixelFormat, sw.BitmapCreateCacheOption.CacheOnLoad); using (var graphics = new Graphics(Widget as Bitmap)) { graphics.ImageInterpolation = interpolation; var rect = new Rectangle(0, 0, width, height); graphics.FillRectangle(Colors.Transparent, rect); graphics.DrawImage(image, rect); } }
public static NSImage Resize(this NSImage image, sd.Size newsize, ImageInterpolation interpolation = ImageInterpolation.Default) { var newimage = new NSImage(newsize); var newrep = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32); newimage.AddRepresentation(newrep); var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG(); image.DrawInRect(new sd.RectangleF(sd.PointF.Empty, newimage.Size), new sd.RectangleF(sd.PointF.Empty, image.Size), NSCompositingOperation.SourceOver, 1f); NSGraphicsContext.GlobalRestoreGraphicsState(); return newimage; }
public static NSImageRep Resize(this NSImageRep image, CGSize newsize, ImageInterpolation interpolation = ImageInterpolation.Default, CGSize?imageSize = null) { var newrep = new NSBitmapImageRep(IntPtr.Zero, (nint)newsize.Width, (nint)newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * (nint)newsize.Width, 32); newrep.Size = imageSize ?? newsize; var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG(); image.DrawInRect(new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, NSCompositingOperation.SourceOver, 1f, true, DrawHints); NSGraphicsContext.GlobalRestoreGraphicsState(); return(newrep); }
Control CreateImage(ImageInterpolation interpolation) { var image = TestIcons.TestImage; var drawable = new Drawable { Size = new Size(250, 160) }; drawable.Paint += (sender, pe) => { pe.Graphics.ImageInterpolation = interpolation; pe.Graphics.DrawImage(image, 0, 0, 20, 20); pe.Graphics.DrawImage(image, 0, 20, 50, 50); pe.Graphics.DrawImage(image, 0, 70, 100, 100); pe.Graphics.DrawImage(image, 120, 0, 300, 300); }; return drawable; }
public static NSImage Resize(this NSImage image, sd.Size newsize, ImageInterpolation interpolation = ImageInterpolation.Default) { var newimage = new NSImage(newsize); var newrep = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32); newimage.AddRepresentation(newrep); var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG(); image.DrawInRect(new sd.RectangleF(sd.PointF.Empty, newimage.Size), new sd.RectangleF(sd.PointF.Empty, image.Size), NSCompositingOperation.SourceOver, 1f); NSGraphicsContext.GlobalRestoreGraphicsState(); return(newimage); }
public static Cairo.Filter ConvertC (ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return Cairo.Filter.Bilinear; case ImageInterpolation.None: return Cairo.Filter.Nearest; case ImageInterpolation.High: return Cairo.Filter.Best; case ImageInterpolation.Low: return Cairo.Filter.Fast; case ImageInterpolation.Medium: return Cairo.Filter.Good; default: throw new NotSupportedException(); } }
public static sd.BitmapInterpolationMode ToDx(this ImageInterpolation value) { switch (value) { case ImageInterpolation.None: return(sd.BitmapInterpolationMode.NearestNeighbor); case ImageInterpolation.Default: case ImageInterpolation.Low: case ImageInterpolation.Medium: case ImageInterpolation.High: return(sd.BitmapInterpolationMode.Linear); default: throw new NotSupportedException(); } }
Control CreateImage (ImageInterpolation interpolation) { var resourceStream = GetType().Assembly.GetManifestResourceStream ("Eto.Test.TestImage.png"); var image = new Bitmap (resourceStream); var drawable = new Drawable { Size = new Size(250, 160) }; drawable.Paint += (sender, pe) => { pe.Graphics.ImageInterpolation = interpolation; pe.Graphics.DrawImage (image, 0, 0, 20, 20); pe.Graphics.DrawImage (image, 0, 20, 50, 50); pe.Graphics.DrawImage (image, 0, 70, 100, 100); pe.Graphics.DrawImage (image, 120, 0, 300, 300); }; return drawable; }
/// <summary> /// Create a new scaled bitmap with the specified <paramref name="width"/> and <paramref name="height"/> /// </summary> /// <param name="image">Image to scale</param> /// <param name="width">Width to scale the source image to</param> /// <param name="height">Height to scale the source image to</param> /// <param name="interpolation">Interpolation quality</param> public Bitmap(Image image, int?width = null, int?height = null, ImageInterpolation interpolation = ImageInterpolation.Default) { if (image == null) { throw new ArgumentNullException("image"); } if (width != null && width <= 0) { throw new ArgumentOutOfRangeException("width", "width must be greater than zero"); } if (height != null && height <= 0) { throw new ArgumentOutOfRangeException("height", "height must be greater than zero"); } Handler.Create(image, width ?? image.Size.Width, height ?? image.Size.Height, interpolation); Initialize(); }
Control CreateImage(ImageInterpolation interpolation) { var image = TestIcons.TestImage; var drawable = new Drawable { Size = new Size(250, 160) }; drawable.Paint += (sender, pe) => { pe.Graphics.ImageInterpolation = interpolation; pe.Graphics.DrawImage(image, 0, 0, 20, 20); pe.Graphics.DrawImage(image, 0, 20, 50, 50); pe.Graphics.DrawImage(image, 0, 70, 100, 100); pe.Graphics.DrawImage(image, 120, 0, 300, 300); }; return(drawable); }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { ApplicationHandler.InvokeIfNecessary(() => { var source = image.ToWpf(); // use drawing group to allow for better quality scaling var group = new swm.DrawingGroup(); swm.RenderOptions.SetBitmapScalingMode(group, interpolation.ToWpf()); group.Children.Add(new swm.ImageDrawing(source, new sw.Rect(0, 0, width, height))); var drawingVisual = new swm.DrawingVisual(); using (var drawingContext = drawingVisual.RenderOpen()) drawingContext.DrawDrawing(group); var resizedImage = new swm.Imaging.RenderTargetBitmap(width, height, source.DpiX, source.DpiY, swm.PixelFormats.Default); resizedImage.Render(drawingVisual); Control = resizedImage; }); }
Control CreateImage(ImageInterpolation interpolation) { var resourceStream = GetType().Assembly.GetManifestResourceStream("Eto.Test.TestImage.png"); var image = new Bitmap(resourceStream); var drawable = new Drawable { Size = new Size(250, 160) }; drawable.Paint += (sender, pe) => { pe.Graphics.ImageInterpolation = interpolation; pe.Graphics.DrawImage(image, 0, 0, 20, 20); pe.Graphics.DrawImage(image, 0, 20, 50, 50); pe.Graphics.DrawImage(image, 0, 70, 100, 100); pe.Graphics.DrawImage(image, 120, 0, 300, 300); }; return(drawable); }
public static NSImageInterpolation Convert(ImageInterpolation value) { switch (value) { case ImageInterpolation.None: return(NSImageInterpolation.None); case ImageInterpolation.Low: return(NSImageInterpolation.Low); case ImageInterpolation.Medium: return(NSImageInterpolation.Medium); case ImageInterpolation.High: return(NSImageInterpolation.High); default: throw new NotSupportedException(); } }
public static NSImageRep Resize(this NSImageRep image, CGSize newsize, ImageInterpolation interpolation = ImageInterpolation.Default, CGSize?imageSize = null) { var newrep = new NSBitmapImageRep(IntPtr.Zero, (nint)newsize.Width, (nint)newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * (nint)newsize.Width, 32); newrep.Size = imageSize ?? newsize; var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG(); #if XAMMAC // Xamarin.Mac doesn't allow null for hints, remove this when it does. Messaging.bool_objc_msgSend_CGRect_CGRect_UIntPtr_nfloat_bool_IntPtr(image.Handle, selDrawInRect_FromRect_Operation_Fraction_RespectFlipped_Hints_Handle, new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, (UIntPtr)(ulong)NSCompositingOperation.SourceOver, 1f, true, IntPtr.Zero); #else image.DrawInRect(new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, NSCompositingOperation.SourceOver, 1f, true, null); #endif NSGraphicsContext.GlobalRestoreGraphicsState(); return(newrep); }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { var source = image.ToSD(); var pixelFormat = source.PixelFormat; if ( pixelFormat == SD.Imaging.PixelFormat.Indexed || pixelFormat == SD.Imaging.PixelFormat.Format1bppIndexed || pixelFormat == SD.Imaging.PixelFormat.Format4bppIndexed || pixelFormat == SD.Imaging.PixelFormat.Format8bppIndexed) { pixelFormat = SD.Imaging.PixelFormat.Format32bppRgb; } Control = new SD.Bitmap(width, height, pixelFormat); using (var graphics = SD.Graphics.FromImage(Control)) { graphics.InterpolationMode = interpolation.ToSD(); var rect = new SD.Rectangle(0, 0, width, height); graphics.FillRectangle(SD.Brushes.Transparent, rect); graphics.DrawImage(source, rect); } }
public static sd2.InterpolationMode ToSD(this ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return(sd2.InterpolationMode.High); case ImageInterpolation.None: return(sd2.InterpolationMode.NearestNeighbor); case ImageInterpolation.Low: return(sd2.InterpolationMode.Low); case ImageInterpolation.Medium: return(sd2.InterpolationMode.High); case ImageInterpolation.High: return(sd2.InterpolationMode.HighQualityBilinear); default: throw new NotSupportedException(); } }
public static CGInterpolationQuality ToCG(this ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return(CGInterpolationQuality.Default); case ImageInterpolation.None: return(CGInterpolationQuality.None); case ImageInterpolation.Low: return(CGInterpolationQuality.Low); case ImageInterpolation.Medium: return(CGInterpolationQuality.Medium); case ImageInterpolation.High: return(CGInterpolationQuality.High); default: throw new NotSupportedException(); } }
public static Gdk.InterpType ToGdk(this ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return(Gdk.InterpType.Bilinear); case ImageInterpolation.None: return(Gdk.InterpType.Nearest); case ImageInterpolation.High: return(Gdk.InterpType.Hyper); case ImageInterpolation.Low: return(Gdk.InterpType.Tiles); case ImageInterpolation.Medium: return(Gdk.InterpType.Bilinear); default: throw new NotSupportedException(); } }
public static s.BitmapScalingMode ToWpf(this ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return(s.BitmapScalingMode.Unspecified); case ImageInterpolation.None: return(s.BitmapScalingMode.NearestNeighbor); case ImageInterpolation.Low: return(s.BitmapScalingMode.LowQuality); case ImageInterpolation.Medium: return(s.BitmapScalingMode.HighQuality); case ImageInterpolation.High: return(s.BitmapScalingMode.HighQuality); default: throw new NotSupportedException(); } }
public static Cairo.Filter ToCairo(this ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return(Cairo.Filter.Bilinear); case ImageInterpolation.None: return(Cairo.Filter.Nearest); case ImageInterpolation.High: return(Cairo.Filter.Best); case ImageInterpolation.Low: return(Cairo.Filter.Fast); case ImageInterpolation.Medium: return(Cairo.Filter.Good); default: throw new NotSupportedException(); } }
public static SD.Drawing2D.InterpolationMode Convert(ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return(SD.Drawing2D.InterpolationMode.Default); case ImageInterpolation.None: return(SD.Drawing2D.InterpolationMode.NearestNeighbor); case ImageInterpolation.Low: return(SD.Drawing2D.InterpolationMode.Low); case ImageInterpolation.Medium: return(SD.Drawing2D.InterpolationMode.High); case ImageInterpolation.High: return(SD.Drawing2D.InterpolationMode.HighQualityBilinear); default: throw new NotSupportedException(); } }
/// <summary> /// Create a new scaled bitmap with the specified <paramref name="width"/> and <paramref name="height"/> /// </summary> /// <param name="image">Image to scale</param> /// <param name="width">Width to scale the source image to</param> /// <param name="height">Height to scale the source image to</param> /// <param name="interpolation">Interpolation quality</param> public Bitmap(Image image, int? width = null, int? height = null, ImageInterpolation interpolation = ImageInterpolation.Default) { Handler.Create(image, width ?? image.Size.Width, height ?? image.Size.Height, interpolation); Initialize(); }
protected override GLib.Value GetValueInternal(object dataItem, int dataColumn, int row) { if (Widget.Binding != null) { var ret = Widget.Binding.GetValue(dataItem); var image = ret as Image; if (image != null) { return(new GLib.Value(((IGtkPixbuf)image.Handler).GetPixbuf(new Size(16, 16), ImageInterpolation.ToGdk()))); } } return(new GLib.Value((Gdk.Pixbuf)null)); }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { var source = image.ToNS(); Control = source.Resize(new CGSize(width, height), interpolation); }
public static SD.Drawing2D.InterpolationMode Convert (ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return SD.Drawing2D.InterpolationMode.Default; case ImageInterpolation.None: return SD.Drawing2D.InterpolationMode.NearestNeighbor; case ImageInterpolation.Low: return SD.Drawing2D.InterpolationMode.Low; case ImageInterpolation.Medium: return SD.Drawing2D.InterpolationMode.High; case ImageInterpolation.High: return SD.Drawing2D.InterpolationMode.HighQualityBilinear; default: throw new NotSupportedException(); } }
/// <summary> /// Create a new scaled bitmap with the specified <paramref name="width"/> and <paramref name="height"/> /// </summary> /// <param name="image">Image to scale</param> /// <param name="width">Width to scale the source image to</param> /// <param name="height">Height to scale the source image to</param> /// <param name="interpolation">Interpolation quality</param> public Bitmap(Image image, int? width = null, int? height = null, ImageInterpolation interpolation = ImageInterpolation.Default) { if (image == null) throw new ArgumentNullException("image"); if (width != null && width <= 0) throw new ArgumentOutOfRangeException("width", "width must be greater than zero"); if (height != null && height <= 0) throw new ArgumentOutOfRangeException("height", "height must be greater than zero"); Handler.Create(image, width ?? image.Size.Width, height ?? image.Size.Height, interpolation); Initialize(); }
public void DrawImage(Image image, float x, float y) { var bmp = image.ToDx(Control); Control.DrawBitmap(bmp, new s.RectangleF(x, y, bmp.Size.Width, bmp.Size.Height), 1f, ImageInterpolation.ToDx()); }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { Control = ag.Bitmap.CreateScaledBitmap(image.ToAndroid(), width, height, false); }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { throw new NotImplementedException(); }
public static NSImageInterpolation Convert (ImageInterpolation value) { switch (value) { case ImageInterpolation.None: return NSImageInterpolation.None; case ImageInterpolation.Low: return NSImageInterpolation.Low; case ImageInterpolation.Medium: return NSImageInterpolation.Medium; case ImageInterpolation.High: return NSImageInterpolation.High; default: throw new NotSupportedException(); } }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { var pixbuf = image.ToGdk(); Control = pixbuf.ScaleSimple(width, height, interpolation.ToGdk()); }
public Bitmap(Image image, int? width, int? height, ImageInterpolation interpolation, Generator generator) : this(generator) { Handler.Create(image, width ?? image.Size.Width, height ?? image.Size.Height, interpolation); }
public static swm.BitmapScalingMode Convert (ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return swm.BitmapScalingMode.Unspecified; case ImageInterpolation.None: return swm.BitmapScalingMode.NearestNeighbor; case ImageInterpolation.Low: return swm.BitmapScalingMode.LowQuality; case ImageInterpolation.Medium: return swm.BitmapScalingMode.HighQuality; case ImageInterpolation.High: return swm.BitmapScalingMode.HighQuality; default: throw new NotSupportedException (); } }
/// <summary> /// Create a new scaled bitmap with the specified <paramref name="width"/> and <paramref name="height"/> /// </summary> /// <param name="image">Image to scale</param> /// <param name="width">Width to scale the source image to</param> /// <param name="height">Height to scale the source image to</param> /// <param name="interpolation">Interpolation quality</param> /// <param name="generator">Generator to create the bitmap</param> public Bitmap(Image image, int? width = null, int? height = null, ImageInterpolation interpolation = ImageInterpolation.Default, Generator generator = null) : this (generator) { Handler.Create (image, width ?? image.Size.Width, height ?? image.Size.Height, interpolation); }
public void Create(Image image, int width, int height, ImageInterpolation interpolation) { throw new NotImplementedException(); }
public static CGInterpolationQuality ConvertCG (ImageInterpolation value) { switch (value) { case ImageInterpolation.Default: return CGInterpolationQuality.Default; case ImageInterpolation.None: return CGInterpolationQuality.None; case ImageInterpolation.Low: return CGInterpolationQuality.Low; case ImageInterpolation.Medium: return CGInterpolationQuality.Medium; case ImageInterpolation.High: return CGInterpolationQuality.High; default: throw new NotSupportedException(); } }