forked from BYOBMO/BMOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPhoto.cpp
More file actions
51 lines (38 loc) · 849 Bytes
/
CPhoto.cpp
File metadata and controls
51 lines (38 loc) · 849 Bytes
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
41
42
43
44
45
46
47
48
49
50
51
#include "CPhoto.h"
#include "CApplication.h"
CPhoto::CPhoto() :CWindow()
{
}
void CPhoto::LoadPicture(std::string path)
{
//printf("LoadPicture %s\n", path.c_str());
SDL_Renderer* renderer = CApplication::sRenderer;
CSurfWindow* surf = new CSurfWindow();
SDL_Texture* oldTexture;
oldTexture = SDL_GetRenderTarget(renderer);
surf->LoadImage(path);
SDL_SetRenderTarget(renderer, mTexture);
surf->DrawTextureScaled(renderer, Width(), GetHeight());
SDL_SetRenderTarget(renderer, oldTexture);
delete(surf);
}
void CPhoto::Draw()
{
SDL_Rect src, dst;
src.x = 0;
src.y = 0;
src.w = Width();
src.h = GetHeight();
dst.x = 0;
dst.y = 0;
dst.w = mParent->Width();
dst.h = mParent->GetHeight();
CTexture::Draw(&src, &dst, 0.0);
}
void CPhoto::KeyDown(SDL_KeyboardEvent e)
{
if (mParent != NULL)
{
mParent->KeyDown(e);
}
}