/*
* call-seq:
* zoom_size(size, zoom) -> [width, height]
*
* Return the dimensions of the surface that would be returned if
* #zoom were called with a surface of the given size and zoom factors.
*
* This method takes these arguments:
* size:: an Array with the hypothetical surface width and height (pixels)
* zoom:: the factor to scale by in both x and y directions, or an Array
* with separate x and y scale factors.
*/
VALUE rbgm_transform_zoomsize(int argc, VALUE *argv, VALUE module)
{
int w,h, dstw,dsth;
double zoomx, zoomy;
VALUE vsize, vzoom;
rb_scan_args(argc,argv,"2", &vsize, &vzoom);
vsize = convert_to_array(vsize);
w = NUM2INT(rb_ary_entry(vsize,0));
h = NUM2INT(rb_ary_entry(vsize,1));
switch( TYPE(vzoom) )
{
case T_ARRAY: {
zoomx = NUM2DBL(rb_ary_entry(vzoom,0));
zoomy = NUM2DBL(rb_ary_entry(vzoom,1));
break;
}
case T_FLOAT:
case T_FIXNUM: {
zoomx = NUM2DBL(vzoom);
zoomy = zoomx;
break;
}
default: {
rb_raise(rb_eArgError,
"wrong zoom factor type (expected Array or Numeric)");
break;
}
}
zoomSurfaceSize(w, h, zoomx, zoomy, &dstw, &dsth);
return rb_ary_new3(2,INT2NUM(dstw),INT2NUM(dsth));
}