- 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
QVector<Line> Converter::convert(QImage &image, Modes mode/*, int left, int top, int right, int bottom*/){
QVector<Line> result;
/* if(left < 0) left = 0;
if(top < 0) top = 0;
//if(right > image.width()) right = image.width();
//if(bottom > image.height()) bottom = image.height();
//points.clear();
//pix.fill(Qt::black);
if(left > right){
left ^= right;
right ^= left;
left ^= right;
}
if(top > bottom){
top ^= bottom;
bottom ^= top;
top ^= bottom;
}*/
int left = 0,top = 0,right = image.width(),bottom = image.height();
for( int i = left; i < right; ++i){
for( int j = top; j < bottom; ++j){
Line p;
p.x1 = p.x2 = i;
p.y1 = p.y2 = j;
p.z1 = qGray(image.pixel(i,j));
p.c = p.z1;
QVector<int> v;
if(i!=left) v.push_back(qGray(image.pixel(i-1,j)));
if(i < right-1) v.push_back(qGray(image.pixel(i+1,j)));
if(j!=top) v.push_back(qGray(image.pixel(i,j-1)));
if(j < bottom-1) v.push_back(qGray(image.pixel(i,j+1)));
if(i!=left && j!= top) v.push_back(qGray(image.pixel(i-1,j-1)));
if(i < right-1 && j!=top) v.push_back(qGray(image.pixel(i+1,j-1)));
if(j < bottom-1 && i!=left) v.push_back(qGray(image.pixel(i-1,j+1)));
if(i < right-1 && j < bottom-1) v.push_back(qGray(image.pixel(i+1,j+1)));
int min = *(std::min_element(v.begin(),v.end()));
if(min < qGray(image.pixel(i,j))){
/* for( unsigned k = 0; k < p.c-min; ++k){
Point p0;
p0.x = i;
p0.y = j;
p0.z = qGray(image.pixel(i,j))-(k+1);
p0.c = qGray(image.pixel(i,j));
points.push_back(p0);
}*/
p.z2 = p.z1 - min;
}else{
p.z2 = p.z1;
}
result.push_back(p);
}
}
/*origin.x = 0;
origin.y = 0;
origin.z = 0.0;*/
switch (mode) {
case ISO:
rotate(result, 3.1415/180*35.2,3.1415/4,-3.1415/4);
//rotate(result, 0,,0);
//rotate(result, 0,0,-3.1415/4);
break;
case BOTTOM:
rotate(result, 3.1415/180*90,0,0);
break;
case LEFT:
rotate(result, 3.1415/180*90,0,0);
rotate(result, 0, 3.1415/180*90,0);
break;
case RIGHT:
rotate(result, 3.1415/180*90,0,0);
rotate(result, 0, -3.1415/180*90,0);
break;
default:
break;
}
return result;
}