You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to convert the following code to resize an image:
Bitmap newImage = new Bitmap(targetSize.Width, targetSize.Height, oldImage.PixelFormat);
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(newImage))
using (var attributes = new System.Drawing.Imaging.ImageAttributes())
{
// need to set the following attribute mode to fix the border issue
// https://stackoverflow.com/questions/1861305/c-sharp-resized-images-have-black-borders
attributes.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.DrawImage(oldImage, System.Drawing.Rectangle.FromLTRB(0, 0, targetSize.Width, targetSize.Height), 0, 0, oldImage.Width, oldImage.Height, GraphicsUnit.Pixel, attributes);
}
Currently, I'm resizing the image like this:
var newImage = SixLabors.ImageSharp.Image.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(oldImageBytes, out IImageFormat format);
newImage.Mutate(x => x.Resize(width, height, new BicubicResampler()));
Is it the best way? Are there settings equivalent to WrapMode.TileFlipXY and HighQualityBicubic in the library?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to convert the following code to resize an image:
Currently, I'm resizing the image like this:
Is it the best way? Are there settings equivalent to WrapMode.TileFlipXY and HighQualityBicubic in the library?
Beta Was this translation helpful? Give feedback.
All reactions