bank to texture !
Blitz3D Forums/Blitz3D Programming/bank to texture !
| ||
hello, I'm looking for a way to load an image into a bank by piece, example: for a 100 KB, in 10 times, 10 kb each VBL. and then when finished transfer that into a texture and use it. which would it? thank you, for your help. |
| ||
Standard blitz commands for loading images & textures will load the image or texture in its entirety. If you were to read the file directly with readfile() or openfile() it would still provide access to the entire file upon opening. Without knowing what the effect is you're trying to achieve it's difficult to know what the best piece of advice is..a file that is 100kb will load into a texture or image very quickly. |
| ||
If it is necessary to store the file in memory (a bank, etc.), possibly from transferring data over the network or something, then later there are two methods that come to mind that you can use to 'convert' the bank into a texture. 1 - Save the data to a file, then load it with the standard commands. This is very fast (even though it involves writing and loading a file), and will work for whatever type of image you have in your bank. 2 - If the data in the bank is just ARGB values for the pixels (i.e. a straight bitmap) then use RTLMoveMemory commands or etc to copy the data into a texture. This would be annoying due to issues like the rounding up of image widths, etc. Option 1 is probably best, and most certainly the easiest. |
| ||
You may also use the copyrect command to copy from an Imagebuffer to a texturebuffer. But you should know: whenever you are altering a texture, the system will have to re-upload the entire texture. Therefor the process is rather slow, even if you alter only a single pixel. We have made some speed tests, some time ago, maybe you'll find it in the archives. If you are using the Texture flag 256 then certain operations (eg. maybe copyrect from backbuffer to texturebuffer) is a lot faster. Editing a Texture, then save it and load it using Loadtexture usually doesn't work because DirectX "thinks" it has already loaded the Texture and will then use the cached texture. TO use a Bank doesn't make much sense because as soon as you want to copy the bank to the texture, there will be this texture-upload bottleneck. Also if you can manage to vector-bend the address of a texture to a bank, so you can directly POKE to the texture, there will still be this bottleneck. Best method without any extensions is in my opinion: Use Texture Flag 256, then use Copyrect from Backbuffer to Texturebuffer. (Always keep an actual copy of the texture as an image, use DrawBlock to draw it to the backbuffer and do the editing on the backbuffer, using writepixelfast or so.) |