Are png images essential to use?

I’m just a beginner this is my first app development attempt so :stuck_out_tongue:
Anyway I first used all jpg and bmp images in my app and everything looked fine.
switched to all png and now everything looks terrible. Black backgrounds everywhere etc.

is it oke to just use bmp or not for some reason?

if I would decide to stick with png, how do I solve the black background problem ?

thanks :slight_smile:

It’s hard to tell exactly what you’re trying to do, but it kind of sounds like you’re using PNGs with transparency without enabling blending. That would render translucent images as if on top of black boxes.

What I’m kind of wondering is, how did you avoid this situation when using BMP and JPG?
Colorkeying? :slight_smile:

I think IMG_Load() will grab the alpha channel if there is one, but you need to manually set the blend mode you want (most likely SDL_BLENDMODE_BLEND in this case), using SDL_SetTextureBlendMode(), or SDL_SetSurfaceBlendMode() if you’re using surfaces.

This is assuming you’re using SDL2. SDL1.2 is slightly different, but IIRC, the same logic applies here.

//David

Thanks, I used settxtureblendmode, but it still looks the same :frowning:
and no I did not use colorkeying, because it wasn’t needed.

Maybe someone could take a look at my code ? I will pay if it’s necessary , but this is just beginning to feel so hopeless :frowning:

and yes the pings are transparent

Is it available online somewhere?
Maybe put it (+ the images needed for testing) on github or bitbucket or
sth if you’re familiar with git or mercurial?
Otherwise just zip it and upload it somewhere.
Either way, post the link here, I’m sure someone will look at it (I will
if no one else beats me to it; currently I only infrequently check my
E-Mails and the SDL forums).

Thanks. :slight_smile:

I posted the code here:
//removed .
I explain from line 326 what the problem is :slight_smile:

hope somebody can help , I really want to be done with this soon.
Oh & the idea of the app is that it
first displays a flash screen (while loading all textures and the start screen).
then displays the start screen.
if the start button is loaded it loads the main screen . Here a child can drag 3 balls to a goal (with a counter) . And it has a small area the child can dlick to hear/see opposites (on /off , hot / cold etc).
then in main there is a ‘letter button’ to select the abc game . it loads the togglegame screen. Here there are three areas top, middle, and bottom.
the top shows (on the first page ) a , the middle b, bottom c . Next page (click arrows) would be d , e, f , and so on.

Thanks. I hope someone can take a good look at my code see what the pngs problem is about and if the code looks good for the rest (because i’ve only been able to test my desktop version so far )
I will off course pay for all the time needed (paypal) .

Thanks :slight_smile:

I think the SDL_ConvertSurface() call in mainScreen::getLoadedImage() removes the alpha channel from the images. After that, SDL_BLENDMODE_BLEND is not going to do anything.

There should be no reason to convert surface pixel formats before converting to textures anyway, unless you need to do something that SDL_CreateTextureFromSurface() doesn’t.

Thanks for the reply. So what do i need to change for the images to look right?

You need to remove SDL_ConvertSurface() (or use it with a pixel format with alpha, but I don’t see the point in converting at all here, since SDL_CreateTextureFromSurface() will convert as needed anyway), and you need to enable the SDL_SetTextureBlendMode() call again.

You may want to avoid setting SDL_BLENDMODE_BLEND for images without an alpha channel, though I don’t think it’s going to matter, apart from possibly being marginally slower with “unnecessary” blending of opaque images.

BTW, what’s the deal with backgroundColorVect and all that? Can’t you just use SDL_SetRenderDrawColor() and SDL_RenderClear() or SDL_RenderFillRect()?

1 Like

Thanks for the reply David :slight_smile: It helped , it works now :slight_smile:

1 Like