Hi, I was looking to methods to have a texture out into plugin, I saw in template that texture is created by a shaderlike method.
In my work I have a fixed size bitmap actually builded in a custom thread, is it possible to copy that bitmap data, or build up a bitmapdatarray that can just be copied to texture out ?
yes, the ‘UpdateTexture’ method is called each frame. there you can copy the bytes into the texture. you can look into the TextureUtils.cs to see how you can lock a texture and fill it with data, for example the ‘CreateColoredTexture’ method is a good start.
thank for pointing me to some docs, btw that method accept just a single value, so will create a one color texture, how can i fill the pixel onebyone ?
unsafe private void FillTexure(uint* data, int row, int col, int width, int height)
{
ushort* pDepth = (ushort*)this.depth.GetDepthMapPtr().ToPointer();
ushort* pix = pDepth+col+row*width;
byte depthPixel = (byte)this.histogram[*pix](*pix);
//a pixel is just a 32-bit unsigned int value
var pixel = UInt32Utils.fromARGB(255, depthPixel, depthPixel, depthPixel);
//copy pixel into texture
TextureUtils.SetPtrVal2D(data, pixel, row, col, width);
}
hey, I’m happy to see u left my messy comments :D by the way didnt have time to take a look at texture, I will soon, and keep upadtes , here my skype add :
mmmhhh, this is my third project in c# so im a littl bit confused , or better not skilled.
Anyway the histogram u are using with unsafe code is inside a locked loop or something by that, in my first view will be easier just to copy bitmapdata from the bitmap builded in openNi thread into a texture, seems to be easier :D
Ok I got rid of the lines, was a problem of sync between the vvvv thread and the openNI thread.
Can someone help move the pointer get outside of the iteration function? I think this is what is killing the framerate, it is getting the pointer of the frame every pixel.
what i got so far, is the texture coming out, but colors are wrong, it always dispaly striped blue, like im coping values only into blue channel or soemthign like that, well als o something else is strange, by the way framerate is normal and smooth :D
the bitmap im trying to copy is a 640x480 Format24bppRgb
FillTexure is called for each pixel. probably better to do it in your own loop so you only need to fetch the pointer once. like you show it in the out-commented code in UpdateTexture.
you can save a few comparisons and increments by using one loop intead of two (minor).
change the datatype of you’re histogram array to avoid calling UInt32Utils.fromARGB for each pixel and write something like
I made it into a 32 bit bitmap (told you hierro :p) and now I read the depth data in evaluate. It seems a little slow but still around 30fps. With color 8D
Will try copying bytes from the other thread next year.