Sdl Surface Weird Goings On With Image Overlaying


CyberAxe

Member
Joined
Nov 18, 2005
Messages
206
I'm basically taking a rectangle sample from a surface and applying it to the screen surface then applying anohter surface ontop of that which has the picture then on top of that a border image that depends on if its selected or not if so its blue if not irs grey

however it is not working for some reason the overlay borders graduly multiply each update till the semi transparent pixels are completley opaque

heres my source code for this

CODE

intMenuPagePrev = intMenuPage;
int intMultiplyer = 9 * intMenuPage;

int intIncCol = 0;
int intIncRow = 0;
int intIncCounter = 0;

int intOverlayDifferenceW = surfaceChannelSelection->w - vecChannelImageCache[0]->w;
int intOverlayDifferenceH = surfaceChannelSelection->h - vecChannelImageCache[0]->h;

//Apply Channels
for(int i = 0; i < 9; i++) {

//The Portions Of The Sprite Map To Be Blitted
SDL_Rect rectBackgroundSample;

//Clip Range For The Top Left
rectBackgroundSample.x = intCoordCol[intIncCol] - (intOverlayDifferenceW / 2);
rectBackgroundSample.y = intCoordRow[intIncRow] - (intOverlayDifferenceH / 2);
rectBackgroundSample.w = surfaceChannelSelection->w;
rectBackgroundSample.h = surfaceChannelSelection->h;

applySurface(intCoordCol[intIncCol] - (intOverlayDifferenceW / 2), intCoordRow[intIncRow] - (intOverlayDifferenceH / 2), surfaceBackground, surfaceMenuScreen, &rectBackgroundSample);
cout << vecChannelImageCache.size() << endl;
cout << intMenuPage << endl;
applySurface(intCoordCol[intIncCol], intCoordRow[intIncRow], vecChannelImageCache[i + intMultiplyer], surfaceMenuScreen);

//Apply Selection Overlay
if ((i + intMultiplyer) == intCurrentChannel) {
applySurface(intCoordCol[intIncCol], intCoordRow[intIncRow], surfaceChannelSelection, surfaceMenuScreen);
}
else {
applySurface(intCoordCol[intIncCol], intCoordRow[intIncRow], surfaceChannelInactive, surfaceMenuScreen);
}

SDL_UpdateRect(surfaceMenuScreen, intCoordCol[intIncCol] - 1, intCoordRow[intIncRow] - 1, surfaceChannelSelection->w + 2, surfaceChannelSelection->h + 2);

//Calculate Which Row To Use
if (intIncCounter > 1) {
intIncCounter = 0;
++intIncRow;
}
else {
++intIncCounter;
}

//Calculate Which Column To Use
if (intIncCol > 1) {
intIncCol = 0;
}
else {
++intIncCol;
}
}



and here is a screen shot of what is happening top half is what it should look like and is what it looks like when it starts the bottom half is the result of the overlays not being overlayed (and i know the background is being sampled and placed on the surface every time because ive tested it with a background image) and it also happens if i update the entire screen or flip the entire screen

ScreenShot.jpg
 
The only difference I spot is that the lower pictures are not smothened around the edges o_O palette troubles? I dunno.
 
Quiest said:
The only difference I spot is that the lower pictures are not smothened around the edges o_O palette troubles? I dunno.
thats what i am trying to fix

shouldnt be anythign to do with pallet i dont think since i am just loading a png straight to the surface and applying it approliatly

my older inefficiant method didnt do this where it updated each one individually each time and did sdl_flip however i have no copies of my older code left and i didnt change a great deal from what i remember, though ive been stuck with this problem for a few weeks

for some reason it appears just to be applying the overlays over the top of the old screen update which graduly results in those horrid corners
 
Last edited by a moderator:
found out whats wrong if there is no background.png found it merley fills surfaceBackground with white however it doesnt appear to be working it works ok if there is a background.png it samples it and applies it where needed

just wasnt working with a surface filled with white

am now figuring out how to rectify this
 
this is what is causing the problem

CODE

surfaceBackground = loadImage(strImagePathBackground);

//Make Background White if there is no Background.png
if (surfaceBackground == NULL) {
SDL_FillRect(surfaceBackground, NULL, 0xFFFFFF);
}



ive tried creating an SDL_rect and setting it to the size of the screen but i get errors when i try and use it to fill rect the surfaceBackground and i cant find any info on setting the height and width of a surface which i think would fix the problem, works fine with a background.png thats filled with white and this is the only thing i can think of which is causing it not to work with the white filled surface

Sphinxter said:
Not sure whether or not you are using a transparent color on those blitz and if so the side effect could be from the dithering of the original with the transparency key color.
The Overlays are using the Alpha Channel from the PNG the main channel image is using a key colour
 
Last edited by a moderator:
Keep in mind this might be the beer talking, but if surfaceBackground is NULL, shouldn't you create it with SDL_CreateRGBSurface before filling it?
 
Back
Top