Tuesday 15 February 2011

c# - Size of image increases after cropping -


I have the C # code to crop images.

When I crop the image (size: 191 KB, my C # code), the resulting result increases the image (dazzle) (size: 2.44 MB)

Please tell me That's why the size increases after the crop .. ???

  bitmap source = new bitmap (@ "F: \ images \", "+ +" kernel "+ + + j +" .jpg "); Rectangle section = new rectangle (new point (0, 0), new shape (1362, 761)); Bitmap croped image = crop image (source, section); Cropped image. Save (@ "File Path \" "+ i +" Colonel "+ j +" .jpg "); Public bitmap crop image (bitmap source, rectangle volume) {// An empty bitmap which will keep crop image bitmap BMP = new bitmap (section with section, height); Graphics G = Graphics. Frame Image (BMP); // Draw the given area (section) of the source image // at 0,0 on empty bitmap (BMP) g.DrawImage (source, 0, 0, article, GraphicsUnit.Pixel). Return BMP; Telepathic power: You are talking about the size of the file on the disk and are comparing the original compressed; File (potential JPG) with the saved version in non-compressed format (potential BMP)  

Correct: Save the baked image in compressed format.

2 arguments lets you specify the format i.e. in contrast to a logic version that you use in your sample).

Example from the article:

  // Create a bitmap from the button image processing. Bitmap BMP1 = new bitmap (typef (button), "button.bmp"); // Save image as a GIF Bmp1.Save ("c: \\ button.gif", system, drawing.imaging.imageformat.gif);    

No comments:

Post a Comment