| 886 | |
| 887 | |
| 888 | void Viewer::LoadCurrImage(bool forceReload) |
| 889 | { |
| 890 | tAssert(CurrImage); |
| 891 | bool imgJustLoaded = false; |
| 892 | |
| 893 | if (!CurrImage->IsLoaded()) |
| 894 | { |
| 895 | imgJustLoaded = CurrImage->Load(); |
| 896 | } |
| 897 | else if (forceReload) |
| 898 | { |
| 899 | CurrImage->Unbind(); |
| 900 | CurrImage->Unload(true); |
| 901 | imgJustLoaded = CurrImage->Load(); |
| 902 | CurrImage->Bind(); |
| 903 | } |
| 904 | |
| 905 | AutoPropertyWindow(); |
| 906 | Gutil::SetWindowTitle(); |
| 907 | if (!CurrImage->IsLoaded()) |
| 908 | { |
| 909 | tPrintf("Warning: Failed to load [%s]\n", tGetFileName(CurrImage->Filename).Chr()); |
| 910 | return; |
| 911 | } |
| 912 | |
| 913 | Config::ProfileData& profile = Config::GetProfileData(); |
| 914 | if |
| 915 | ( |
| 916 | profile.AutoPlayAnimatedImages && !profile.ShowImportRaw && |
| 917 | (CurrImage->GetNumFrames() > 1) && |
| 918 | FileTypes_MultiFrame.Contains(CurrImage->Filetype) |
| 919 | ) |
| 920 | { |
| 921 | CurrImage->FramePlayLooping = true; |
| 922 | CurrImage->FramePlayRev = false; |
| 923 | CurrImage->Play(); |
| 924 | } |
| 925 | |
| 926 | ResetPan(); |
| 927 | Request_CropLineConstrain = true; |
| 928 | |
| 929 | // We only need to consider unloading an image when a new one is loaded... in this function. |
| 930 | // We currently do not allow unloading when in slideshow and the frame duration is small. |
| 931 | bool slideshowSmallDuration = SlideshowPlaying && (profile.SlideshowPeriod < 0.5f); |
| 932 | if (imgJustLoaded && !slideshowSmallDuration) |
| 933 | { |
| 934 | ImagesLoadTimeSorted.Sort(Compare_ImageLoadTimeAscending); |
| 935 | |
| 936 | int64 usedMem = 0; |
| 937 | for (tItList<Image>::Iter iter = ImagesLoadTimeSorted.First(); iter; iter++) |
| 938 | usedMem += int64((*iter).Info.MemSizeBytes); |
| 939 | |
| 940 | int64 allowedMem = int64(profile.MaxImageMemMB) * 1024 * 1024; |
| 941 | if (usedMem > allowedMem) |
| 942 | { |
| 943 | tPrintf("Used image mem (%|64d) bigger than max (%|64d). Unloading.\n", usedMem, allowedMem); |
| 944 | for (tItList<Image>::Iter iter = ImagesLoadTimeSorted.First(); iter; iter++) |
| 945 | { |