Problem blitting a RGB image

Hello

I am having some trouble blitting a RGB image using SDL.
I have a pointer to a image in RGB24-format and i want to blit it to the
display.
Code for the relevant parts is below. I do get something on screen and it
looks like its the first line of the image repeated over the whole image. So
when i generate a new image I can see the screen change.

About the code. frame points to the RGB24-image. FRAME_WIDTH and
FRAME_HEIGHT is the width and height of the image pointed to by frame.
dv_one_frame(frame, 0) gets the next frame in
RGB24-format. I know that the image returned by dv_one_frame(frame, 0) is a
RGB24-image and i can display it with other software (gtk+/glib) but it’s
too slow.

Thanks in advance
Mattias Blomqvist

if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
exit(1);
}
screen = SDL_SetVideoMode(800, 600, 24, SDL_HWSURFACE|SDL_FULLSCREEN);
if ( screen == NULL ) {
exit(1);
}
done = 0;

while (!done && (dv_one_frame(frame, 0) != 0)) {
  screen2 = SDL_CreateRGBSurfaceFrom(frame, FRAME_WIDTH, FRAME_HEIGHT,

24, 0, 0xff0000, 0xff00, 0xff,0);
dstrect.x = (screen->w-screen2->w)/2;
dstrect.y = (screen->h-screen2->h)/2;
dstrect.w = screen2->w;
dstrect.h = screen2->h;
if ( SDL_BlitSurface(screen2, NULL, screen, &dstrect) < 0 ) {
SDL_FreeSurface(screen2);
ComplainAndExit();
}
SDL_UpdateRects(screen, 1, &dstrect);
while ( SDL_PollEvent(&event) ) {
switch (event.type) {
case SDL_KEYDOWN:
if ( event.key.keysym.sym == SDLK_ESCAPE ) {
done = 1;
}
break;
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
}
SDL_Quit();