@@ -522,17 +522,34 @@ resample_ (ImageBuf &dst, const ImageBuf &src, bool interpolate,
522522 if (interpolate) {
523523 int nchannels = src.nchannels ();
524524 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 };
525527 ImageBuf::Iterator<DSTTYPE> out (dst, roi);
528+ ImageBuf::ConstIterator<SRCTYPE> it (src);
526529 for (int y = roi.ybegin ; y < roi.yend ; ++y) {
527530 // s,t are NDC space
528531 float t = (y-dstfy+0 .5f )*dstpixelheight;
529532 // src_xf, src_xf are image space float coordinates
530533 float src_yf = srcfy + t * srcfh;
534+ float yy = src_yf - 0 .5f ;
535+ int ytexel;
536+ float yfrac = floorfrac (yy, &ytexel);
531537 for (int x = roi.xbegin ; x < roi.xend ; ++x, ++out) {
532538 float s = (x-dstfx+0 .5f )*dstpixelwidth;
533539 float src_xf = srcfx + s * srcfw;
534540 // 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+
536553 for (int c = roi.chbegin ; c < roi.chend ; ++c)
537554 out[c] = pel[c];
538555 }
0 commit comments