Drawing, and saving... how?

BlitzMax Forums/BlitzMax Programming/Drawing, and saving... how?

Trader3564(Posted 2008) [#1]
Hello,

The RPG im working on allows you to draw your own maps. However, im not sure how i can save the drawn picture. Basicly, i think what is needed is a function that allows me to draw ON the image for real. Or make it virtual, and render the lines, then only on save merge the 2. Also, the maps should be small in filesize. Basicly they have to be shared with other players, so i guess its better to use monochrome bitmaps or even a custom format. Any ideas?


Azathoth(Posted 2008) [#2]
Maps as in game levels? Couldn't you just save the tile ids?


Trader3564(Posted 2008) [#3]
Oh sorry, no i meen like this:




Trader3564(Posted 2008) [#4]
then they share the paper with others, but only the black lines should be send... and how? or if it doesnt matter you could as well just send the whole map.


Perturbatio(Posted 2008) [#5]
I'm sure you can develop this further:



Trader3564(Posted 2008) [#6]
Thanks! I made a modification so it allows mouse stops and a small antialiasing hack.

I guess a list of coords is smaller than a PNG?
THere is one problem tough, you cant erase. On the otherhand, its a medieval game and i think there is no need for it. haha. if they screw up the paper, they need to buy new :) just as in real life. Talking about content-control. That solves itself then, cause none will make crappy 10 tons of drawings.




Perturbatio(Posted 2008) [#7]
I guess a list of coords is smaller than a PNG?


Yup, unless they manage to put a coordinate in every pixel location. (I would obviously compress the coordinate list before sending).


Trader3564(Posted 2008) [#8]
I did notice tough, having a big image slows it down from 130 FPS to 30 FPS. 2000 nodes is costing me 100 FPS!! Its a hard call.

Look: http://www.fantasaar.com/forum/index.php/topic,149.msg1088.html#msg1088
Also drawing gets VERY difficult... :( if we could only save it as an image...


xlsior(Posted 2008) [#9]
If you're just trying to save the *image*, it's really easy:

mypic:TPixmap=GrabPixmap(0,0,640,480)
SavePixmapJPeg(mypic:TPixmap,"myfile.jpg",quality=75")


Or for lossless images, use SavePixmapPNG instead.


Trader3564(Posted 2008) [#10]
ok, that is to capture the whats on screen? (or just the buffer?). i want to capture only the lines. Also, the software freezes like 1 or 2 sec when i do JPG or PNG. So this is not an realtime option. Thanks for you entry tough! I needed a screenshot feature as well ;-)

Mark should put threading in BlitzMax!!!


Perturbatio(Posted 2008) [#11]
I'm pretty sure that the drawing could be optimized somewhat in the routine above, I was just demonstrating a concept.


skn3(Posted 2008) [#12]
Threading? To be honest, how are you writting an MMOrpg game without knowledge on how to do this type of thing.

Basically, if your saving blacks lines, what is stopping you just splitting up the drawing commands into splines? Or just taking an x,y every so often when drawing, and then using a spline to smooth out the line.

Then you could send a few coords, and produce a large amount of drawn graphics. It is the way live messenger sends hand written messages.

Example:
image 400 x 400
you want to draw a horiontal line in the middle of the image vertically. Using just 8bytes of data?

x1 (short - 2bytes) = 0
y1 (short - 2bytes) = 200
x2 (short - 2bytes) = 400
y2 (short - 2bytes) = 200

total 8 bytes :)

that beats 400 x 4 bytes (over 1k)


Trader3564(Posted 2008) [#13]
skn3[ac], i thank you for your response, but why do yo asume "i know nothing about MMOrpg" and/or threading? Its a bit rude to just throw this at me. I think you are wrong and misinformed.

Ofcorse i would be sending the coords as bytes and not as text, that is rather obvious. The problem is tough, the ammount of drawn lines, not the size in de first place.. it is what slows down BlitzMax terribly. Threading is besides that always good to have. It can gain you a lot of preformance, but its off topic, so lets skip that.

About the splines, this would rather complicate stuff, and still require the coordinates, except it smoothens stuff out. Having said that, the coord itsself as pure data aint the problem, but the drawing of lines. With other words, drawing splines will only slow things down more.

@Perturbatio , ye! Thank you ver much for the code. Ill be spending some more time on finding a way to optimize it. It seems to be a graphical issue tough.. but maybe its the looping and im mistaking. ll post back when i find out.


Bremer(Posted 2008) [#14]
Are you drawing the map each frame? Because you could create a pixmap in memory, draw the lines onto it and then covert it to an image. Then use this image to draw onto the screen. It would change it so that only one image is needed to be drawn and should speed things up a bit. At least for predrawn maps sent to other people.


Trader3564(Posted 2008) [#15]
hey, yes thats what i hoped to receive an awnser for :) really why i started this topic. I don't know how to draw in memory on pixmaps, and im not even sure wheter that would be fast enough.


Dreamora(Posted 2008) [#16]
If you only do it every few seconds it should boost the performace. Have a look at indiepath render 2 texture module. its most likely better than pixmap steps. They aren't that well suited for that as you must create an image out of it anyway.


Trader3564(Posted 2008) [#17]
hah, the guys are playing already ..
http://www.fantasaar.com/forum/index.php/topic,161.msg1102.html#new

Im currently experimenting with a TBank as TList replacement.

-edit- done.