Faster Writepixel?

BlitzMax Forums/BlitzMax Programming/Faster Writepixel?

FBEpyon(Posted 2014) [#1]
Hello,

I'm trying to figure out a faster way to write argb data to a pixmap that is then converted to texture for minib3d..



Does anyone know a faster way..?

Thanks,


Jur(Posted 2014) [#2]
The fastest way would be with pointers. For RGBA pixmaps:




Hardcoal(Posted 2014) [#3]
Good info


FBEpyon(Posted 2014) [#4]
Thanks for the awesome help. I will give this a try when I get home.


Mr. Goober(Posted 2014) [#5]
There's one thing I would probably make mention here. Pixmaps will have different formats, so it's best to use that in your calculations or you might end up writing pixels the wrong way.

For example, PF_RGBA8888 (32-bit pixel data, big endian, with alpha) takes 4 bytes (an Int) to store one pixel. Other formats such as PF_RGB888 (24-bit, RGB components only) is 3 bytes without alpha. I think the most common format is the first one I mentioned.

The pixels in memory are ready left to right, top to bottom. Be careful not to go past the amount of pixels in memory, as it can cause some errors in your RAM if you are not careful.

IF you have a 10 by 10 pixmap with PF_RGBA8888 format, then this means at you have 10*10*4 bytes allocated (400 bytes). If using an Int pointer with a name of something like intptr, you have a range of intptr[0] to intptr[399]. It will allow you to go beyond these ranges though, so it's important to be careful.

Aaaand that is all. Happy programming!