-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetPixelData.cpp
More file actions
62 lines (51 loc) · 1.39 KB
/
GetPixelData.cpp
File metadata and controls
62 lines (51 loc) · 1.39 KB
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
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "GetPixelData.h"
GetPixelData::GetPixelData(int w, int h): width(w),height(h)
{
}
void GetPixelData::copyAlpha(FIBITMAP* image, std::vector<int> &edgeLoc)
{
int i, j,count = 0;
int tmp;
for (i = 1; i < height - 1; i++)
{
for (j = 1; j < width - 1; j++)
{
tmp = 0;
FreeImage_GetPixelColor(image, j, i, &color);
tmp -= color.rgbReserved * 8;
FreeImage_GetPixelColor(image, j + 1, i, &color);
tmp += color.rgbReserved;
FreeImage_GetPixelColor(image, j - 1, i, &color);
tmp += color.rgbReserved;
FreeImage_GetPixelColor(image, j, i + 1, &color);
tmp += color.rgbReserved;
FreeImage_GetPixelColor(image, j, i - 1, &color);
tmp += color.rgbReserved;
FreeImage_GetPixelColor(image, j + 1, i - 1, &color);
tmp += color.rgbReserved;
FreeImage_GetPixelColor(image, j - 1, i - 1, &color);
tmp += color.rgbReserved;
FreeImage_GetPixelColor(image, j + 1, i + 1, &color);
tmp += color.rgbReserved;
FreeImage_GetPixelColor(image, j - 1, i + 1, &color);
tmp += color.rgbReserved;
if (tmp != 0)
{
edgeLoc[count] = j + i * width;
count++;
}
}
}
std::vector<int> r(width * height - count);
edgeLoc.erase(remove_if(edgeLoc.begin(), edgeLoc.end(), [](const int i) {return i == -1; }), edgeLoc.end());
edgeLoc.shrink_to_fit();
}
int GetPixelData::getWidth()
{
return width;
}
int GetPixelData::getHeight()
{
return height;
}