There is a tiff file that I want to trim. I tried to keep it in all formats, but when trimming it shrinks into a strip. With any other jpeg file, everything works, with tiff-no. Here is an example of a file for the test https://yadi.sk/i/Iqw3jv2wwQ3EV
public Bitmap CropImage(Image img) { // create a graphic path to hold the shape data GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); var points = new Point[] { new Point(85, 1111), new Point(934, 1111), new Point(934, 952), new Point(1642, 952), new Point(1642, 2000), new Point(85, 2000), new Point(85, 1111) }; GraphicsPath gp = new GraphicsPath(); gp.AddPolygon(points.ToArray()); Bitmap bmp1 = new Bitmap(2220, 2220); using (Graphics G = Graphics.FromImage(bmp1)) { G.Clip = new System.Drawing.Region(gp); G.DrawImage(img, 0, 0); pictureBox.Image = bmp1; return bmp1; } }
PixelFormatorResolutioncorrect one. - Alexander Petrov