Hey all,
I’m new to sdl, and running into a error that I jsut can not figure out
in anyway what-so-ever.
I’m writing a utility for a little font engine i’m writing to create
bitmap font files from a given font, but in anycase a surface I load
in from bitmap is gettin currupted in a very pecular place. I’ve
isolated the place where the surface is getitn currupted, but I do not
see y…
I’ll post the code below… the surface seems to be curropted at the
very end of the bitmap… it’s okay till it hits the jump…
The effect is a surface all white other then a few pixels along the top
row that r random or random seeming… i’m Very stumped by this… if anyone
can see what’s wrong would be greatly appriciative.
TIA
-John
The function is:
Ps. I know the code is dirty… planned on it being a quick hack.
// sep is a array of ints of size surf->w * sepW
// The SaveBMP’s and printf’s r from my attempts at debuggin this.
int getSeperator(SDL_Surface *surf, int *sep, int sepW) {
int x = 0, y = 0;
Uint32 pixC; // pixel color
Uint32 black = SDL_MapRGB(surf->format, 0, 0, 0);
char baseName[255];
SDL_SaveBMP(surf, "EnteringGetSeperator.bmp");
// Slock(surf);
// loop to get seperator
while(x < sepW) {
// Set the pixel
// printf(“before getpixel - (%i, %i)\n”, x, y);
// printf("(s->w, s->h) = (%i, %i)\n", surf->w, surf->h);
// printf(“BytesPerPixel = %i”, surf->format->BytesPerPixel);
// Sulock(surf);
sprintf(baseName, “InsideSeperatorBeforeGetPix%i.bmp”, x);
SDL_SaveBMP(surf, baseName);
Slock(surf);
pixC = getpixel(surf, x, y);
Sulock(surf);
sprintf(baseName, "InsideSeperatorAfterGetPix%i.bmp", x);
SDL_SaveBMP(surf, baseName);
Slock(surf);
printf("after getpixel\n");
printf("(%i, %i)\n", x, y);
if(pixC == black) {
sep[y * sepW + x] = black;
} else {
sep[y * sepW + y] = pixC;
}
y++;
// coloum advance
if(y >= surf->h) {
y = 0;
x++;
if(x >= surf->w) { // Odd error
Sulock(surf);
return -1;
}
}
Sulock(surf);
sprintf(baseName, "InsideSeperatorEndOfWhile%i.bmp", x);
SDL_SaveBMP(surf, baseName);
// Slock(surf);
// Surface Currupted here!!!
YYYYYYYYYYYYYYYYYYY!!!
}
//Sulock(surf);
SDL_SaveBMP(surf, "LeavingGetSeperator.bmp");
return 0;
}