Improved performance on drawing image. (2-10 times faster in some cases)

This commit is contained in:
spx 2011-11-02 09:19:37 +00:00
parent f1266f6815
commit cecd111869

View File

@ -225,25 +225,19 @@ Bitmap* CTintedImage::LoadImageFromFileHandle(HANDLE fileHandle, DWORD fileSize,
if (Ok == bitmap->GetLastStatus()) if (Ok == bitmap->GetLastStatus())
{ {
//////////////////////////////////////////// ////////////////////////////////////////////
// Workaround to avoid image corruption with JPEG in some cases // Convert loaded image to faster blittable bitmap (may increase memory usage slightly)
if (CSystem::GetOSPlatform() < OSPLATFORM_7)
{ {
GUID guid; Rect r(0, 0, bitmap->GetWidth(), bitmap->GetHeight());
bitmap->GetRawFormat(&guid); Bitmap* clone = new Bitmap(r.Width, r.Height, PixelFormat32bppPARGB);
if (guid == ImageFormatJPEG)
{ {
Rect r(0, 0, bitmap->GetWidth(), bitmap->GetHeight()); Graphics graphics(clone);
Bitmap* clone = new Bitmap(r.Width, r.Height, PixelFormat24bppRGB); graphics.DrawImage(bitmap, r, 0, 0, r.Width, r.Height, UnitPixel);
{
Graphics graphics(clone);
graphics.DrawImage(bitmap, r, 0, 0, r.Width, r.Height, UnitPixel);
}
delete bitmap;
bitmap = clone;
::GlobalFree(hBuffer);
hBuffer = NULL;
} }
delete bitmap;
bitmap = clone;
::GlobalFree(hBuffer);
hBuffer = NULL;
} }
//////////////////////////////////////////// ////////////////////////////////////////////
*ppCache = new ImageCache(bitmap, hBuffer); *ppCache = new ImageCache(bitmap, hBuffer);