Pixmaps and Max Questions

BlitzMax Forums/BlitzMax Beginners Area/Pixmaps and Max Questions

Rico(Posted 2008) [#1]
I'm fairly new to Max (Hello! :D )
In the previous Blitz there was a Copyrect command to copy sections of the screen image around. Am I right in assuming you use Pixmaps to do this now? I was wondering if it is as fast as old Blitz, just because it seems a bit convuluted for the program - to copy to a pixmap - to somehow shift the image around - then to draw back to the screen.
Someone (who was very helpful) told me that to read a pixel on the screen you also have to use pixmaps, and then use various AND functions to extract the information from a bit value. Why is it so hard? will Max be updated to include a read pixel function? (I hope so)
I have some other questions -

1) Do you have to free or release a pixmap after using it? (+how do you do it?)
2) Does Max have a debugger where you can step thru the program and view the variables?
3) Can you draw to the FrontBuffer in Max? I had a program where I was drawing an image (very slowly) on the backbuffer and I wanted to display a numerical value on the front screen to tell me how long I had to wait, but I couldn't work out how to do this.

I like Max so far, though I am finding OO programing a bit weird and new at the moment. But I do have a couple of minor improvement suggestions :

1. when you press 'F1' to display the format of a command - it would be good if it always worked on the current or previous command on the line. Loads of times I get halfway through a command's arguments and realise I need help with the syntax and press F1, but it doesn't work, unless I move the cursor back to the command itself.
2. when the program comes up with an error and it goes back to the program code I always have trouble finding the cursor on the screen, to see where the error is. A bigger cursor or a highlighted command would be better.
3. A built in DrawRect command that just draws the outline of a rectangle rather than fills it.

Thanks - Rico


plash(Posted 2008) [#2]
In the previous Blitz there was a Copyrect command to copy sections of the screen image around. Am I right in assuming you use Pixmaps to do this now?
You have to use GrabPixmap/GrabImage to get a section of the graphics window. I believe using GrabPixmap it will be slightly faster, and if you want to manipulate the grabbed section you have to use GrabPixmap. To copy a grabbed section you could do something like this:
DrawPixmap(GrabPixmap(0, 0, 100, 100), 200, 200)


then use various AND functions to extract the information from a bit value. Why is it so hard?
Thats pretty much what the functions for the old blitz did. It's not really that hard, if you know what you're doing ;) This function will set the r, g and b values sent to the function from a ReadPixel integer (its actually for win32 GetPixel, but it should be able to get the values):
Function ApiRGB(Pixel:Int, Red:Int Var, Green:Int Var, Blue:Int Var)
	Red = (Pixel Shr 0) & 255
	Green = (Pixel Shr  8) & 255
	Blue = (Pixel Shr 16) & 255
	
End Function



ImaginaryHuman(Posted 2008) [#3]
Careful with that, it assumes the pixel will be ABGR format which is not necessarily true.


Rico(Posted 2008) [#4]
Thanks for the help. I found out about the debugger now I think (haven't tried it yet though). Does anyone know if I need to 'release' a pixmap after using it? Also I really need to know if Blitz Max can play Music files? what format do they need to be in?
I found some info on playing what I presume to be individual sounds in the docs, but nothing on music files. What commands do I need to use to play music?
Thank you - Rico


tonyg(Posted 2008) [#5]
GC will clear up any out of scope objects.
Playsound is for sfx and music :
BlitzMax contains native support for sound files in both .wav (uncompressed) and .ogg (compressed) file formats.

I find it best to allocchannel() to obtain a channel for the playsound command.


plash(Posted 2008) [#6]
You can also use BASS or FMOD for other formats and internet streaming.