Hi!
I based my attempts on the VideoIn(DX11.Texture DShow) Node, but without the threading and extra class.
What I’d like to achieve is to get a Bitmap into a DX11DynamicTexture - what I’m doing right now:
public unsafe void TextureFromBitmap(Bitmap bitmap)
{
//Lock bitmap so it can be accessed for texture loading
BitmapData bitmapData = bitmap.LockBits(
new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
SlimDX.DataStream dataStream = new SlimDX.DataStream(
bitmapData.Scan0,
bitmapData.Stride * bitmapData.Height,
true, false);
byte* brgba = (byte*)this.buffer0.ToPointer();
try
{
for (int i = 0; i < bitmap.Width*bitmap.Height; i++)
{
brgba[i * 4](i * 4) = (byte)dataStream.ReadByte();
brgba[i * 4 + 1](i * 4 + 1) = (byte)dataStream.ReadByte();
brgba[i * 4 + 2](i * 4 + 2) = (byte)dataStream.ReadByte();
brgba[i * 4 + 3](i * 4 + 3) = 255;
}
IntPtr temp = this.buffer0;
this.buffer0 = this.buffer1;
this.buffer1 = temp;
}
finally
{
//Free bitmap-access resources
dataStream.Dispose();
bitmap.UnlockBits(bitmapData);
}
}
buffer1 gets passed onto Update() as frontbuffer where this happens:
this.TextureFromBitmap(this.bmp);
this.FTextureOutput[0](0)[context](context).WriteData(this.frontBuffer, this.bmp.Width*this.bmp.Height*4);
Well, and I don’t see any Output :(
I assume the Bmp is loaded correctly, as I get the dimensions as DebugInfo.
Does anyone know where I’m going wrong?
Or maybe if there is a more direct way of accessing the bitmapData and writing it to the DX11DynamicTexture?
Thanks!
DX11.TextureDynamicBitmapTexture.zip (193.1 kB)