Hi all,
I am Dilip. I am very new to SDL … I am developing a Camera
Application where I am planning to display the Raw Data coming from the
Camera using the SDL.
The Image I am displaying is 640*480 and of 8 Bpp… The procedure I
followed in the program was
- Create the Buffer based on the Image Width and Height
- Use the SDL_CreateRGBSurface() function
- Blit the surface
- Update the Buffer …
But after running the program I am getting the segmentation fault. Is
there any logical or syntax error in this. So somebody please help me
regarding this …
My Program …
Display()
{
SDL_Surface *screen, *image;
// Allocating the Buffer for the Image frame.
char buffer = malloc(HeightWidth*Bpp);
// Infinite Loop to display the Camera data
while(ChangeParameters)
{
// Copy the RAW image Data to the Buffer, buffer …
if(SDL_Init(SDL_INIT_VIDEO)==-1)
{
printf(“SDL_Init Video Error !!! \n”);
return 1;
}
/* Set the video colormap */
if ( image->format->palette != NULL )
{
SDL_SetColors(screen, image->format->palette->colors, 0,
image->format->palette->ncolors);
}
/* load the image */
image=SDL_CreateRGBSurfaceFrom(buffer,640,480,8,640,0,0,0,0);
screen=SDL_SetVideoMode(image->w, image->h,
image->format->BitsPerPixel, SDL_ANYFORMAT);
SDL_BlitSurface(image,0,screen,0);
free(buffer);
// Update the Buffer
update(buffer);
SDL_Flip(screen);
SDL_FreeSurface(image);
}
}
Regards
Dilip Vamanan
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.