/*this internal blit function is accessable through the C api*/intPySurface_Blit(PyObject*dstobj,PyObject*srcobj,SDL_Rect*dstrect,SDL_Rect*srcrect,intthe_args){SDL_Surface*src=PySurface_AsSurface(srcobj);SDL_Surface*dst=PySurface_AsSurface(dstobj);intresult;result=SDL_BlitSurface(src,srcrect,dst,dstrect);if(result==-1)RAISE(PyExc_SDLError,SDL_GetError());if(result==-2)RAISE(PyExc_SDLError,"Surface was lost");returnresult!=0;}staticPyObject*surf_blit(PyObject*self,PyObject*args,PyObject*keywds){SDL_Surface*src,*dest=PySurface_AsSurface(self);GAME_Rect*src_rect,temp;PyObject*srcobject,*argpos,*argrect=NULL;intdx,dy,result;SDL_Rectdest_rect,sdlsrc_rect;intsx,sy;intthe_args=0;staticchar*kwids[]={"source","dest","area","special_flags",NULL};if(!PyArg_ParseTupleAndKeywords(args,keywds,"O!O|Oi",kwids,&PySurface_Type,&srcobject,&argpos,&argrect,&the_args))returnNULL;src=PySurface_AsSurface(srcobject);if((src_rect=GameRect_FromObject(argpos,&temp))){dx=src_rect->x;dy=src_rect->y;}elseif(TwoIntsFromObj(argpos,&sx,&sy)){dx=sx;dy=sy;}elsereturnRAISE(PyExc_TypeError,"invalid destination position for blit");temp.x=temp.y=0;temp.w=src->w;temp.h=src->h;src_rect=&temp;dest_rect.x=(short)dx;dest_rect.y=(short)dy;dest_rect.w=(unsignedshort)src_rect->w;dest_rect.h=(unsignedshort)src_rect->h;sdlsrc_rect.x=(short)src_rect->x;sdlsrc_rect.y=(short)src_rect->y;sdlsrc_rect.w=(unsignedshort)src_rect->w;sdlsrc_rect.h=(unsignedshort)src_rect->h;if(!the_args)the_args=0;result=PySurface_Blit(self,srcobject,&dest_rect,&sdlsrc_rect,the_args);if(result!=0)returnNULL;//return PyRect_New (&dest_rect);Py_RETURN_NONE;}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.