We use the same method to set the width and height of our second
thumbnail. However rather than drawing the image from the file
again we use the DrawCanvas method to draw canvas1.
There are a number of reasons why this technique is faster than
drawing the file again. The image is already in memory and not on
the disk, it is already decompressed and it is smaller. Using a
single processor PII 300 and a test image approximately 400 pixels
square, canvas1.DrawFile took 156 milliseconds but
canvas2.DrawCanvas took only 27!
After we've finished drawing canvas1 onto canvas2 we can dispose
of it using the Clear method (this is a safe way of releasing
almost all of the memory it uses immediately). We then save out the
second thumbnail.
[VBScript]
canvas2.Width = 160
canvas2.Height = (160 * rect.Height) / rect.Width
canvas2.DrawCanvas canvas1.Image, "size=" & canvas2.Width &
"," & canvas2.Height
canvas1.Clear
canvas2.SaveAs outpath2, ""
|