Please see the example called: "SDL Example Video Bitmaps Pixels.au3" and/or check SDL_BlitSurface in your favourite helpfile for details on the second and forth parameters.great job with this, its coming along greatly! i really consider using this from now on as a replacement of gdi+.
tho running your png in gui example, ive come to an issue. where would i be able to specify were on the gui to draw the image
SDL UDF
#41
Posted 10 August 2009 - 06:38 PM
#42
Posted 24 October 2009 - 05:06 PM
So what's new?
Well there's 2 new libraries:
SDL_mixer for audio (music, sound effects) and SDL_ttf for drawing truetype fonts. Neither of them are 100% complete (see the table in post1) but the basics work, and the rest should just be a question of time.
SDL_mixer is BTW totally AWESOME for sound effects, it completely owns everything else in AutoIt.
So what's more?
_SDL_SetTimer() has finally been "fixed". Also events have been implemented. Again not 100% complete, but basics work.
I also "fixed" a common memory-error-crash-thingy that's been around forever, but apparantly no one else noticed.
There are also two new examples:
SDL Example get image w,h.au3 (get width and height of an image)
SDL Example image viewer.au3 (shows an image with basic auto-zoom)
I haven't created any examples for events, mixer or ttf, but I am hoping to amend that with one or two games I will release soon.
Download is as usual in the
#43
Posted 17 November 2009 - 12:50 AM
#44
Posted 17 November 2009 - 02:42 AM
As a temporary solution, I uploaded the zip to my webpage. http://hem.passagen.se/amax/autoit/SDL v14½.zip
I will try to find a more permanent solution later, it's like 4 AM here and i am really sleepy
#45
Posted 01 December 2009 - 02:22 PM
#46
Posted 01 December 2009 - 04:30 PM
I am not very good at transparency stuff, but maybe like this?Any way to set a transparent color, like pink?
#Include "SDL.au3" #include "SDL_gfx.au3" #include "SDL_sge.au3" #include "SDL_sprig.au3" _SDL_Init($_SDL_INIT_VIDEO) $Surface = _SDL_SetVideoMode(640, 480, 24, $_SDL_SWSURFACE) ;Software surfaces doesn't need to be locked ;) $Bitmap = _SDL_LoadBMP("image.bmp") _SDL_BlitSurface($Bitmap, 0, $Surface, 0) Switch InputBox("title", "Please write 1 for SDL, 2 for gfx, 3 for sge or 4 for sprig") Case 1 $Surface2 = _SDL_CreateRGBSurface($_SDL_SWSURFACE, 320, 240, 24, 0, 0, 0, 0) _SDL_SetAlpha($Surface2, $_SDL_SRCALPHA, 128) _SDL_FillRect($Surface2, _SDL_Rect_Create(0, 0, 320, 240), _SDL_MapRGB($Surface2, 0xff, 0xc0, 0xcb)) _SDL_BlitSurface($Surface2, 0, $Surface, 0) _SDL_FreeSurface($Surface2) Case 2 _SDL_Startup_gfx() _SDL_boxRGBA($Surface, 0, 0, 320, 240, 0xff, 0xc0, 0xcb, 128) _SDL_Shutdown_gfx() Case 3 _SDL_Startup_sge() _sge_FilledRectAlpha($Surface, 0, 0, 320, 240, _SDL_MapRGB($Surface, 0xff, 0xc0, 0xcb), 128) _SDL_Shutdown_sge() Case 4 _SDL_Startup_sprig() _SPG_RectFilledBlend($Surface, 0, 0, 320, 240, _SDL_MapRGB($Surface, 0xff, 0xc0, 0xcb), 128) _SDL_Shutdown_sprig() EndSwitch _SDL_FreeSurface($Bitmap) _SDL_Flip($Surface) Sleep(10000) _SDL_Quit()
Or did you mean something else?
#47
Posted 01 December 2009 - 05:18 PM
I'll check the example when I get home, thanks for your time
#48
Posted 01 December 2009 - 05:59 PM
#Include "SDL.au3" _SDL_Init(BitOR($_SDL_INIT_JOYSTICK, $_SDL_INIT_VIDEO)) ;Remember that events ate initialized by SDL_INIT_VIDEO $Joystick = _SDL_JoystickOpen(0) _CW($Joystick) ConsoleWrite(_SDL_JoystickEventState($_SDL_QUERY) & @CRLF) ;Are joystick event polling enabled? For $X = $_SDL_NOEVENT To $_SDL_NUMEVENTS -1 ;Listening to events we are not interested in seems lika a waste to me _SDL_EventState($X, $_SDL_IGNORE) Next _SDL_EventState($_SDL_JOYAXISMOTION, $_SDL_ENABLE) _SDL_EventState($_SDL_JOYBALLMOTION, $_SDL_ENABLE) _SDL_EventState($_SDL_JOYHATMOTION, $_SDL_ENABLE) _SDL_EventState($_SDL_JOYBUTTONDOWN, $_SDL_ENABLE) _SDL_EventState($_SDL_JOYBUTTONUP, $_SDL_ENABLE) _SDL_EventState($_SDL_QUIT, $_SDL_ENABLE) ConsoleWrite(_SDL_JoystickEventState($_SDL_QUERY) & @CRLF) ;Are joystick event polling enabled? While 1 $tRet = _SDL_PollEventEasy() Select Case $tRet = 0 ;If no event then Sleep (like GUIGetMsg works!) Sleep(10) Case $tRet[0] = $_SDL_JOYAXISMOTION _BumpDump($tRet) ;Dump array contents to console (see helpfile or source-code to see what is what) Case $tRet[0] = $_SDL_JOYBALLMOTION _BumpDump($tRet) Case $tRet[0] = $_SDL_JOYHATMOTION _BumpDump($tRet) Case $tRet[0] = $_SDL_JOYBUTTONDOWN _BumpDump($tRet) Case $tRet[0] = $_SDL_JOYBUTTONUP _BumpDump($tRet) Case $tRet[0] = $_SDL_QUIT MsgBox(0, "Exiting now", "But you will not see this message ;) (most of the time anyway)") ;Don't ask me about this, I'm just as confused as you :S ExitLoop Case Else ;Never happens (we put ignore on everything "else" a few lines up) ConsoleWrite($tRet[0] & @CRLF) EndSelect WEnd ;This like never happens ConsoleWrite("I am exiting now, bye!" & @CRLF) _SDL_JoystickClose($Joystick) _SDL_Quit()
#49
Posted 01 December 2009 - 06:38 PM
Nope, didn't mean that, sorry for explaining badly.I am not very good at transparency stuff, but maybe like this?
AutoIt#Include "SDL.au3" #include "SDL_gfx.au3" #include "SDL_sge.au3" #include "SDL_sprig.au3" _SDL_Init($_SDL_INIT_VIDEO) $Surface = _SDL_SetVideoMode(640, 480, 24, $_SDL_SWSURFACE) ;Software surfaces doesn't need to be locked ;) $Bitmap = _SDL_LoadBMP("image.bmp") _SDL_BlitSurface($Bitmap, 0, $Surface, 0) Switch InputBox("title", "Please write 1 for SDL, 2 for gfx, 3 for sge or 4 for sprig") Case 1 $Surface2 = _SDL_CreateRGBSurface($_SDL_SWSURFACE, 320, 240, 24, 0, 0, 0, 0) _SDL_SetAlpha($Surface2, $_SDL_SRCALPHA, 128) _SDL_FillRect($Surface2, _SDL_Rect_Create(0, 0, 320, 240), _SDL_MapRGB($Surface2, 0xff, 0xc0, 0xcb)) _SDL_BlitSurface($Surface2, 0, $Surface, 0) _SDL_FreeSurface($Surface2) Case 2 _SDL_Startup_gfx() _SDL_boxRGBA($Surface, 0, 0, 320, 240, 0xff, 0xc0, 0xcb, 128) _SDL_Shutdown_gfx() Case 3 _SDL_Startup_sge() _sge_FilledRectAlpha($Surface, 0, 0, 320, 240, _SDL_MapRGB($Surface, 0xff, 0xc0, 0xcb), 128) _SDL_Shutdown_sge() Case 4 _SDL_Startup_sprig() _SPG_RectFilledBlend($Surface, 0, 0, 320, 240, _SDL_MapRGB($Surface, 0xff, 0xc0, 0xcb), 128) _SDL_Shutdown_sprig() EndSwitch _SDL_FreeSurface($Bitmap) _SDL_Flip($Surface) Sleep(10000) _SDL_Quit()
Or did you mean something else?
What I want is, to make it make the pink color transparent
Ex;
#50
Posted 01 December 2009 - 06:54 PM
Do you think of something like step 3) here?Nope, didn't mean that, sorry for explaining badly.
What I want is, to make it make the pink color transparent
Ex;
3) How to tell SDL which color to make transparent
So how can we specify what color SDL can treat as transparent? Well, when we load an image we can add a little code to take care of this:
if( compatible_image != NULL ) {
// specify a colour that will be used to signify 'transparent' pixels
Uint32 colorkey = SDL_MapRGB( compatible_image->format, 0, 0, 0); // choose black
// now tell SDL to remeber our choice
SDL_SetColorKey( compatible_image, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey);
// SDL_RLEACCEL is run lenght encoded acceleration to speed up the colorkeying
// SDL_SRCCOLORKEY tells SDL that this color key applies to the source image
}
In the SDL_MapRGB function we can tell SDL three numbers that form a color with Red, Green and Blue parts. Hence black, which is no color at all really, is red=0,green=0 and blue=0.
The other two SDL_RLEACCEL and SDL_SRCCOLORKEY specify how the images will be drawn. Its a bit outside the scope of this HOWTO to go into details of RLE but a good five minutes on Google typing in run length encoding will get you a good explanation if you really want one. Its basically that the image surface gets optimized so that the whole color keying process gets done faster.
Edited by ProgAndy, 01 December 2009 - 06:57 PM.
#51
Posted 01 December 2009 - 06:59 PM
There are 3 types of transparency in SDL, color keys (like in the above pink example), per-surface alpha, and per pixel alpha.
The annoying thing is that you cannot mix these (well you can if you use a custom blitter like in sdl_gfx), this usually is the problem people have when it comes to transparency troubles.
At the moment I'm doing manual blitting and alpha settings, it's slower but I like the control.
Googling for specific problem usually turns up good stuff.
Is the link in my post broken? I do not longer own my domain, all the files are moved to my new domain.Example: http://monoceres.se/test.au3 -> http://andhen.mine.nu/monoceres.se/test.au3
#52
Posted 01 December 2009 - 07:03 PM
_SDL_SetColorKey($hSurface, $_SDL_SRCCOLORKEY, _SDL_MapRGB($hSurface, 0xFF, 0x00, 0xFF))
If you have 24/32 bit colors you can remove the MapRGB and input the color directly.
Here's a good tutorial you may want to read: The Ins and Outs (and Overlays) of Alpha-blending
#53
Posted 01 December 2009 - 09:55 PM
Edited by Zisly, 01 December 2009 - 09:55 PM.
#54
Posted 01 December 2009 - 10:42 PM
That work good too although it should blit a little slower than the colorkeyingI went with simply making the png pics transparent with photophiltre
#55
Posted 01 December 2009 - 11:32 PM
How much slower?That work good too although it should blit a little slower than the colorkeying
Well I might check it out again tomorrow or something, I'm so tired today that I simply gave up trying to make it work with colokeying, most of the time nothing happened and sometimes I managed to crash the program
If you could make a working example (nothing complex, just something that works) I would be very grateful
Edited by Zisly, 01 December 2009 - 11:32 PM.
#56
Posted 02 December 2009 - 09:51 PM
No idea (I read about in on the internetz), haven't really tested that myself, but you do know how to use TimerInit/TimerDiff, right?How much slower?
Try adding this after $Loaded1 is declared in "SDL Example SDL_image.au3", all the white in the excel table will be black!Well I might check it out again tomorrow or something, I'm so tired today that I simply gave up trying to make it work with colokeying, most of the time nothing happened and sometimes I managed to crash the program
If you could make a working example (nothing complex, just something that works) I would be very grateful
_SDL_SetColorKey($Loaded1, $_SDL_SRCCOLORKEY, 0xFFFFFF)
Edited by AdmiralAlkex, 02 December 2009 - 09:51 PM.
#57
Posted 02 December 2009 - 10:10 PM
www.minikori.com... and his his name is Valik.They already have a punishment system for abuse.
#58
Posted 02 December 2009 - 11:02 PM
The link at post #44 works for me, try that. As for a permanent solution, can you provide download statistics and FTP login? I can't take the risk that you are abducted by aliens and I can't get a new version onlineThe site you have the download at seems to be down or something, do you want me to host it on my website?
#59
Posted 03 December 2009 - 03:14 AM
No, I can just upload it and people can use a straight link to it, no stats or login. But it's meant to temporary.The link at post #44 works for me, try that. As for a permanent solution, can you provide download statistics and FTP login? I can't take the risk that you are abducted by aliens and I can't get a new version online
I'll try that link you mentioned now.
www.minikori.com... and his his name is Valik.They already have a punishment system for abuse.
#60
Posted 03 December 2009 - 02:49 PM
Ok, now I feel stupidNo idea (I read about in on the internetz), haven't really tested that myself, but you do know how to use TimerInit/TimerDiff, right?
![]()
Try adding this after $Loaded1 is declared in "SDL Example SDL_image.au3", all the white in the excel table will be black!![]()
_SDL_SetColorKey($Loaded1, $_SDL_SRCCOLORKEY, 0xFFFFFF)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





