- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
#include "stdafx.h"
#include <Windows.h>
#pragma comment(lib, "gdiplus.lib")
#include <gdiplus.h>
#include <vector>
#include <chrono>
wchar_t* path =
L"здесь был путь*";
using namespace Gdiplus;
using namespace std::chrono;
int main()
{
GdiplusStartupInput gdipInput;
ULONG_PTR gdipToken;
GdiplusStartup(&gdipToken, &gdipInput, NULL);
HWND progman = FindWindowW(L"Progman", NULL);
HWND workerw = GetWindow(progman, GW_HWNDPREV);
HDC dc = GetDC(workerw);
std::vector<Bitmap*> images;
WIN32_FIND_DATAW fdata = { 0 };
HANDLE hFind = FindFirstFileW(path, &fdata);
int
scrWidth = GetSystemMetrics(SM_CXSCREEN),
scrHeight = GetSystemMetrics(SM_CYSCREEN);
UINT width, height;
bool isInfoRetrieved = false;
std::wstring wmp(path);
wmp = wmp.substr(0, wmp.length() - 1);
do {
Bitmap* bmp = Bitmap::FromFile((wmp + fdata.cFileName).c_str());
if (bmp->GetLastStatus() != Gdiplus::Ok) continue;
int width = bmp->GetWidth();
int height = bmp->GetHeight();
double ratio = (double)width / height;
if (ratio > 1) {
width = scrWidth;
height = scrWidth / ratio;
}
else {
width = scrHeight * ratio;
height = scrHeight;
}
Bitmap* resized = new Bitmap(width, height, PixelFormat32bppRGB);
Graphics* resizedGr = Graphics::FromImage(resized);
resizedGr->DrawImage(bmp, 0, 0, width, height);
delete resizedGr;
delete bmp;
images.push_back(resized);
} while (FindNextFile(hFind, &fdata));
FindClose(hFind);
Graphics* mainGr = Graphics::FromHDC(dc);
Bitmap* bufBmp = new Bitmap(scrWidth, scrHeight, PixelFormat32bppRGB);
Graphics* bufGr = Graphics::FromImage(bufBmp);
int count = images.size();
int gap = 1000 / count;
while (true) {
for (auto it = images.begin(); it != images.end(); it++) {
milliseconds ms1 = duration_cast<milliseconds>(
system_clock::now().time_since_epoch());
Bitmap* bmp = *it;
int width = bmp->GetWidth();
int height = bmp->GetHeight();
int xOfs = (scrWidth - width) / 2, yOfs = (scrHeight - height) / 2;
bufGr->Clear(Color::Black);
bufGr->DrawImage(*it, xOfs, yOfs, width, height);
mainGr->DrawImage(bufBmp, 0, 0);
milliseconds ms2 = duration_cast<milliseconds>(
system_clock::now().time_since_epoch());
milliseconds delta = ms2 - ms1;
if (gap > delta.count())
Sleep(gap - delta.count());
}
}
return 0;
}