I everybody, i’m doing a character Recognition Software based on SDL.
I am having an oral exam really soon and i need to fix a problem.
I want to make a selection on an image based on the
mouse events and I want to draw a rectangular
zone to shwo the selection. I’d like to change the
alpha of the part of the image which is not selected.
I’d like to know how to enable alpha on a surface.
I use SDL_SetVideoMode to create my SDL_Surface
and I use it to display some changes i do on the
pixels with SDL_MapRGBA and the function
putpixel given in the documentation.
It seems to me that the Alpha i put isn’t consider
by SDL and i’d like to know what to do to change it.
here is the code that is important in my problem:
/The sreen surface/
screen = SDL_SetVideoMode(600, 600, 32, SDL_SWSURFACE & SDL_OPENGLBLIT);
/*The pixels i add */
white = SDL_MapRGBA(screen->format, 0xff, 0xff, 0xff, 0xff);
gray = SDL_MapRGBA(screen->format, 0x64, 0x64, 0x64, 0x00);
putpixel(screen, 2, 2, gray);
putpixel(screen, 3, 2, white);
here you can see that i both used 255 and 0 as alpha and none of the works.
By the way i’d like to know how to work on different layers :
I’d like to display the BMP i use on the background and i want to
work on an other SDL_Surface to display the rectangular selection. For the
moment i copy the bmp on the surface then make the
changes of the rectangular zone but it’s not the best way i guess.
Thanks for your help and sorry for my bad english