CreateRamStream ?
BlitzMax Forums/BlitzMax Programming/CreateRamStream ?
| ||
Hi :) I have try to understand the real use of RamStream but without example it's not very easy :) Anybody have an example code to use Ram Stream ? I have try : Global MyRam:TRamStream Global MyBank:TBank MyRam=CreateRamStream(MyBank,BankSize(MyBank),True,True) WriteLine MyRam,"CECI EST UN TEST" SeekStream(MyRam,0) Print ReadLine(MyRam) |
| ||
Strict Global myRam : Byte Ptr = MemAlloc(128) 'allocate 128 bytes of memory to myRam Global myStream : TRamStream = CreateRamStream(myRam, 128, True, True) 'Create a ram stream and link it to myRam WriteLine(myStream, "test text") 'write the text SeekStream(myStream, 0) 'reset the stream to the beginning Print ReadLine(myStream)'read the text and print it myStream = Null MemFree(myRam, 128) 'clear the alloced memory End |
| ||
Many thanks Perturbatio :) your alway here to save me :) But a last question ! it is possible to load media like image directly from ram stream ? And a little example ? :) Thanks |
| ||
np :) I've just updated it with comments to help out |
| ||
Thanks ! if you have information about my previous post ! i'll take it :) |
| ||
incidentally, you can also just use TRamStream.Create() instead of CreateRamStream (it takes the same parameters). CreateRamStream simply calls the create method. *EDIT* I'll try and knock up something for loading an image now. |
| ||
I love you :) |
| ||
Hi, RamStream is pretty low level, and in there mainly to support 'incbin::'. For streaming in/out of banks, use a BankStream instead. It will automatically grow the bank for you when writing and will ensure you don't read/write outside the limits of the bank. |
| ||
Mark, can you specify a RamStream or a BankStream as a URL? |
| ||
solved (a bit messy). *EDIT* The same thing using a TBankStream: |
| ||
Many thanks Perturbatio ! i 'll explore your code ! |