New, better optimized FreeImage Resize wrapper

For cases when the full source image is being resized, we can skip the
creation of some temporary DIBs, improving performance noticeably.
Optimize layer thumbnail generation

Over the past few months, the creation of new resize-related functions
mean we can strip this function down to just a few lines of code *and*
get better performance from it.
Optimize full image thumbnail creation

As the image must be composited on-the-fly for any thumbnail request,
it's to our benefit to optimize thumbnail creation as much as possible.
Optimize unsaved changes dialog image preview

Previously, it always requested a full-size image composite.
GetCompositedRect is much faster!
Fix image save state tracking

Undo/Redo changes made our save state checks off-by-one, so images were
being erroneously flagged as "not saved in their current state" even
when they were.