/* * call-seq: * zoom(zoom, smooth=false) -> Surface * * Return a zoomed version of the Surface. * * This method takes these arguments: * zoom:: a Numeric factor to scale by in both x and y directions, * or an Array with separate x and y scale factors. * smooth:: whether to anti-alias the new surface. * By the way, if true, the new surface will be 32bit RGBA. */ VALUE rbgm_transform_zoom(int argc, VALUE *argv, VALUE self) { SDL_Surface *src, *dst; double zoomx, zoomy; int smooth = 0; VALUE vzoom, vsmooth; rb_scan_args(argc, argv, "11", &vzoom, &vsmooth); Data_Get_Struct(self,SDL_Surface,src); smooth = RTEST(vsmooth) ? 1 : 0; 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(argv[0]); zoomy = zoomx; break; } default: { rb_raise(rb_eArgError, "wrong zoom factor type (expected Array or Numeric)"); break; } } dst = zoomSurface(src,zoomx,zoomy,smooth); if(dst == NULL) rb_raise(eSDLError,"Could not rotozoom surface: %s",SDL_GetError()); return Data_Wrap_Struct(cSurface,0,SDL_FreeSurface,dst); }