faster rotate and resize of images

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is it just me or does anybody else find the Image.RotateFlip method kind of
slow? (I'm comparing to commercial softwares). Same for resizing. I'm using

sourceImage = system.drawing.bitmap.fromFile(filestring)
newImage = new bitmpa(sourceImage, newWidth, newHeight)
newImage.save(newFileString)

Anyone knows of any faster methods?
 
thanks Peter. I just went thru your code. It's almost the same as what I have.
what dou you call slow? Because I also resize images in my app and you don't
even see or notice that it happens

Well, for single images, you can't feel it, but in a batch job, like
100 images, the 'slowness' can be felt.

many thanks btw :-)
 
Hi Chad, could you post your code? It's always good to see how someone else
does something.
And how long does it take for you to resize 100 images? With a program I've
written about a year ago that creates thumbnails and resizes the original
images it takes 47sec to resize 504 images and create 504 thumbnails which
in my opinion is acceptable. But you don't need to forget that gdi+ just
isn't super fast. :-)

Greetz Peter
 
I had read somewhere that VB.Net 2005 would include a faster GDI+...is this
correct?
 
hi Peter, here's the code. Btw, it takes about 60sec to do 100images. But
then again, it really depends on the hdd. RAID will perform better, though.

'*******************************************************

For i As Integer = 0 To UBound(ImageString)

Dim sourceImg As System.Drawing.Image
Dim destImg As System.Drawing.Bitmap

sourceImg = System.Drawing.Bitmap.FromFile(ImageString(i)) 'image
destImg = New Bitmap(sourceImg, newWidth, newHeight) 'constructor

destFileName = destFolder & "\" & Path.GetFileName(ImageString(i))

If ext = ".bmp" Then
destImg.Save(destFileName,System.Drawing.Imaging.ImageFormat.Bmp)

ElseIf ext = ".jpg" Then
destImg.Save(destFileName,System.Drawing.Imaging.ImageFormat.jpeg)

End If


sourceImg.Dispose()
destImg.Dispose()

sourceImg = Nothing
destImg = Nothing

Next


'*******************************************************
 
Hi Chad, I woul get
Dim sourceImg As System.Drawing.Image
Dim destImg As System.Drawing.Bitmap

out of the for loop

And maybe you can try this code to resize the images but I don't think it
will be much faster, the example is with fixed values which ofcourse isn't
the correct way to work.

sourceImg = DirectCast(Bitmap.FromFile(files(i)), Bitmap)
destImg = New Bitmap(400, 400)
destImg .SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(destImg )
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(sourceImg , New Rectangle(0, 0, 400, 400), 0, 0, sourceImg
..Width, sourceImg .Height, GraphicsUnit.Pixel)
g.Dispose()
imgOrg.Dispose()

And as you said yourself it also has got a lot to do with your computer
speed because I tested my method and your method on my pc And they both took
about 17 seconds (16.9 and 17.7 seconds) to resize 100 images

Greetz Peter
 
yup, I tried it and it's about the same timings. Guess it's the best GDI+ can
do :-)

Chad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top