141 |
const int PART_HEIGHT = SCREEN_HEIGHT/PART; |
const int PART_HEIGHT = SCREEN_HEIGHT/PART; |
142 |
|
|
143 |
// randomly choose upper-left corner (zoomxypos is always visible) |
// randomly choose upper-left corner (zoomxypos is always visible) |
144 |
int x = zoomxpos - IntegerRand(16, PART_WIDTH-16-1); |
int x, y; |
145 |
int y = zoomypos - IntegerRand(16, PART_HEIGHT-16-1); |
for (int trials = 0; trials<5; ++trials) { |
146 |
|
x = zoomxpos - IntegerRand(16, PART_WIDTH-16-1); |
147 |
|
y = zoomypos - IntegerRand(16, PART_HEIGHT-16-1); |
148 |
|
|
149 |
|
x = min(max(8, x), WIDTH-(PART_WIDTH+24)); |
150 |
|
if (zoomypos<48 || zoomypos >= (GAME_HEIGHT-48)) |
151 |
|
y = min(max(16, y), GAME_HEIGHT-(PART_HEIGHT+16)); |
152 |
|
else |
153 |
|
y = min(max(48, y), GAME_HEIGHT-(PART_HEIGHT+48)); // skip first and last row |
154 |
|
|
155 |
|
x = (x/32)*32+24; |
156 |
|
y = (y/32)*32+16; |
157 |
|
|
158 |
x = min(max(0, x), WIDTH-(PART_WIDTH+16-1)); |
int xoff = zoomxpos-x; |
159 |
y = min(max(0, y), GAME_HEIGHT-(PART_HEIGHT+16-1)); |
int yoff = zoomypos-y; |
160 |
|
|
161 |
x = (x/32)*32+24; |
// fprintf(stderr, "xoff=%i, yoff=%i\n", xoff, yoff); |
162 |
y = (y/32)*32+16; |
|
163 |
|
if (xoff<72 || xoff>136 || yoff<37 || yoff>96) |
164 |
|
break; // no overlap with menu -> take it |
165 |
|
} |
166 |
|
|
167 |
Surface back(video::GetScreen()->get_surface()); |
Surface back(video::GetScreen()->get_surface()); |
168 |
Rect src_area(x, y, PART_WIDTH, PART_HEIGHT); |
Rect src_area(x, y, PART_WIDTH, PART_HEIGHT); |
169 |
Surface *src = Grab(&back, src_area); |
Surface *src = Grab(&back, src_area); |
170 |
|
|
171 |
// zoom 3 times to get softer image : |
const double stepsize = 0.3; // zoom multiple times for softer image |
172 |
{ |
for (double zoom = stepsize; zoom <= (1.0-stepsize/2); zoom += stepsize) { |
173 |
Surface *zoom1 = src->zoom(WIDTH/3, SCREEN_HEIGHT/3); |
int sx = int(zoom*WIDTH+0.5); |
174 |
Surface *zoom2 = src->zoom(WIDTH/6, SCREEN_HEIGHT/6); |
int sy = int(zoom*SCREEN_HEIGHT+0.5); |
175 |
zoomed = zoom1->zoom(WIDTH, SCREEN_HEIGHT); |
Surface *tmp = src->zoom(sx, sy); |
176 |
delete zoom2; |
|
177 |
delete zoom1; |
delete src; |
178 |
|
src = tmp; |
179 |
} |
} |
180 |
|
|
181 |
|
zoomed = src->zoom(WIDTH, SCREEN_HEIGHT); |
182 |
delete src; |
delete src; |
183 |
} |
} |
184 |
|
|