VERY strange error

Hello everyone!

Okay, this works perfectly fine on Windows, but on Linux it screws up the
most strange way ever.

I want to blit an image onto the screen, but the behavior changes every time
I compile the program without changing any code.

It alternates between these:

  • Segmentation fault.
  • Works but image is darker.

Any, erm, clues?

Here are all of the code I use this image on: (all lines on different
functions)

spritesImg = SDL_LoadBMP(“sprites.bmp”);
if (spritesImg == NULL) return -1;
SDL_DisplayFormat(spritesImg);

/* Replace all cyan(bg1) and light yellow (bg2) colors with magenta (bgd) */

for (x = 0; x < surf->w; x++)
{
for (y = 0; y < surf->h; y++)
{
px = sge_GetPixel(surf, x, y);
if (px == bg1 || px == bg2)
sge_PutPixel(surf, x, y, bgd);
}
}
SDL_SetColorKey(s, SDL_SRCCOLORKEY, bgd))

Any idears? Everything else was loaded at 24-bit, including the screen, and
if I remember correctly this image is also 24-bit.

Thanks in advance, kind people of SDL!

Leo28C wrote:

Hello everyone!

Here are all of the code I use this image on: (all lines on different
functions)

spritesImg = SDL_LoadBMP(“sprites.bmp”);
if (spritesImg == NULL) return -1;
SDL_DisplayFormat(spritesImg);

/* Replace all cyan(bg1) and light yellow (bg2) colors with magenta (bgd)
*/

for (x = 0; x < surf->w; x++)
{
for (y = 0; y < surf->h; y++)
{
px = sge_GetPixel(surf, x, y);
if (px == bg1 || px == bg2)
sge_PutPixel(surf, x, y, bgd);
}
}
SDL_SetColorKey(s, SDL_SRCCOLORKEY, bgd))

I’ll try to answer as best as I can. Haven’t tried manipulating the pixels
directly.

  1. What is the “surf” variable?

  2. What are the definition of sge_GetPixel & sge_PutPixel? I reckon it is
    similar with the getpixel() and putpixel() method from the documentation,
    right?

  3. AFAIK, to manipulate a surface, you must lock the surface first.

Fare thee well,
Bawenang R. P. P.----------------
ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”

Uh, nevermind that - turned out I was overflowing an array… Sorry for
wasting your time! :blush:

benang at cs.its.ac.id wrote:> Leo28C wrote:

Hello everyone!

Here are all of the code I use this image on: (all lines on different
functions)

spritesImg = SDL_LoadBMP(“sprites.bmp”);
if (spritesImg == NULL) return -1;
SDL_DisplayFormat(spritesImg);

/* Replace all cyan(bg1) and light yellow (bg2) colors with magenta (bgd)
*/

for (x = 0; x < surf->w; x++)
{
for (y = 0; y < surf->h; y++)
{
px = sge_GetPixel(surf, x, y);
if (px == bg1 || px == bg2)
sge_PutPixel(surf, x, y, bgd);
}
}
SDL_SetColorKey(s, SDL_SRCCOLORKEY, bgd))

I’ll try to answer as best as I can. Haven’t tried manipulating the pixels
directly.

  1. What is the “surf” variable?

  2. What are the definition of sge_GetPixel & sge_PutPixel? I reckon it is
    similar with the getpixel() and putpixel() method from the documentation,
    right?

  3. AFAIK, to manipulate a surface, you must lock the surface first.

Fare thee well,
Bawenang R. P. P.


ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”

Hi,

Watch out for SGE… After looking through the source code, I’ve noticed it doesn’t always handle endianness correctly (it doesn’t define PI correctly either, among other things). It is a really old library now, so I’m working on a new version here: http://pubpages.unh.edu/~jmb97

Jonny D> To: sdl at libsdl.org> From: kixdemp at gmail.com> Date: Thu, 27 Sep 2007 02:30:32 -0400> Subject: Re: [SDL] VERY strange error…> > Uh, nevermind that - turned out I was overflowing an array… Sorry for > wasting your time! :$> > benang at cs.its.ac.id wrote:> > Leo28C wrote:> >> Hello everyone!> >> …> >> Here are all of the code I use this image on: (all lines on different> >> functions)> >>> >> spritesImg = SDL_LoadBMP(“sprites.bmp”);> >> if (spritesImg == NULL) return -1;> >> SDL_DisplayFormat(spritesImg);> >>> >> /* Replace all cyan(bg1) and light yellow (bg2) colors with magenta (bgd)> >> */> >>> >> for (x = 0; x < surf->w; x++)> >> {> >> for (y = 0; y < surf->h; y++)> >> {> >> px = sge_GetPixel(surf, x, y);> >> if (px == bg1 || px == bg2)> >> sge_PutPixel(surf, x, y, bgd);> >> }> >> }> >> SDL_SetColorKey(s, SDL_SRCCOLORKEY, bgd))> >>> >> …> > > > I’ll try to answer as best as I can. Haven’t tried manipulating the pixels> > directly.> > > > 1. What is the “surf” variable?> > > > 2. What are the definition of sge_GetPixel & sge_PutPixel? I reckon it is> > similar with the getpixel() and putpixel() method from the documentation,> > right?> > > > 3. AFAIK, to manipulate a surface, you must lock the surface first.> > > > Fare thee well,> > Bawenang R. P. P.> > > > ----------------> > ERROR: Brain not found. Please insert a new brain!> > > > ?Do nothing which is of no use.? - Miyamoto Musashi.> > > > “I live for my dream. And my dream is to live my life to the fullest.”> > _______________________________________________> SDL mailing list> SDL at lists.libsdl.org> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Connect to the next generation of MSN Messenger?
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline