@@ -522,17 +522,34 @@ resample_ (ImageBuf &dst, const ImageBuf &src, bool interpolate,
522
522
if (interpolate) {
523
523
int nchannels = src.nchannels ();
524
524
float *pel = ALLOCA (float , nchannels);
525
+ float *localpixel = ALLOCA (float , nchannels*4 );
526
+ float *p[4 ] = { localpixel, localpixel+nchannels, localpixel+2 *nchannels, localpixel+3 *nchannels };
525
527
ImageBuf::Iterator<DSTTYPE> out (dst, roi);
528
+ ImageBuf::ConstIterator<SRCTYPE> it (src);
526
529
for (int y = roi.ybegin ; y < roi.yend ; ++y) {
527
530
// s,t are NDC space
528
531
float t = (y-dstfy+0 .5f )*dstpixelheight;
529
532
// src_xf, src_xf are image space float coordinates
530
533
float src_yf = srcfy + t * srcfh;
534
+ float yy = src_yf - 0 .5f ;
535
+ int ytexel;
536
+ float yfrac = floorfrac (yy, &ytexel);
531
537
for (int x = roi.xbegin ; x < roi.xend ; ++x, ++out) {
532
538
float s = (x-dstfx+0 .5f )*dstpixelwidth;
533
539
float src_xf = srcfx + s * srcfw;
534
540
// Non-deep image, bilinearly interpolate
535
- src.interppixel (src_xf, src_yf, pel);
541
+
542
+ // src.interppixel (src_xf, src_yf, pel);
543
+
544
+ float xx = src_xf - 0 .5f ;
545
+ int xtexel;
546
+ float xfrac = floorfrac (xx, &xtexel);
547
+ it.rerange (xtexel, xtexel+2 , ytexel, ytexel+2 , 0 , 1 );
548
+ for (int i = 0 ; i < 4 ; ++i, ++it)
549
+ for (int c = 0 ; c < nchannels; ++c)
550
+ p[i][c] = it[c];
551
+ bilerp (p[0 ], p[1 ], p[2 ], p[3 ], xfrac, yfrac, nchannels, pel);
552
+
536
553
for (int c = roi.chbegin ; c < roi.chend ; ++c)
537
554
out[c] = pel[c];
538
555
}
0 commit comments