-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImgGDIItem.cpp
40 lines (32 loc) · 910 Bytes
/
ImgGDIItem.cpp
1
2
3
4
5
6
7
8
9
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
#include "ImgGDIItem.h"
#include "ImgItemHelper.h"
void ImgGDIItem::Load()
{
status_ = Status::Loading;
const auto bitmap = std::make_unique<Gdiplus::Bitmap>(filepath_.c_str(), FALSE);
lastgdiplusstatus_ = bitmap->GetLastStatus();
if (lastgdiplusstatus_ != Gdiplus::Status::Ok || bitmap->GetWidth() == 0)
{
status_ = Status::Error;
goto done;
}
width_ = bitmap->GetWidth();
height_ = bitmap->GetHeight();
if (width_ > targetwidth_ || height_ > targetheight_)
{
displaybuffer_ = ImgItemHelper::ResizeImage(bitmap.get(), targetwidth_, targetheight_);
}
else
{
displaybuffer_ = ImgItemHelper::GetBuffer(bitmap.get());
}
SetupDisplayParameters(true);
status_ = Status::Ready;
done:
SetEvent(loadedevent_);
}
void ImgGDIItem::Unload()
{
lastgdiplusstatus_ = Gdiplus::Status::Ok;
ImgItem::Unload();
}