public InterpolationModeGraphics( Graphics graphics, InterpolationMode newMode) { _graphics = graphics; _oldMode = graphics.InterpolationMode; graphics.InterpolationMode = newMode; }
public Tweener(float from, float to, float time, InterpolationMode mode = InterpolationMode.Linear) { _From = from; _To = to; _DesiredTime = time; _Method = Interpolate.GetMethod(mode); }
// Constructor, which saves away all of the important information. // We assume that the lock on the "graphics" object is held by the caller. internal GraphicsContainer(Graphics graphics) { // Push this container onto the stack. this.graphics = graphics; next = graphics.stackTop; graphics.stackTop = this; // Save the graphics state information. clip = graphics.Clip; if(clip != null) { clip = clip.Clone(); } compositingMode = graphics.CompositingMode; compositingQuality = graphics.CompositingQuality; interpolationMode = graphics.InterpolationMode; pageScale = graphics.PageScale; pageUnit = graphics.PageUnit; pixelOffsetMode = graphics.PixelOffsetMode; renderingOrigin = graphics.RenderingOrigin; smoothingMode = graphics.SmoothingMode; textContrast = graphics.TextContrast; textRenderingHint = graphics.TextRenderingHint; if (graphics.transform == null) { transform = null; } else { transform = Matrix.Clone(graphics.transform); } }
/// <summary>Initializes a new instance of the /// <see cref="T:XNAnimation.Controllers.AnimationController" /> /// class. /// </summary> /// <param name="skeleton">The skeleton of the model to be animated</param> public AnimationController(SkinnedModelBoneCollection skeleton) { this.skeleton = skeleton; localBonePoses = new Pose[skeleton.Count]; skinnedBoneTransforms = new Matrix[skeleton.Count]; skeleton[0].CopyBindPoseTo(localBonePoses); time = TimeSpan.Zero; speed = 1.0f; loopEnabled = true; playbackMode = PlaybackMode.Forward; blendWeight = 1.0f; translationInterpolation = InterpolationMode.None; orientationInterpolation = InterpolationMode.None; scaleInterpolation = InterpolationMode.None; crossFadeEnabled = false; crossFadeInterpolationAmount = 0.0f; crossFadeTime = TimeSpan.Zero; crossFadeElapsedTime = TimeSpan.Zero; hasFinished = false; isPlaying = false; }
private void contextMenuFilterBicubic_Click(object sender, EventArgs e) { this.filter = InterpolationMode.Bicubic; this.Invalidate(); this.contextMenuFilterNearest.Checked = this.contextMenuFilterBilinear.Checked = false; this.contextMenuFilterBicubic.Checked = true; }
/// <summary> /// Interpolate between two values using the specified interpolation mode. /// </summary> /// <param name="from">The starting value to interpolate from.</param> /// <param name="to">The end value to interpolate to.</param> /// <param name="delta">The percentage of progress between the two. Ranges from 0.0 to 1.0 are acceptable.</param> /// <param name="mode">The interpolation mode to used, specified by the InterpolationMode enum. ex: InterpolationMode.Sigmoid</param> /// <returns>The current value between from and to based on the delta specified.</returns> public static float Interpolate(float from, float to, float delta, InterpolationMode mode) { // return the results of different methods based on which mode is specified if (mode == InterpolationMode.Linear) { // use linear for entire interpolation curve return _InterpolateLinear(from, to, delta); } else if (mode == InterpolationMode.EaseInOut) { // use sigmoid for the entire interpolation curve return _InterpolateSigmoid(from, to, delta); } else if (mode == InterpolationMode.EaseIn) { // use sigmoid for only the first half of the curve if (delta <= 0.5f) return _InterpolateSigmoid(from, to, delta); else return _InterpolateLinear(from, to, delta); } else if (mode == InterpolationMode.EaseOut) { // use sigmoid for only the last half of the curve if (delta >= 0.5f) return _InterpolateSigmoid(from, to, delta); else return _InterpolateLinear(from, to, delta); } // default to linear return _InterpolateLinear(from, to, delta); }
private ThumbnailSettings(Size size, InterpolationMode interpolationMode, Color backColor, ThreadPriority threadPriority) { this.size = size; this.interpolationMode = interpolationMode; this.backColor = backColor; this.threadPriority = threadPriority; }
/// <summary> /// Creates a scaled thumbnail. /// </summary> /// <param name="width">The maximum width of the thumbnail to create.</param> /// <param name="height">The maximum height of the thumbnail to create.</param> /// <param name="interpolationMode">The Interpolation of the thumbnailing (HighQualityBicubic provides best quality)</param> /// <returns>A bitmap thumbnail of the source image.</returns> public static Bitmap CreateThumbnail(Bitmap aBitmap, int width, int height, InterpolationMode interpolationMode) { //Calculate scales float x = ((float)aBitmap.Width / (float)width); float y = ((float)aBitmap.Height / (float)height); float factor = Math.Max(x, y); if (factor < 1) factor = 1; int thWidth = (int)Math.Round((aBitmap.Width / factor), 0); int thHeight = (int)Math.Round((aBitmap.Height / factor), 0); // Set the size of the target image Bitmap bmpTarget = new Bitmap(thWidth, thHeight); Graphics grfxThumb = Graphics.FromImage(bmpTarget); grfxThumb.InterpolationMode = interpolationMode; // Draw the original image to the target image grfxThumb.DrawImage(aBitmap, new Rectangle(0, 0, thWidth, Convert.ToInt32(thWidth * aBitmap.Height / aBitmap.Width))); grfxThumb.Dispose(); return bmpTarget; }
public PolynomialImageTransformer(RegistrationDefinition registration, InterpolationMode interpolationMode, int polynomialDegree) : base(registration, interpolationMode) { List<PositionAssociation> associationList = registration.GetAssociationList(); TransformationStyle arg_15_0 = registration.warpStyle; int num = associationList.Count; if (num == 2) { num++; } JamaMatrix jamaMatrix = new JamaMatrix(num, 2); JamaMatrix jamaMatrix2 = new JamaMatrix(num, 2); for (int i = 0; i < num; i++) { LatLon latLon = (i == associationList.Count) ? PolynomialImageTransformer.getThirdPosition(associationList[0].sourcePosition.pinPosition.latlon, associationList[1].sourcePosition.pinPosition.latlon, true) : associationList[i].sourcePosition.pinPosition.latlon; jamaMatrix.SetElement(i, 0, latLon.lon); jamaMatrix.SetElement(i, 1, latLon.lat); LatLon latLon2 = (i == associationList.Count) ? PolynomialImageTransformer.getThirdPosition(MercatorCoordinateSystem.LatLonToMercator(associationList[0].globalPosition.pinPosition.latlon), MercatorCoordinateSystem.LatLonToMercator(associationList[1].globalPosition.pinPosition.latlon), false) : MercatorCoordinateSystem.LatLonToMercator(associationList[i].globalPosition.pinPosition.latlon); jamaMatrix2.SetElement(i, 0, latLon2.lon); jamaMatrix2.SetElement(i, 1, latLon2.lat); } this.destMercatorToSourceTransformer = PolynomialImageTransformer.getPolyPointTransformer(jamaMatrix, jamaMatrix2, polynomialDegree); this.sourceToDestMercatorTransformer_approximate = PolynomialImageTransformer.getApproximateInverterPolyPointTransformer(jamaMatrix, jamaMatrix2, polynomialDegree); DownhillInverterPointTransformer flakyPointTransformer = new DownhillInverterPointTransformer(this.destMercatorToSourceTransformer, this.sourceToDestMercatorTransformer_approximate); IPointTransformer sourceToMercator = new RobustPointTransformer(flakyPointTransformer, this.sourceToDestMercatorTransformer_approximate); this.destLatLonToSourceTransformer = new LatLonToSourceTransform(this.destMercatorToSourceTransformer); this.sourceToDestLatLonTransformer = new SourceToLatLonTransform(sourceToMercator); }
private RenderQualityStyle(string _styleName, InterpolationMode invokeImageInterpolationMode, InterpolationMode warpInterpolationMode, double hackyWarperAntialiasFactor) { this._styleName = _styleName; this._invokeImageInterpolationMode = invokeImageInterpolationMode; this._warpInterpolationMode = warpInterpolationMode; this._hackyWarperAntialiasFactor = hackyWarperAntialiasFactor; }
public InterpolationModeGraphics( System.Drawing.Graphics graphics, InterpolationMode newMode) { _graphics = graphics; _oldMode = graphics.InterpolationMode; graphics.InterpolationMode = newMode; }
/// <summary> /// Applies the GDI+ pixel scaler. /// </summary> /// <param name="type">The type of scaler to use.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="filterRegion">The filter region, if any.</param> /// <returns> /// The rescaled image. /// </returns> public cImage ApplyScaler(InterpolationMode type, int width, int height, Rectangle? filterRegion = null) { if (!((IList<InterpolationMode>)INTERPOLATORS).Contains(type)) throw new NotSupportedException(string.Format("Interpolation mode '{0}' not supported.", type)); var startX = filterRegion == null ? 0 : Math.Max(0, filterRegion.Value.Left); var startY = filterRegion == null ? 0 : Math.Max(0, filterRegion.Value.Top); var endX = filterRegion == null ? this.Width : Math.Min(this.Width, filterRegion.Value.Right); var endY = filterRegion == null ? this.Height : Math.Min(this.Height, filterRegion.Value.Bottom); // run through scaler var bitmap = new Bitmap(width, height); using (var graphics = Graphics.FromImage(bitmap)) { //set the resize quality modes to high quality graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = type; graphics.SmoothingMode = SmoothingMode.HighQuality; //draw the image into the target bitmap //graphics.DrawImage(source, 0, 0, result.Width, result.Height); // FIXME: this is a hack to prevent the microsoft bug from creating a white pixel on top and left border (see http://forums.asp.net/t/1031961.aspx/1) graphics.DrawImage(filterRegion == null ? this.ToBitmap() : this.ToBitmap(startX, startY, endX - startX, endY - startY), -1, -1, bitmap.Width + 1, bitmap.Height + 1); } var result = FromBitmap(bitmap); result.HorizontalOutOfBoundsMode = this.HorizontalOutOfBoundsMode; result.VerticalOutOfBoundsMode = this.VerticalOutOfBoundsMode; return (result); }
public static Image KaMagnify( this Image self, int rate, InterpolationMode im = InterpolationMode.Default) { if ( !self.KaIs() ) { return null; } var src = self.Clone() as Image; var w = src.Width * rate; var h = src.Height * rate; var res = new Bitmap( w, h ); Graphics g = null; using ( g = Graphics.FromImage( res ) ) { g.InterpolationMode = im; g.DrawImage( src, 0, 0, w, h ); } return res; }
private void bicubicaToolStripMenuItem_Click(object sender, EventArgs e) { desativaOpcoes(); bicubicaToolStripMenuItem.Checked = true; suavizacao = InterpolationMode.Bicubic; refreshImages(); }
public async static Task<BitmapHolder> ToBitmapHolderAsync(this Stream imageStream, Tuple<int, int> downscale, bool useDipUnits, InterpolationMode mode) { if (imageStream == null) return null; using (IRandomAccessStream image = new RandomStream(imageStream)) { if (downscale != null && (downscale.Item1 > 0 || downscale.Item2 > 0)) { using (var downscaledImage = await image.ResizeImage(downscale.Item1, downscale.Item2, mode, useDipUnits).ConfigureAwait(false)) { BitmapDecoder decoder = await BitmapDecoder.CreateAsync(downscaledImage); PixelDataProvider pixelDataProvider = await decoder.GetPixelDataAsync(); var bytes = pixelDataProvider.DetachPixelData(); int[] array = new int[decoder.PixelWidth * decoder.PixelHeight]; CopyPixels(bytes, array); return new BitmapHolder(array, (int)decoder.PixelWidth, (int)decoder.PixelHeight); } } else { BitmapDecoder decoder = await BitmapDecoder.CreateAsync(image); PixelDataProvider pixelDataProvider = await decoder.GetPixelDataAsync(); var bytes = pixelDataProvider.DetachPixelData(); int[] array = new int[decoder.PixelWidth * decoder.PixelHeight]; CopyPixels(bytes, array); return new BitmapHolder(array, (int)decoder.PixelWidth, (int)decoder.PixelHeight); } } }
public static Image ScaleByPercent(Image imgPhoto, int Percent, InterpolationMode interpolationMode) { float nPercent = ((float)Percent / 100); int sourceWidth = imgPhoto.Width; int sourceHeight = imgPhoto.Height; int sourceX = 0; int sourceY = 0; int destX = 0; int destY = 0; int destWidth = (int)(sourceWidth * nPercent); int destHeight = (int)(sourceHeight * nPercent); Bitmap bmPhoto = new Bitmap(destWidth, destHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb); bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution); Graphics grPhoto = Graphics.FromImage(bmPhoto); grPhoto.InterpolationMode = interpolationMode; //int memoryMB = (int)(Process.GetCurrentProcess().PagedMemorySize64 / (1024 * 1024)); grPhoto.DrawImage(imgPhoto, new Rectangle(destX, destY, destWidth, destHeight), new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel); grPhoto.Dispose(); return bmPhoto; }
public LinearScroll(Vector2 position, Vector2 target, float duration, InterpolationMode mode = InterpolationMode.Linear) { _InitialPoint = position; _TargetPoint = target; _Method = Interpolate.GetMethod(mode); _Duration = duration; }
public void Resize(int width, int height, InterpolationMode mode = InterpolationMode.Bicubic) { Bitmap tmp = new Bitmap(width, height); Graphics g = Graphics.FromImage(tmp); g.InterpolationMode = mode; g.DrawImage(Image, 0, 0, width, height); Image.Dispose(); Image = tmp; }
public FontState(Font f, char g, InterpolationMode i, int r, string file) { font = f; glyph = g; interpolation = i; range = r; filename = file; s.Start(); }
public TextureBrush(Texture texture) { IsAsync = texture.IsAsync; disposeTexture = false; this.texture = texture; Color = Color4.White; InterpolationMode = InterpolationMode.Default; }
public TextureBrush(Stream stream, bool loadAsync = false) { IsAsync = loadAsync; disposeTexture = true; texture = new Texture(stream, loadAsync); Color = Color4.White; InterpolationMode = InterpolationMode.Default; }
public Framebuffer AttachDepth(PixelInternalFormat internalFormat, PixelFormat format, PixelType type, InterpolationMode interpolation) { this.BufferTextures[FboAttachment.DepthAttachment] = new Texture2D (TextureTarget.Texture2D, internalFormat, format, type, interpolation, false, this.Width, this.Height); this.Bind (); this.BufferTextures[FboAttachment.DepthAttachment].Bind (); GL.FramebufferTexture (this.Target, FramebufferAttachment.DepthAttachment, this.BufferTextures[FboAttachment.DepthAttachment].TextureId, 0); this.Unbind (); return this; }
public static Bitmap CreateDistanceField(InterpolationMode interpolation, int width, int height, int scale, uint[] buffer) { Grid g1, g2; Grid.FromBitmap(out g1, out g2, width, height, buffer); g1.Generate(); g2.Generate(); return Grid.ToBitmap(g1, g2, scale, interpolation); }
public Framebuffer AttachTexture(FboAttachment attachment, DrawBuffersEnum mode, PixelInternalFormat internalFormat, PixelFormat format, PixelType type, InterpolationMode interpolation) { this.Attachments.Add (mode); this.BufferTextures[attachment] = new Texture2D (TextureTarget.Texture2D, internalFormat, format, type, interpolation, false, this.Width, this.Height); this.Bind (); this.BufferTextures[attachment].Bind (); GL.FramebufferTexture (this.Target, (FramebufferAttachment) mode, this.BufferTextures[attachment].TextureId, 0); this.Unbind (); return this; }
/// <summary> /// 按指定宽度与高度缩放图像 /// </summary> /// <param name="bmp"> 待处理的图像 </param> /// <param name="width"> 缩放后的宽度 </param> /// <param name="height"> 缩放后的高度 </param> /// <param name="model">图像质量模式</param> /// <returns> 缩放后的图像 </returns> public static Bitmap Zoom(this Bitmap bmp, int width, int height, InterpolationMode model = InterpolationMode.Default) { Bitmap newBmp = new Bitmap(width, height); using (Graphics graphics = Graphics.FromImage(newBmp)) { graphics.InterpolationMode = model; graphics.DrawImage(bmp, new Rectangle(0, 0, width, height), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel); return newBmp; } }
public static Bitmap Resize(this Bitmap image, Size newSize, InterpolationMode mode) { var result = new Bitmap(newSize.Width, newSize.Height); var graphic = Graphics.FromImage(result); graphic.CompositingQuality = CompositingQuality.AssumeLinear; graphic.InterpolationMode = mode; var rectangle = new Rectangle(Point.Empty, newSize); graphic.DrawImage(image, rectangle); return result; }
public static Stream CreateCropedImageFile(Stream originalStream, double x, double y, double q, ImageFormat outputFormat, SmoothingMode smoothingMode, InterpolationMode interpolationMode, PixelOffsetMode pixelOffsetMode, double verticalDiff, double horizontalDiff) { if (originalStream == null) return new MemoryStream(); Stream newMemoryStream; using (var originalImage = System.Drawing.Image.FromStream(originalStream)) { using (var bmp = new Bitmap((int)x, (int)y)) { double verticalOffset = verticalDiff; double horizontalOffset = horizontalDiff; if(horizontalDiff == double.MaxValue) { horizontalOffset = originalImage.Width - x; }else if(horizontalDiff < 0) { horizontalOffset = (originalImage.Width - x)/2; } if(horizontalOffset<0) horizontalOffset = 0; if (verticalDiff == double.MaxValue) { verticalOffset = originalImage.Height - y; }else if(verticalDiff < 0) { verticalOffset = (originalImage.Height - y)/2; } if(verticalOffset<0) verticalOffset = 0; bmp.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution); using (var graphic = Graphics.FromImage(bmp)) { graphic.SmoothingMode = smoothingMode; graphic.InterpolationMode = interpolationMode; graphic.PixelOffsetMode = pixelOffsetMode; graphic.DrawImage(originalImage, new Rectangle(0, 0, (int)x, (int)y), (int)horizontalOffset, (int)verticalOffset, (int)x, (int)y, GraphicsUnit.Pixel); newMemoryStream = new MemoryStream(); bmp.Save(newMemoryStream, originalImage.RawFormat); if(bmp != null) bmp.Dispose(); } } } newMemoryStream.Position = 0; return newMemoryStream; }
public Image GetResizedWithCache(Image source, int width, int height, InterpolationMode mode = InterpolationMode.HighQualityBicubic) { var key = new CacheKey(source, width, height); return cachedImages.GetOrAdd(key, (k) => { var resized = new Bitmap(k.Width, k.Height); using (var g = Graphics.FromImage(resized)) { g.InterpolationMode = mode; g.DrawImage(source, 0, 0, k.Width, k.Height); } return resized; }); }
public void Animate(float destinationValue, int intervalTime) { _originValue = _currentValue; _targetValue = destinationValue; _duration = intervalTime; // keep in float to speed calc _originTick = Animator.Instance.Tick; _targetTick = _originTick + intervalTime; _currentMode = InterpolationMode.Lerp; }
/// <summary> /// The idea here is to stop image from stretching. /// </summary> /// <param name="img"></param> /// <param name="ctrl"></param> /// <returns></returns> public Bitmap FitToControl(System.Windows.Forms.Control ctrl, InterpolationMode iMode) { float aspectCtrl = (float)ctrl.Width / (float)ctrl.Height; float aspectImg = (float)OutputImage.Width / (float)OutputImage.Height; Size newSize = new Size(ctrl.Width, (int)((float)ctrl.Width / aspectImg)); if (aspectCtrl / aspectImg > 1) { newSize = new Size((int)((float)ctrl.Height * aspectImg),ctrl.Height); } ResizeImage(newSize,iMode); return OutputImage; }
protected static Bitmap ResizeImg(Image image, int width, int height, InterpolationMode mode, bool maintain_aspect_ratio) { int draw_height, draw_width, pos_x, pos_y; if (maintain_aspect_ratio) { double ratioX = (double)width / (double)image.Width; double ratioY = (double)height / (double)image.Height; double ratio = Math.Min(ratioX, ratioY); draw_height = (int)(image.Height * ratio); draw_width = (int)(image.Width * ratio); pos_x = (int)((width - (image.Width * ratio)) / 2); pos_y = (int)((height - (image.Height * ratio)) / 2); } else { draw_height = height; draw_width = width; pos_x = 0; pos_y = 0; } var destRect = new Rectangle(pos_x, pos_y, draw_width, draw_height); var destImage = new Bitmap(width, height); destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); using (var graphics = Graphics.FromImage(destImage)) { graphics.CompositingMode = CompositingMode.SourceCopy; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = mode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; using (var wrapMode = new ImageAttributes()) { wrapMode.SetWrapMode(WrapMode.TileFlipXY); graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); } } return(destImage); }
private void ConvertOneFile(string oneoriginalfile, int ihowmuch, InterpolationMode modetouse) { Image original; try { original = Image.FromFile(oneoriginalfile); } catch (Exception e) { txtprogress.AppendText(oneoriginalfile + " could not be converted to an image.\n"); Application.DoEvents(); return; } // The resize function takes a new absoloute width/height so we have to calculate what X% of that means // Take the original width and height, then multiply the UI percentage to get the new abosolutes // The alg always preserves aspect ratio so you may not get an exact match Size mysize = new Size(); float ratio = (float)ihowmuch / 100; float rwidth = original.Width * ratio; float rheight = original.Height * ratio; mysize.Width = (int)rwidth; mysize.Height = (int)rheight; // Call the resize code to do the work Image resized = ResizeImage(original, mysize, modetouse); // New file name is old file name plus 'resized' at the end. Save the new file. string newfilename = oneoriginalfile + "_resized.jpg"; resized.Save(newfilename, ImageFormat.Jpeg); // Put up a little progress and status so people know things are working ... mystatus.Text = newfilename + " resized successfully."; txtprogress.AppendText(newfilename + " resized successfully.\n"); newfilename = ""; Application.DoEvents(); }
/// <summary> /// 重设Bitmap图片大小 /// </summary> /// <param name="bm"></param> /// <param name="w">宽</param> /// <param name="h">高</param> /// <param name="interpolationMode"></param> /// <param name="smoothingMode"></param> /// <param name="compositingQuality"></param> /// <returns></returns> public static Bitmap SetSize(this Bitmap bm, int w, int h, InterpolationMode interpolationMode = InterpolationMode.HighQualityBicubic, SmoothingMode smoothingMode = SmoothingMode.HighQuality, CompositingQuality compositingQuality = CompositingQuality.HighSpeed ) { int nowWidth = w; int nowHeight = h; Bitmap newbm = new Bitmap(nowWidth, nowHeight);//新建一个放大后大小的图片 Graphics g = Graphics.FromImage(newbm); g.InterpolationMode = interpolationMode; g.SmoothingMode = smoothingMode; g.CompositingQuality = compositingQuality; g.DrawImage(bm, new Rectangle(0, 0, nowWidth, nowHeight), new Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel); g.Dispose(); return(newbm); }
private Bitmap ScaleImage(Bitmap srcImage, int destWidth, int destHeight, InterpolationMode interpMode) { var scaledImage = new Bitmap(srcImage, destWidth, destHeight); scaledImage.SetResolution(96.0f, 96.0f); var grPhoto = Graphics.FromImage(scaledImage); grPhoto.InterpolationMode = interpMode; grPhoto.DrawImage(srcImage, new Rectangle(0, 0, destWidth, destHeight), new Rectangle(0, 0, srcImage.Width, srcImage.Height), GraphicsUnit.Pixel); grPhoto.Dispose(); return(scaledImage); }
public RecordingParameters(RecordingParameters copyFrom) { this.PosX = copyFrom.PosX; this.PosY = copyFrom.PosY; this.SizeX = copyFrom.SizeX; this.SizeY = copyFrom.SizeY; this.ResX = copyFrom.ResX; this.ResY = copyFrom.ResY; this.FrameRate = copyFrom.FrameRate; this.running = copyFrom.running; this.RecordingMs = copyFrom.RecordingMs; this.audioBalance = copyFrom.audioBalance; this.leftVolume = copyFrom.leftVolume; this.rightVolume = copyFrom.rightVolume; this.pixelFormat = copyFrom.pixelFormat; this.interpolationMode = copyFrom.interpolationMode; this.smoothingMode = copyFrom.smoothingMode; this.compressionRate = copyFrom.compressionRate; }
/// <summary> /// Resizes an image using specified interpolation mode. /// </summary> /// <param name="img">Input image.</param> /// <param name="newSize">New image size.</param> /// <param name="mode">Interpolation mode.</param> /// <returns>Resized image.</returns> internal static TColor[,] Resize <TColor>(this TColor[,] img, Size newSize, InterpolationMode mode) where TColor : struct, IColor { switch (mode) { case InterpolationMode.NearestNeighbor : //return img.ApplyFilter(new ResizeNearestNeighbor(newSize.Width, newSize.Height)); return(ResizeNearsetNeighbur.Resize(img, newSize)); //faster case InterpolationMode.Bilinear: return(img.ApplyBaseTransformationFilter(new ResizeBilinear(newSize.Width, newSize.Height))); case InterpolationMode.Bicubic: return(img.ApplyBaseTransformationFilter(new ResizeBicubic(newSize.Width, newSize.Height))); default: throw new NotSupportedException(); } }
private IEnumerable <Widgets.DropdownMenuElement <string> > DropdownGenerator(InterpolationMode enumThing) { foreach (var item in Enum.GetValues(typeof(InterpolationMode))) { if ((InterpolationMode)item == InterpolationMode.Invalid) { continue; } yield return(new Widgets.DropdownMenuElement <string>() { payload = "", option = new FloatMenuOption((InterpolationMode)item == InterpolationMode.HighQualityBicubic ? item.ToString() + " (Recommended)" : item.ToString(), () => { CurrentInterpolationMode = (InterpolationMode)item; }) }); } }
public Heatmap(string _name) { heatmapResolution = 64; flipAutoConstrain = false; autoConstrain = false; alphaMapData = null; heatmapValues = null; lowerValueLimit = 0; higherValueLimit = 100; name = _name; texSource = TextureSource.DefaultColors; splatPrototypes = null; interpolationMode = InterpolationMode.NearestNeighbor; heatmapDataPoints = null; dataType = HeatmapData.HeightMap; heatmapSplatMaps = new List <HeatmapSplatprototype>(); baseValue = 0.0f; filter = ""; }
public static Bitmap FocusZoom(this Image image, float zoomFactor, int focusX, int focusY, ResizeMethod resizeMethod = ResizeMethod.Stretch, ResizeAlignment resizeAlignment = ResizeAlignment.CenterCenter, InterpolationMode interpolationMode = InterpolationMode.HighQualityBicubic, Color?paddingColor = null, PixelFormat?newPixelFormat = null ) { if (Math.Abs(zoomFactor - 0.0f) < Tools.Maths.EPSILON_F) { throw new ArgumentOutOfRangeException("zoomFactor", string.Format("Must not be 0 (epsilon tested with {0})", Tools.Maths.EPSILON_F)); } var actualPaddingColor = paddingColor.GetValueOrDefault(Color.Transparent); var pixelFormat = newPixelFormat.GetValueOrDefault(image.PixelFormat); var bitmap = new Bitmap(image.Width, image.Height, pixelFormat); bitmap.SetResolution(image.HorizontalResolution, image.VerticalResolution); using (Graphics graphics = Graphics.FromImage(bitmap)) { graphics.Clear(actualPaddingColor); graphics.InterpolationMode = interpolationMode; var sourceHeight = image.Height / zoomFactor; var sourceWidth = image.Width / zoomFactor; var startX = focusX - sourceWidth / 2; var startY = focusY - sourceHeight / 2; var sourceRectangle = new Rectangle( (int)Math.Round(startX), (int)Math.Round(startY), (int)Math.Round(sourceWidth), (int)Math.Round(sourceHeight) ) .IntersectWith(0, 0, image.Width, image.Height); var destRectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height); graphics.DrawImage(image, sourceRectangle, destRectangle, GraphicsUnit.Pixel); } return(bitmap); }
public void Update() { if (_currentMode == InterpolationMode.None) { return; } // lerp var currentTick = Animator.Instance.Tick; if (currentTick >= _targetTick) { _currentValue = _targetValue; _currentMode = InterpolationMode.None; return; } var amount = (currentTick - _originTick) / _duration; _currentValue = _originValue + (_targetValue - _originValue) * amount; }
SelectAlgorithm( InterpolationMode mode ) { switch (mode) { case InterpolationMode.ExpectNoPoles: return(new PolynomialInterpolationAlgorithm()); case InterpolationMode.ExpectPoles: return(new RationalInterpolationAlgorithm()); case InterpolationMode.Smooth: throw new NotImplementedException(); default: return(new PolynomialInterpolationAlgorithm()); } }
public IEnumerator MoveCamera(Transform camTransform, Vector3 targetPosition, Action nextStep) { var t = 0f; //Used by Lerp Vector3 startPosition = camTransform.position; //Used by Lerp Vector3 currentVelocity = new Vector3(); //Used by SmoothDamp if (interpolationMode == InterpolationMode.CURVE && customCurve.keys[customCurve.length - 1].value != 1) { interpolationMode = InterpolationMode.LERP; Debug.LogWarning("The last keyframe of your curve didn't have a value of 1, LERP has been forced as interpolation mode instead. Please correct it!"); } while (camTransform.position != targetPosition) { switch (interpolationMode) { case InterpolationMode.LERP: t += Time.deltaTime / panTime; camTransform.position = Vector3.Lerp(startPosition, targetPosition, t); break; case InterpolationMode.SMOOTH_DAMP: if (Vector3.Distance(camTransform.position, targetPosition) < 0.01f) { camTransform.position = targetPosition; } else { camTransform.position = Vector3.SmoothDamp(camTransform.position, targetPosition, ref currentVelocity, panTime); } break; case InterpolationMode.CURVE: t += Time.deltaTime / panTime; camTransform.position = Utils.InterpolateByCurve(startPosition, targetPosition, t, customCurve); break; } yield return(new WaitForEndOfFrame()); } nextStep.Invoke(); }
/// <summary> /// 添加改变参数的事件 /// </summary> /// <param name="para">参数类型</param> /// <param name="changeMode">改变的模式,(增加到、减少到、变化到)</param> /// <param name="changeValue">改变的值</param> /// <param name="valueOffset">改变的值的上下偏移</param> /// <param name="delay">延迟</param> /// <param name="duration">变化的持续时间</param> /// <param name="intMode">变化的插值方式</param> /// <param name="repeatCount">重复次数</param> /// <param name="repeatInterval">重复的时间间隔</param> public void AddParaChangeEvent(BulletParaType para, ParaChangeMode changeMode, ParaChangeValue value, int delay, float duration, InterpolationMode intMode, int repeatCount, int repeatInterval) { BulletParasChangeData changeData = CreateChangeData(para, intMode); changeData.changeMode = changeMode; changeData.changeValue = value; changeData.delay = delay; changeData.changeTime = 0; // duration小于等于0时默认设置为1,以免报错 if (duration <= 0) { duration = 1; } changeData.changeDuration = duration; changeData.repeatCount = repeatCount; changeData.repeatInterval = repeatInterval; _changeList.Add(changeData); _listCount++; }
public static string GetString(InterpolationMode interpolation) { switch (interpolation) { case InterpolationMode.Undefined: return(""); case InterpolationMode.Centroid: return("centroid"); case InterpolationMode.Linear: return("linear"); case InterpolationMode.NoInterpolation: return("nointerpolation"); default: return(null); } }
/// <summary> /// sets The quality of the drawing to the given graphics. /// </summary> /// <param name="e">The Graphics to set the quality</param> /// <param name="smoothingMode">Gets or sets the rendering quality for this System.Drawing.Graphics.</param> /// <param name="textRenderingHint"></param> /// <param name="pixelOffsetMode">Gets or set a value specifying how pixels are offset during rendering of this </param> /// <param name="interpolationMode">Gets or sets the interpolation mode associated with this System.Drawing.Graphics.</param> /// <param name="compositingQuality">Gets or sets the rendering quality of composited images drawn to this System.Drawing.Graphics.</param> public void SetQuality(Graphics e, SmoothingMode smoothingMode = SmoothingMode.Default, TextRenderingHint textRenderingHint = TextRenderingHint.ClearTypeGridFit, PixelOffsetMode pixelOffsetMode = PixelOffsetMode.Default, InterpolationMode interpolationMode = InterpolationMode.Default, CompositingQuality compositingQuality = CompositingQuality.Default) { try { e.SmoothingMode = smoothingMode; e.PixelOffsetMode = pixelOffsetMode; e.InterpolationMode = interpolationMode; e.CompositingQuality = compositingQuality; e.TextRenderingHint = textRenderingHint; } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } }
public HomographicImageTransformer(RegistrationDefinition registration, InterpolationMode interpolationMode) : base(registration, interpolationMode) { List <PositionAssociation> associationList = registration.GetAssociationList(); TransformationStyle arg_15_0 = registration.warpStyle; int count = associationList.Count; JamaMatrix jamaMatrix = new JamaMatrix(count, 2); JamaMatrix jamaMatrix2 = new JamaMatrix(count, 2); for (int i = 0; i < count; i++) { LatLon latlon = associationList[i].sourcePosition.pinPosition.latlon; jamaMatrix.SetElement(i, 0, latlon.lon); jamaMatrix.SetElement(i, 1, latlon.lat); LatLon latLon = MercatorCoordinateSystem.LatLonToMercator(associationList[i].globalPosition.pinPosition.latlon); jamaMatrix2.SetElement(i, 0, latLon.lon); jamaMatrix2.SetElement(i, 1, latLon.lat); } }
public static Bitmap Resize(this Image image, Size size, InterpolationMode mode) { if (image == null || size.IsEmpty) { return(null); } var resizedImage = new Bitmap(size.Width, size.Height, image.PixelFormat); resizedImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); using (var g = System.Drawing.Graphics.FromImage(resizedImage)) { var location = new Point(0, 0); g.InterpolationMode = mode; g.DrawImage(image, new Rectangle(location, size), new Rectangle(location, image.Size), GraphicsUnit.Pixel); } return(resizedImage); }
public static Bitmap Resize(this Bitmap i, int width, int height, InterpolationMode mode = InterpolationMode.HighQualityBicubic) { Bitmap r = new Bitmap(width, height); r.SetResolution(i.HorizontalResolution, i.VerticalResolution); using (Graphics graphics = Graphics.FromImage(r)) { graphics.InterpolationMode = mode; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.CompositingMode = CompositingMode.SourceCopy; graphics.SmoothingMode = SmoothingMode.HighQuality; using (ImageAttributes wrapMode = new ImageAttributes()) { //This fixes the antialiasing on the edges of the image wrapMode.SetWrapMode(WrapMode.TileFlipXY); graphics.DrawImage(i, new Rectangle(0, 0, r.Width, r.Height), 0, 0, i.Width, i.Height, GraphicsUnit.Pixel, wrapMode); } } return(r); }
/// <summary> /// Resizes the image. /// </summary> /// <param name="self">The self.</param> /// <param name="newSize">The new size.</param> /// <param name="compositingQuality">The compositing quality.</param> /// <param name="interpolationMode">The interpolation mode.</param> /// <param name="smoothingMode">The smoothing mode.</param> /// <returns>A resized bitmap.</returns> public static Bitmap Resize( this Image self, Size newSize, CompositingQuality compositingQuality = CompositingQuality.Default, InterpolationMode interpolationMode = InterpolationMode.Default, SmoothingMode smoothingMode = SmoothingMode.Default) { var result = new Bitmap(newSize.Width, newSize.Height); using (Graphics graphics = Graphics.FromImage(result)) { graphics.CompositingQuality = compositingQuality; graphics.InterpolationMode = interpolationMode; graphics.SmoothingMode = smoothingMode; graphics.DrawImage(self, new Rectangle(0, 0, result.Width, result.Height)); } return(result); }
public static Bitmap Resize(Bitmap bmp, int width, int height) { InterpolationMode mode = InterpolationMode.NearestNeighbor; Rectangle rct = new Rectangle(0, 0, width, height); Bitmap tmp = new Bitmap(width, height); tmp.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution); using (Graphics g = Graphics.FromImage(tmp)) { g.InterpolationMode = mode; using (ImageAttributes attributes = new ImageAttributes()) { attributes.SetWrapMode(WrapMode.TileFlipXY); GraphicsUnit unit = GraphicsUnit.Pixel; g.DrawImage(bmp, rct, 0, 0, bmp.Width, bmp.Height, unit, attributes); } } return(tmp); }
protected Image ResizeImageJob(Image input, System.Windows.Size newSize, InterpolationMode mode) { try { int originalWidth, originalHeight; originalWidth = input.Width; originalHeight = input.Height; Bitmap newImage = new Bitmap((int)newSize.Width, (int)newSize.Height); Graphics g = Graphics.FromImage(newImage); g.InterpolationMode = mode; g.DrawImage(input, new Rectangle(0, 0, newImage.Width, newImage.Height), 0, 0, input.Width, input.Height, GraphicsUnit.Pixel); g.Dispose(); return((Image)newImage); } catch (Exception ex) { Trace.TraceError(ex.ToString()); return(input); } }
public ImgThumb(secImg ig, Point sz, SizeFlags sizef, SmoothingMode smode, InterpolationMode imode, Color Matte) { siz = sizef; SM = smode; IP = imode; mattecolor = Matte; imgSize = sz; imgRef = ig; sf = scaleFlags.autoScale; p = new Pen(Color.White); b = new SolidBrush(Color.Navy); if (imgRef.Attributes.ContainsKey("rotation")) { this.Rotate = imgRef; } else { imgpath = imgRef.Path; } update(); }
/// <summary> /// マウスホイール /// </summary> /// <param name="e"></param> protected override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); if (e.Delta > 0) { // 拡大 if (MatAffine.Elements[0] < ZOOM_MAX) // X方向の倍率を代表してチェック { // ポインタの位置周りに拡大 ScaleAt(ref MatAffine, ZOOM_UNIT, e.Location); if (MatAffine.Elements[0] > 1) { interpolationMode = InterpolationMode.NearestNeighbor; graphics.InterpolationMode = interpolationMode; } isScaleChanged = true; } } else { // 縮小 if (MatAffine.Elements[0] > minScale) // X方向の倍率を代表してチェック { // ポインタの位置周りに縮小 ScaleAt(ref MatAffine, 1.0f / ZOOM_UNIT, e.Location); if (MatAffine.Elements[0] < 1) { interpolationMode = InterpolationMode.HighQualityBicubic; graphics.InterpolationMode = interpolationMode; } } else { isScaleChanged = false; } } // 画像の描画 DrawImage(); }
public static void DrawIcon(Graphics graphics, Rectangle rect, Image icon, Color multiplyColor) { if (graphics == null || icon == null) { return; } if (multiplyColor == Color.White) { DrawIcon(graphics, rect, icon); return; } using (ImageAttributes attributes = new ImageAttributes()) { ColorMatrix cm = new ColorMatrix { Matrix00 = multiplyColor.R / 255f, Matrix11 = multiplyColor.G / 255f, Matrix22 = multiplyColor.B / 255f }; attributes.SetColorMatrix(cm); InterpolationMode lastInterpolationMode = graphics.InterpolationMode; graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; graphics.DrawImage( icon, CreateRectFromAspect(rect, icon.Size), 0, 0, icon.Width, icon.Height, GraphicsUnit.Pixel, attributes); graphics.InterpolationMode = lastInterpolationMode; } }
void drawTo(Graphics g) { // Background // Brush brushBackground = new SolidBrush(BackColor); // g.FillRectangle(brushBackground, this.ClientRectangle); Vector center = Vector.Zero; Vector size = Vector.Zero; GraphicsUtil.TextPosition titlePosition = null; getWfCoords(ref center, ref size, ref titlePosition); if (titlePosition != null) { Brush titleBrush = new SolidBrush(_titleColor); titlePosition.drawText(g, _titleFont, titleBrush, _title); } Rectangle fr = VectorRect.FromCenterSize(center, size).rectangle; g.DrawRectangle(framePen, fr.Left - 1, fr.Top - 1, fr.Width + 2, fr.Height + 2); if ((bmap == null) || (data.Length != bmap.Height * bmap.Width * 4)) { bmap = new Bitmap(_timeSteps, _ySteps, PixelFormat.Format32bppRgb); } BitmapData bmd = bmap.LockBits(new Rectangle(0, 0, bmap.Width, bmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb); Marshal.Copy(data, 0, bmd.Scan0, bmap.Width * bmap.Height * 4); bmap.UnlockBits(bmd); InterpolationMode imode = g.InterpolationMode; PixelOffsetMode pmode = g.PixelOffsetMode; g.InterpolationMode = InterpolationMode.NearestNeighbor; g.PixelOffsetMode = PixelOffsetMode.Half; g.DrawImage(bmap, fr, 0, 0, bmap.Width, bmap.Height, GraphicsUnit.Pixel); g.InterpolationMode = imode; g.PixelOffsetMode = pmode; // needsRedraw = false; }
/// <summary> /// Initializes a new instance of the <see cref="ResampleForm"/> class. /// </summary> /// <param name="horizontalResolution">The horizontal resolution of the image.</param> /// <param name="verticalResolution">The vertical resolution of the image.</param> /// <param name="interpolationMode">The image interpolation mode.</param> /// <param name="dlgCaption">Title text.</param> public ResampleForm(float horizontalResolution, float verticalResolution, InterpolationMode interpolationMode, string dlgCaption, bool resample) { InitializeComponent(); this.Text = dlgCaption; _horizontalResolution = horizontalResolution; _verticalResolution = verticalResolution; interpolationModeComboBox.Items.Add(InterpolationMode.Default); interpolationModeComboBox.Items.Add(InterpolationMode.Low); interpolationModeComboBox.Items.Add(InterpolationMode.High); interpolationModeComboBox.Items.Add(InterpolationMode.Bilinear); interpolationModeComboBox.Items.Add(InterpolationMode.Bicubic); interpolationModeComboBox.Items.Add(InterpolationMode.NearestNeighbor); interpolationModeComboBox.Items.Add(InterpolationMode.HighQualityBilinear); interpolationModeComboBox.Items.Add(InterpolationMode.HighQualityBicubic); interpolationModeComboBox.SelectedItem = interpolationMode; nHorizontalResolution.Value = Math.Min((decimal)horizontalResolution, nHorizontalResolution.Maximum); nVerticalResolution.Value = Math.Min((decimal)verticalResolution, nVerticalResolution.Maximum); }
static public SKFilterQuality ToSKFilterQuality(this InterpolationMode interpolation) { switch (interpolation) { case InterpolationMode.Low: return(SKFilterQuality.Low); case InterpolationMode.NearestNeighbor: return(SKFilterQuality.None); case InterpolationMode.Bilinear: case InterpolationMode.HighQualityBilinear: return(SKFilterQuality.Medium); case InterpolationMode.Bicubic: case InterpolationMode.HighQualityBicubic: return(SKFilterQuality.High); } return(SKFilterQuality.None); }
public static Bitmap GdiResize(Image photo, int width, int height, InterpolationMode interpolationMode = InterpolationMode.HighQualityBicubic, SmoothingMode smoothingMode = SmoothingMode.HighQuality, PixelOffsetMode pixelMode = PixelOffsetMode.HighQuality, CompositingQuality compositingQuality = CompositingQuality.HighQuality, CompositingMode compositingMode = CompositingMode.SourceOver ) { var resized = new Bitmap(width, height); using (var graphics = Graphics.FromImage(resized)) { graphics.CompositingQuality = compositingQuality; graphics.InterpolationMode = interpolationMode; graphics.CompositingMode = compositingMode; graphics.SmoothingMode = smoothingMode; graphics.PixelOffsetMode = pixelMode; graphics.DrawImage(photo, 0, 0, width, height); } return(resized); }
/// <summary> /// Resize the image to the specified width and height. /// </summary> /// <param name="image">The image to resize.</param> /// <param name="width">The width to resize to.</param> /// <param name="height">The height to resize to.</param> /// <param name="mode">The interpolation mode to use in the resampling.</param> /// <returns>The resized image.</returns> public static Bitmap Resize(this Image image, int width, int height, InterpolationMode mode = InterpolationMode.HighQualityBicubic) { var destImage = new Bitmap(width, height); destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); using (var graphics = Graphics.FromImage(destImage)) { graphics.CompositingMode = CompositingMode.SourceCopy; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = mode; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.SmoothingMode = SmoothingMode.HighQuality; using (var wrapMode = new ImageAttributes()) { wrapMode.SetWrapMode(WrapMode.TileFlipXY); graphics.DrawImage(image, new Rectangle(0, 0, width, height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); } } return(destImage); }
public int GetTexture(string path, InterpolationMode interpolation, out int width, out int height) { int id = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, id); using (BitmapFactory.Options options = new BitmapFactory.Options() { InScaled = false }) using (Stream stream = GetStream(path)) using (Bitmap bitmap = BitmapFactory.DecodeStream(stream, null, options)) { GLUtils.TexImage2D((int)TextureTarget.Texture2D, 0, bitmap, 0); width = bitmap.Width; height = bitmap.Height; } GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)interpolation); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)interpolation); return(id); }