-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTexture.cpp
More file actions
36 lines (30 loc) · 756 Bytes
/
Texture.cpp
File metadata and controls
36 lines (30 loc) · 756 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
#include "Texture.h"
Texture::Texture(IWICBitmap* texture)
{
texture->GetSize(&textureWidth, &textureHeight);
WICRect rcLock = { 0, 0, textureWidth, textureHeight };
IWICBitmapLock* textureLock;
texture->Lock(&rcLock, WICBitmapLockRead, &textureLock);
textureMem = (int*)malloc(textureHeight * textureWidth * 4);
texture->CopyPixels(&rcLock, textureWidth * 4, textureHeight * textureWidth * 4, (byte*)textureMem);
}
Texture::~Texture()
{
delete textureMem;
}
UINT Texture::GetWidth()
{
return textureWidth;
}
UINT Texture::GetHeight()
{
return textureHeight;
}
int Texture::GetValue(int x, int y)
{
if (x >= textureWidth)
x = textureWidth - 1;
if (y >= textureHeight)
y = textureHeight - 1;
return textureMem[y * textureWidth + x];
}