src/sampler.cc
branchpyrit
changeset 92 9af5c039b678
parent 88 f7edb3b90816
child 93 96d65f841791
equal deleted inserted replaced
91:9d66d323c354 92:9af5c039b678
   221 				s->x = osax[osa_samp]/h + (Float)sx/h - (Float)w/h/2.0;
   221 				s->x = osax[osa_samp]/h + (Float)sx/h - (Float)w/h/2.0;
   222 				s->y = osay[osa_samp]/h + (Float)sy/h - 0.5;
   222 				s->y = osay[osa_samp]/h + (Float)sy/h - 0.5;
   223 			}
   223 			}
   224 			else
   224 			else
   225 			{
   225 			{
   226 				sx++;
       
   227 				if (sx >= w)
       
   228 				{
       
   229 					sx = 0;
       
   230 					sy++;
       
   231 				}
       
   232 				if (sy >= h)
       
   233 					return false;
       
   234 
       
   235 				if (subsample > 1)
   226 				if (subsample > 1)
   236 				{
   227 				{
   237 					// find next not interpolated pixel
   228 					// find next not interpolated pixel
   238 					while ( *(buffer + 3*(sy*w + sx)) >= 0. )
   229 					do
   239 					{
   230 					{
   240 						sx++;
   231 						sx++;
   241 						if (sx >= w)
   232 						if (sx >= w)
   242 						{
   233 						{
   243 							sx = 0;
   234 							sx = 0;
   244 							sy++;
   235 							sy++;
   245 						}
   236 						}
   246 						if (sy >= h)
   237 						if (sy >= h)
   247 							return false;
   238 							return false;
   248 					}
   239 					}
       
   240 					while ( *(buffer + 3*(sy*w + sx)) >= 0. );
       
   241 				}
       
   242 				else if (!oversample && !(w&1) && !(h&1))
       
   243 				{
       
   244 					// generate good raster for packet tracing
       
   245 					const int j = ((sy&1)<<1) + (sx&1);
       
   246 					switch (j)
       
   247 					{
       
   248 						case 0:
       
   249 						case 2:
       
   250 							sx++;
       
   251 							break;
       
   252 						case 1:
       
   253 							sx--;
       
   254 							sy++;
       
   255 							break;
       
   256 						case 3:
       
   257 							sx++;
       
   258 							if (sx >= w)
       
   259 							{
       
   260 								sx = 0;
       
   261 								sy++;
       
   262 							}
       
   263 							else
       
   264 								sy--;
       
   265 							if (sy >= h)
       
   266 								return false;
       
   267 							break;
       
   268 					}
       
   269 				}
       
   270 				else
       
   271 				{
       
   272 					sx++;
       
   273 					if (sx >= w)
       
   274 					{
       
   275 						sx = 0;
       
   276 						sy++;
       
   277 					}
       
   278 					if (sy >= h)
       
   279 						return false;
   249 				}
   280 				}
   250 
   281 
   251 				s->x = (Float)sx/h - (Float)w/h/2.0;
   282 				s->x = (Float)sx/h - (Float)w/h/2.0;
   252 				s->y = (Float)sy/h - 0.5;
   283 				s->y = (Float)sy/h - 0.5;
   253 				osa_samp = 0;
   284 				osa_samp = 0;