tags:

views:

39

answers:

1

I am trying to understand why after croping an image in .NET i end up with an image 3 times the size of the original image. Listed below is the code i am using to crop the image

  Private Shared Function CropImage(ByVal img As Image, ByVal cropArea As Rectangle) As Image
      Dim bmpImage As Bitmap = New Bitmap(img)
      Dim bmpCrop As Bitmap = bmpImage.Clone(cropArea, img.PixelFormat)
      Return CType(bmpCrop, Image)
   End Function

where img is the original image loaded from file into an image object.

How can i achieve a loss less cropping of my image?

+1  A: 

Take a look at the second answer to this question:

http://stackoverflow.com/questions/249587/high-quality-image-scaling-c

That code should help. The problem is that the .NET image handling library defaults the System.Drawing.Imaging.Encoder.Quality setting to 100%, which is literally three times the size of 90%, which has no visible difference in quality. Use the code in that question to save your image at lower quality settings and you should see a big difference in the size of your file.

Dave Swersky
It works! thank you!
zaladane