SDL_BlitSurface()

As far as I can tell from the documentation, SDL_BlitSurface(src,
srcrect, dst, dstrect) should take account of srcrect.x and srcrect.y,
but in my program it appears that regardless of what values I supply,
the blit treats them as 0. Is the documentation wrong, or am I
confused?

Gib

Someone is going to ask to see my code, so here is an example:

void
copyImageToSurface(SDL_Surface *surface, SDL_Surface *p2_surface)
{
SDL_Rect area1,area2;

area1.x = 200;
area1.y = 200;
area1.w = surface->w - area1.x;
area1.h = surface->h - area1.y;
area2.x = 0;
area2.y = 0;
area2.w = area1.w;
area2.h = area1.h;
SDL_BlitSurface(surface, &area1, p2_surface, &area2);

}

I want to copy the lower right portion of the image, but instead I get
the upper left portion.

Gib

Check the values of surface->w and surface->h. Could it be the
clipping problem?On Sat, Feb 15, 2003 at 07:48:09PM +1300, Gib Bogle wrote:

Someone is going to ask to see my code, so here is an example:

void
copyImageToSurface(SDL_Surface *surface, SDL_Surface *p2_surface)
{
SDL_Rect area1,area2;

area1.x = 200;
area1.y = 200;
area1.w = surface->w - area1.x;
area1.h = surface->h - area1.y;
area2.x = 0;
area2.y = 0;
area2.w = area1.w;
area2.h = area1.h;
SDL_BlitSurface(surface, &area1, p2_surface, &area2);
}

I want to copy the lower right portion of the image, but instead I get
the upper left portion.


Ivan Stankovic, @Ivan_Stankovic

Ivan Stankovic wrote:

Someone is going to ask to see my code, so here is an example:

void
copyImageToSurface(SDL_Surface *surface, SDL_Surface *p2_surface)
{
SDL_Rect area1,area2;

  area1.x = 200;
  area1.y = 200;
  area1.w = surface->w - area1.x;
  area1.h = surface->h - area1.y;
  area2.x = 0;
  area2.y = 0;
  area2.w = area1.w;
  area2.h = area1.h;
  SDL_BlitSurface(surface, &area1, p2_surface, &area2);

}

I want to copy the lower right portion of the image, but instead I get
the upper left portion.

Check the values of surface->w and surface->h. Could it be the
clipping problem?

No, these values are fine. I can readily copy the whole image, but
always from (0,0). BTW, this is with W2000/VisualC.

Gib> On Sat, Feb 15, 2003 at 07:48:09PM +1300, Gib Bogle wrote:

Ivan Stankovic wrote:

Someone is going to ask to see my code, so here is an example:

void
copyImageToSurface(SDL_Surface *surface, SDL_Surface *p2_surface)
{
SDL_Rect area1,area2;

  area1.x = 200;
  area1.y = 200;
  area1.w = surface->w - area1.x;
  area1.h = surface->h - area1.y;
  area2.x = 0;
  area2.y = 0;
  area2.w = area1.w;
  area2.h = area1.h;
  SDL_BlitSurface(surface, &area1, p2_surface, &area2);

}

I want to copy the lower right portion of the image, but instead I get
the upper left portion.

Check the values of surface->w and surface->h. Could it be the
clipping problem?

No, these values are fine. I can readily copy the whole image, but
always from (0,0). BTW, this is with W2000/VisualC.

This is weird. I’m just guessing here, but how(when?) do you call SDL_UpdateRect()/SDL_Flip()?
Does it happen with all surfaces? Have you tried this code on other platforms?On Sun, Feb 16, 2003 at 08:31:28AM +1300, Gib Bogle wrote:

On Sat, Feb 15, 2003 at 07:48:09PM +1300, Gib Bogle wrote:


Ivan Stankovic, @Ivan_Stankovic

Ivan Stankovic wrote:

This is weird. I’m just guessing here, but how(when?) do you call SDL_UpdateRect()/SDL_Flip()?
Does it happen with all surfaces? Have you tried this code on other platforms?

Problem solved - I was confused. The error was, as you suggested, in
what I was doing with the surface (actually the first frame to be
displayed was clipped in the way I wanted, but I overlooked the fact
that subsequent frames were processed differently).

Now I feel embarrassed :-]

thanks
Gib