Thanks no-one for your reply. I tried the function that you suggested, but it still crashes at the same line. It still crashes at dib = auxDIBImageLoad(Filename);. I get an Windows error saying it has generated errors and will need to be restarted. Does anyone have any other reason why this is not working?

- Sean