- o_yp = o_y*p_outpic->p[i_plane].i_lines
- /p_outpic->p[Y_PLANE].i_lines;
- o_xp = o_x*p_outpic->p[i_plane].i_pitch
- /p_outpic->p[Y_PLANE].i_pitch;
- int i_pitch = p_outpic->p[i_plane].i_pitch;
-#if 0
- int o_zoom2 = o_zoom*o_zoom;
- int o_zoom3 = o_zoom*o_zoom*o_zoom;
- int o_zoom4 = o_zoom*o_zoom*o_zoom*o_zoom;
- int o_zoom6 = o_zoom*o_zoom*o_zoom * o_zoom*o_zoom*o_zoom;
-#endif
- for( y=0; y<p_outpic->p[i_plane].i_visible_lines; y++ )
- {
- for( x=0; x<p_outpic->p[i_plane].i_visible_pitch; x++ )
- {
-#if 0
- /* Nearest neighbor */
- int nx = o_xp + x*ZOOM_FACTOR/o_zoom;
- int ny = o_yp + y*ZOOM_FACTOR/o_zoom;
- p_outpic->p[i_plane].p_pixels[y*i_pitch+x] =
- p_pic->p[i_plane].p_pixels[ny*i_pitch+nx];
-#elif 1
- /* Bi-linear */
- int nx_real = o_xp*o_zoom + x*ZOOM_FACTOR;
- int ny_real = o_yp*o_zoom + y*ZOOM_FACTOR;
- int nx = nx_real/o_zoom;
- int ny = ny_real/o_zoom;
- int wtl = ((nx+1)*o_zoom-nx_real)*((ny+1)*o_zoom-ny_real);
- int wtr = (nx_real-nx*o_zoom)*((ny+1)*o_zoom-ny_real);
- int wbl = ((nx+1)*o_zoom-nx_real)*(ny_real-ny*o_zoom);
- int wbr = (nx_real-nx*o_zoom)*(ny_real-ny*o_zoom);
- p_outpic->p[i_plane].p_pixels[y*i_pitch+x] =
- ( wtl*p_pic->p[i_plane].p_pixels[ny*i_pitch+nx]
- + wtr*p_pic->p[i_plane].p_pixels[ny*i_pitch+(nx+1)]
- + wbl*p_pic->p[i_plane].p_pixels[(ny+1)*i_pitch+nx]
- + wbr*p_pic->p[i_plane].p_pixels[(ny+1)*i_pitch+(nx+1)]
- ) / (o_zoom*o_zoom);
-#else
- /* Bi-cubic */
- /* FIXME: doesn't work */
- /* \Sigma_{i=0..3} \Sigma_{j=0..3} \alpha_{i,j} x^i y^j
- * 16 \alpha_{i,j} so we need to use the 16 nearest pixels
- *
- * In fact we should be able to write it as:
- * \Pi_{i=1..16} [ \Pi_{j!=i} ( x - x_j ) * ( y - y_j ) ]
- * * z_i / [ \Pi_{j!=i} ( x_i - x_j ) * ( y_i - y_j ) ]
- * We also have to make sure that we don't use any
- * x_j == x_i or y_j == y_i in the \Pi on j (else we get
- * a 0/0 which kind of sucks) .
- */
- uint8_t *p = p_pic->p[i_plane].p_pixels;
- int nx_real = o_xp*o_zoom + x*ZOOM_FACTOR;
- int ny_real = o_yp*o_zoom + y*ZOOM_FACTOR;
-
- int nx = nx_real/o_zoom;
- int ny = ny_real/o_zoom;
-
- int xi, yi, xj, yj;
- int my = __MAX( ny-1, 0 );
- int mx = __MAX( nx-1, 0 );
- //p_outpic->p[i_plane].i_visible_lines - 4
- //p_outpic->p[i_plane].i_visible_pitch - 4
- int v = 1;
- for( yi = my; yi <= my+3; yi++ )
- {
- int numy = 1;
- int deny = 1;
- /*
- for( yj = my; yj <= my+3; yj++ )
- {
- if( yj != yi )
- {
- numy *= (ny_real-yj*o_zoom);
- deny *= (yi - yj);
- }
- }
- numy /= o_zoom2;*/
- for( xi = mx; xi <= mx+3; xi++ )
- {
- int num = numy;
- int den = deny;
- for( xj = mx; xj <= mx+3; xj++ )
- {
- if( xj != xi )
- {
- num *= (nx_real-xj*o_zoom);
- den *= (xi - xj);
- }
- }
- v = ( v * (p[yi*i_pitch+xi] * num) ) / ( den * o_zoom3 );
- }
- }
- p_outpic->p[i_plane].p_pixels[y*i_pitch+x] = v;
-#endif
- }
- }