protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.depthread, 512 * 424 * 2);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.colpoints, 1920 * 1080 * 8);
     }
 }
        protected override void CopyData(DX11DynamicTexture2D texture)
        {
            lock (m_lock)
            {
                for (int i = 0; i < this.colpoints.Length; i++)
                {
                    if (FRelativeLookup[0])
                    {
                        this.colorimage[i * 2] = (float)VMath.Map(colpoints[i].X - i % 1920, 0, 1920, 0, 1, TMapMode.Float);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y - VMath.Abs(i / 1920), 0, 1080, 0, 1, TMapMode.Float);
                    }
                    else
                    {

                        this.colorimage[i * 2] = (float)VMath.Map(colpoints[i].X, 0, 1920, 0, 1, TMapMode.Clamp);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y, 0, 1080, 0, 1, TMapMode.Clamp);
                    }
                }

                fixed (float* f = &this.colorimage[0])
                {
                    IntPtr ptr = new IntPtr(f);
                    texture.WriteData(ptr, this.width * this.height * 8);
                }
            }
        }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.depthread, 512 * 424 * 2);
     }
 }
Beispiel #5
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (c != null)
            {
                if (this.invalidate || !this.FTextureOutput[0].Contains(context))
                {
                    try
                    {
                        if (this.FTextureOutput[0].Contains(context))
                        {
                            this.FTextureOutput[0].Dispose(context);
                        }

                        DX11DynamicTexture2D t = new DX11DynamicTexture2D(context, this.FInW[0], this.FInH[0], SlimDX.DXGI.Format.B8G8R8A8_UNorm);


                        this.FTextureOutput[0][context] = t;
                    }
                    catch
                    {
                    }
                }

                if (this.copyframe && this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0][context].WriteData(this.rgbadata, this.size);
                }
            }
        }
Beispiel #6
0
        public void Update(FeralTic.DX11.DX11RenderContext context)
        {
            for (int i = 0; i < FTextureOut.SliceCount; i++)
            {
                if (!FTextureOut[i].Contains(context))
                {
                    renderer          = new BitmapRenderer();
                    renderer.TextFont = new System.Drawing.Font(FFontIn[i].Name, FFontSizeIn[i]);

                    Bitmap bmp = new Bitmap(GenerateBarcodeImage(i));

                    DX11DynamicTexture2D tex = new DX11DynamicTexture2D(context, bmp.Width, bmp.Height, SlimDX.DXGI.Format.R8G8B8A8_UNorm);

                    int pitch = tex.GetRowPitch();

                    var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat);

                    if (pitch != bmp.Width * 4)
                    {
                        tex.WriteDataPitch(data.Scan0, bmp.Width * bmp.Height * 4);
                    }
                    else
                    {
                        tex.WriteData(data.Scan0, bmp.Width * bmp.Height * 4);
                    }

                    FTextureOut[i][context] = tex;
                }
            }
        }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.depthread, 1920 * 1080 * 4);
     }
 }
        public void Update(DX11RenderContext context)
        {
            if ((isImageReady && invalidate) || !this.FTextureOutput[0].Contains(context))
            {
                if (this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0].Dispose(context);
                }

                texture = new DX11DynamicTexture2D(context, width, height, SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                this.FTextureOutput[0][context] = texture;
                invalidate = false;
            }

            if (browser != null && image != null && isImageReady && FEnabledIn[0])
            {
                lock (bLock)
                {
                    unsafe
                    {
                        fixed(byte *p = image)
                        {
                            texture.WriteDataPitch((IntPtr)p, width * height * 4);
                        }
                    }
                }
            }
        }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData<byte>(this.rawdepth);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData <int>(this.playerimage);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData <byte>(this.rawdepth);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData<int>(this.playerimage);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.depthread, 1920 * 1080 * 4);
     }
 }
Beispiel #14
0
        public void UpdateImage(DX11RenderContext context, DX11Resource <DX11DynamicTexture2D> texture, byte[] data)
        {
            if (FInvalidate || !texture.Contains(context))
            {
                var fmt = SlimDX.DXGI.Format.R8_UNorm;

                if (texture.Contains(context))
                {
                    var imgdesc = texture[context].Resource.Description;

                    if (imgdesc.Width != ValidImage.Width || imgdesc.Height != ValidImage.Height || imgdesc.Format != fmt)
                    {
                        texture.Dispose(context);
                        texture[context] = new DX11DynamicTexture2D(context, ValidImage.Width, ValidImage.Height, fmt);
                    }
                }
                else
                {
                    texture[context] = new DX11DynamicTexture2D(context, ValidImage.Width, ValidImage.Height, fmt);
#if DEBUG
                    texture[context].Resource.DebugName = "DynamicTexture";
#endif
                }
                texture[context].WriteData(data);
            }
        }
Beispiel #15
0
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.colpoints, 1920 * 1080 * 8);
     }
 }
        public void Update(IPluginIO pin, FeralTic.DX11.DX11RenderContext context)
        {
            for (int i = 0; i < this.FTextureOut.SliceCount; i++)
            {
                if (!this.FTextureOut[i].Contains(context))
                {
                    Bitmap bmp = ComputeQRCode(i);

                    DX11DynamicTexture2D tex = new DX11DynamicTexture2D(context, bmp.Width, bmp.Height, SlimDX.DXGI.Format.R8G8B8A8_UNorm);

                    int pitch = tex.GetRowPitch();

                    var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat);

                    if (pitch != bmp.Width * 4)
                    {
                        tex.WriteDataPitch(data.Scan0, bmp.Width * bmp.Height * 4);
                    }
                    else
                    {
                        tex.WriteData(data.Scan0, bmp.Width * bmp.Height * 4);
                    }

                    this.FTextureOut[i][context] = tex;
                }
            }
        }
Beispiel #17
0
        protected override void CopyData(DX11DynamicTexture2D texture)
        {
            lock (m_lock)
            {
                for (int i = 0; i < this.colpoints.Length; i++)
                {
                    if (FRelativeLookup[0])
                    {
                        this.colorimage[i * 2]     = (float)VMath.Map(colpoints[i].X - i % 640, 0, 640, 0, 1, TMapMode.Float);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y - VMath.Abs(i / 640), 0, 480, 0, 1, TMapMode.Float);
                    }
                    else
                    {
                        this.colorimage[i * 2]     = (float)VMath.Map(colpoints[i].X, 0, 640, 0, 1, TMapMode.Clamp);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y, 0, 480, 0, 1, TMapMode.Clamp);
                    }
                }

                fixed(float *f = &this.colorimage[0])
                {
                    IntPtr ptr = new IntPtr(f);

                    texture.WriteData(ptr, this.width * this.height * 8);
                }
            }
        }
Beispiel #18
0
        public void UpdateDistMap(DX11RenderContext context, DX11Resource <DX11DynamicTexture2D> texture, Image.CameraType side)
        {
            if (FInvalidate || !texture.Contains(context))
            {
                var fmt = SlimDX.DXGI.Format.R32G32_Float;

                if (texture.Contains(context))
                {
                    var imgdesc = texture[context].Resource.Description;

                    if (imgdesc.Width != ValidImage.DistortionWidth / 2 || imgdesc.Height != ValidImage.DistortionHeight || imgdesc.Format != fmt)
                    {
                        texture.Dispose(context);
                        texture[context] = new DX11DynamicTexture2D(context, ValidImage.DistortionWidth / 2, ValidImage.DistortionHeight, fmt);
                    }
                }
                else
                {
                    texture[context] = new DX11DynamicTexture2D(context, ValidImage.DistortionWidth / 2, ValidImage.DistortionHeight, fmt);
#if DEBUG
                    texture[context].Resource.DebugName = "DynamicTexture";
#endif
                }

                texture[context].WriteData(ValidImage.Distortion(side), 2);
            }
        }
Beispiel #19
0
        void CheckTextureAllocation(DX11RenderContext context)
        {
            //check if the texture we've got allocated for this context doesn't meet the current image attributes
            //this coule be on an OnImageAttributesChanged, but perhaps lazy reallocation is best
            if (FTextures.ContainsKey(context))
            {
                var tex = FTextures[context].Texture;
                if (tex.Width != this.Width || tex.Height != this.Height || tex.Format != GetFormat(FBuffer.ImageAttributes.ColorFormat))
                {
                    tex.Dispose();
                    FTextures.Remove(context);
                }
            }

            //check if we've not currently got a texture allocated for this context
            if (!FTextures.ContainsKey(context))
            {
                var tex      = new DX11DynamicTexture2D(context, Width, Height, GetFormat(FBuffer.ImageAttributes.ColorFormat));
                var resource = new Resource()
                {
                    Texture      = tex,
                    NeedsRefresh = this.FInput.Allocated,
                };
                FTextures[context]        = resource;
                this.OutputSlice[context] = tex;
            }
        }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     fixed (float* f = &world1[0])
     {
         IntPtr ptr = new IntPtr(f);
         texture.WriteData(ptr, this.width * this.height * 4 * 4);
     }
        // texture.WriteData<float>(world1);
 }
 protected unsafe override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         fixed(PointF *ptr = &this.data[0])
         {
             texture.WriteData(new IntPtr(ptr), this.width * this.height * 8);
         }
     }
 }
Beispiel #22
0
 public void Dispose()
 {
     if (this.blacktex != null)
     {
         this.blacktex.Dispose(); this.blacktex = null;
     }
     if (this.whitetex != null)
     {
         this.whitetex.Dispose(); this.whitetex = null;
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_depthlock)
     {
         fixed (Vector4* cp = &this.colorread[0])
         {
             IntPtr ptr = new IntPtr(cp);
             texture.WriteData(ptr, 512 * 424 * 16);
         }
     }
 }
Beispiel #24
0
        protected override void CopyData(DX11DynamicTexture2D texture)
        {
            fixed(float *f = &world1[0])
            {
                IntPtr ptr = new IntPtr(f);

                texture.WriteData(ptr, this.width * this.height * 4 * 4);
            }

            // texture.WriteData<float>(world1);
        }
				public ResourcePool(DX11RenderContext context, int width, int height)
				{
					FFrontTexture = new DX11DynamicTexture2D(context, width, height, SlimDX.DXGI.Format.R8_UNorm);
					byte[] black = new byte[width * height];
					for(int i=0; i<width * height; i++)
					{
						black[i] = 0;
					}
					FFrontTexture.WriteData(black);
					FContext = context;
				}
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         fixed (SkeletonPoint* f = &this.skelpoints[0])
         {
             IntPtr ptr = new IntPtr(f);
             texture.WriteData(ptr, this.width * this.height * 16);
         }
     }
 }
        protected override void CopyData(DX11DynamicTexture2D texture)
        {
            lock (m_depthlock)
            {
                fixed(Vector4 *cp = &this.colorread[0])
                {
                    IntPtr ptr = new IntPtr(cp);

                    texture.WriteData(ptr, 512 * 424 * 16);
                }
            }
        }
Beispiel #28
0
        protected override void CopyData(DX11DynamicTexture2D texture)
        {
            lock (m_lock)
            {
                fixed(SkeletonPoint *f = &this.skelpoints[0])
                {
                    IntPtr ptr = new IntPtr(f);

                    texture.WriteData(ptr, this.width * this.height * 16);
                }
            }
        }
Beispiel #29
0
        public void Update(DX11Resource <DX11DynamicTexture2D> textureSlice, DX11RenderContext context)
        {
            if (!this.Running || !FDataNewForTexture)
            {
                return;
            }
            FDataNewForTexture = false;

            DX11DynamicTexture2D tex;

            //create texture if necessary
            //should also check if properties (width,height) changed
            if (!textureSlice.Contains(context))
            {
                tex = new DX11DynamicTexture2D(context, FFrameWidth, FFrameHeight, SlimDX.DXGI.Format.R8_UNorm);
                textureSlice[context] = tex;
            }
            else if (textureSlice[context].Width != this.FFrameWidth || textureSlice[context].Height != this.FFrameHeight)
            {
                textureSlice[context].Dispose();
                tex = new DX11DynamicTexture2D(context, FFrameWidth, FFrameHeight, SlimDX.DXGI.Format.R8_UNorm);
                textureSlice[context] = tex;
            }
            else
            {
                tex = textureSlice[context];
            }

            FDoubleBuffer.LockFront.AcquireReaderLock(100);
            try
            {
                //write data to surface
                if (FFrameWidth == tex.GetRowPitch())
                {
                    tex.WriteData(FDoubleBuffer.Front);
                }
                else
                {
                    GCHandle pinnedArray = GCHandle.Alloc(FDoubleBuffer.Front, GCHandleType.Pinned);
                    tex.WriteDataPitch(pinnedArray.AddrOfPinnedObject(), FDoubleBuffer.Front.Length);
                    pinnedArray.Free();
                }
            }
            catch
            {
            }
            finally
            {
                FDoubleBuffer.LockFront.ReleaseReaderLock();
            }
        }
Beispiel #30
0
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         if (this.FRawData[0])
         {
             texture.WriteData(this.colpoints, this.width * this.height * 8);
         }
         else
         {
             texture.WriteData(this.convertedColPoints, this.width * this.height * 8);
         }
     }
 }
Beispiel #31
0
            unsafe public void Update(DX11RenderContext context)
            {
                if (FOutTexture.SliceCount == 0 || buffer_ptr == IntPtr.Zero)
                {
                    return;
                }

                if (invalidate || !FOutTexture[0].Contains(context))
                {
                    // do not update buffer from here
                    lockBuffer = true;

                    SlimDX.DXGI.Format   fmt;
                    Texture2DDescription desc;

                    fmt = SlimDX.DXGI.Format.B8G8R8A8_UNorm;
                    if (FOutTexture[0].Contains(context))
                    {
                        desc = FOutTexture[0][context].Resource.Description;

                        if (desc.Width != width || desc.Height != height || desc.Format != fmt)
                        {
                            FOutTexture[0].Dispose(context);
                            FOutTexture[0][context] = new DX11DynamicTexture2D(context, width, height, fmt);
                        }
                    }
                    else
                    {
                        FOutTexture[0][context] = new DX11DynamicTexture2D(context, width, height, fmt);
                    }

                    desc = FOutTexture[0][context].Resource.Description;

                    // sometimes occur errors.
                    var t = FOutTexture[0][context];
                    t.WriteData(buffer_ptr, bufferSize);

                    invalidate = false;

                    // ready to update buffer
                    lockBuffer = false;
                }
            }
Beispiel #32
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (this.reset)
            {
                if (this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0].Dispose(context);
                }

                DX11DynamicTexture2D t = new DX11DynamicTexture2D(context, this.videoin.GetWidth(), this.videoin.GetHeight(), SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                this.FTextureOutput[0][context] = t;
                this.reset = false;
            }

            if (this.invalidate)
            {
                this.FTextureOutput[0][context].WriteData(this.videoin.frontBuffer, this.videoin.size);
                this.invalidate = false;
            }
        }
		void CheckTextureAllocation(DX11RenderContext context)
		{
			//check if the texture we've got allocated for this context doesn't meet the current image attributes
			//this coule be on an OnImageAttributesChanged, but perhaps lazy reallocation is best
			if (FTextures.ContainsKey(context))
			{
				var tex = FTextures[context].Texture;
				if (tex.Width != this.Width || tex.Height != this.Height || tex.Format != GetFormat(FBuffer.ImageAttributes.ColorFormat))
				{
					tex.Dispose();
					FTextures.Remove(context);
				}
			}

			//check if we've not currently got a texture allocated for this context
			if (!FTextures.ContainsKey(context))
			{
				var tex = new DX11DynamicTexture2D(context, Width, Height, GetFormat(FBuffer.ImageAttributes.ColorFormat));
				var resource = new Resource()
				{
					Texture = tex,
					NeedsRefresh = this.FInput.Allocated,
				};
				FTextures[context] = resource;
				this.OutputSlice[context] = tex;
			}
		}
Beispiel #34
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (c != null)
            {
                if (this.invalidate || !this.FTextureOutput[0].Contains(context))
                {
                    try
                    {
                        if (this.FTextureOutput[0].Contains(context))
                        {
                            this.FTextureOutput[0].Dispose(context);
                        }

                        DX11DynamicTexture2D t = new DX11DynamicTexture2D(context, this.FInW[0], this.FInH[0], SlimDX.DXGI.Format.B8G8R8A8_UNorm);

                        this.FTextureOutput[0][context] = t;
                    }
                    catch
                    {

                    }
                }

                if (this.copyframe && this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0][context].WriteData(this.rgbadata, this.size);
                }
            }
        }
Beispiel #35
0
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteData <ColorSpacePoint>(this.points);
 }
Beispiel #36
0
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteData <byte>(this.colorimage);
 }
		public void Update(DX11Resource<DX11DynamicTexture2D> textureSlice, DX11RenderContext context)
		{
			if (!this.Running || !FDataNewForTexture)
			{
				return;
			}
			FDataNewForTexture = false;

			DX11DynamicTexture2D tex;

			//create texture if necessary
			//should also check if properties (width,height) changed
			if (!textureSlice.Contains(context))
			{
				tex = new DX11DynamicTexture2D(context, FFrameWidth, FFrameHeight, SlimDX.DXGI.Format.R8_UNorm);
				textureSlice[context] = tex;
			}
			else if (textureSlice[context].Width != this.FFrameWidth || textureSlice[context].Height != this.FFrameHeight)
			{
				textureSlice[context].Dispose();
				tex = new DX11DynamicTexture2D(context, FFrameWidth, FFrameHeight, SlimDX.DXGI.Format.R8_UNorm);
				textureSlice[context] = tex;
			}
			else
			{
				tex = textureSlice[context];
			}

			FDoubleBuffer.LockFront.AcquireReaderLock(100);
			try
			{
				//write data to surface
				if (FFrameWidth == tex.GetRowPitch())
				{
					tex.WriteData(FDoubleBuffer.Front);
				}
				else
				{
					GCHandle pinnedArray = GCHandle.Alloc(FDoubleBuffer.Front, GCHandleType.Pinned);
					tex.WriteDataPitch(pinnedArray.AddrOfPinnedObject(), FDoubleBuffer.Front.Length);
					pinnedArray.Free();
				}
			}
			catch
			{
			}
			finally
			{
				FDoubleBuffer.LockFront.ReleaseReaderLock();
			}
		}
			unsafe void ThreadedFunction()
			{
				Random random = new Random();
				Thread.Sleep((int)(random.NextDouble() * 1000.0));

				while(FRunningThread)
				{
					try
					{
						if (FNeedsRelist)
						{
							try
							{
								var filenames = Directory.GetFiles(FPath, FMask);
								lock (FMemoryPoolLock)
								{
									FMemoryPool.Clear();
									foreach (var filename in filenames)
									{
										var image = new Image();
										image.Filename = filename;
										FMemoryPool.Add(image);
									}
								}
							}
							catch (Exception e)
							{
								FLogger.Log(e);
							}
							FNeedsRelist = false;
						}

						lock (FMemoryPoolLock)
						{
							int imageIndex = 0;
							foreach (var image in FMemoryPool)
							{
								try
								{
									if (!image.LoadedCPU)
									{
										var bitmap = new Bitmap(image.Filename);
										image.Data = new byte[FWidth * FHeight];
										var bitmapData = bitmap.LockBits(new Rectangle(0, 0, FWidth, FHeight), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
										Exception e3 = null;
										try
										{
											byte* input = (byte*)bitmapData.Scan0;
											fixed (byte* outputFixed = &image.Data[0])
											{
												byte* output = outputFixed;
												for (int i = 0; i < FWidth * FHeight; i++)
												{
													input++; //a

													int pixelData = 0;
													pixelData += *input++;
													pixelData += *input++;
													pixelData += *input++;

													*output++ = (byte)(pixelData / 3);
												}
											}

											image.LoadedCPU = true;
										}
										catch (Exception e2)
										{
											e3 = e2;
										}
										finally
										{
											bitmap.UnlockBits(bitmapData);
										}
										if (e3 != null)
										{
											throw (e3);
										}
										//we've done enough work for this cycle
										break;
									}

									lock (FTexturePoolLock)
									{
										foreach (var resourcePool in FTexturePool)
										{
											lock(FLockCreation)// make sure all threads don't go crazy at the same time
											{
												var context = resourcePool.Key;
												var texturePool = resourcePool.Value.FTextures;
												if (texturePool.Count <= imageIndex)
												{
													var texture = new DX11DynamicTexture2D(context, FWidth, FHeight, SlimDX.DXGI.Format.R8_UNorm);

													GCHandle pinnedArray = GCHandle.Alloc(image.Data, GCHandleType.Pinned);
													IntPtr pointer = pinnedArray.AddrOfPinnedObject();
													texture.WriteDataPitch(pointer, image.Data.Length, FWidth);
													pinnedArray.Free();

													texturePool.Add(texture);
												}
											}
											//we've done enough work for this cycle
											break;
										}
									}
								}
								catch (Exception e)
								{
									FLogger.Log(e);
								}
								imageIndex++;
							}
						}
					}
					catch(Exception e)
					{

					}
					Thread.Sleep(10);
				}
			}
Beispiel #39
0
        public void Update(DX11RenderContext context)
        {
            Stopwatch w = Stopwatch.StartNew();

            int cnt = 0;

            foreach (VlcPlayer vlc in this.players)
            {
                if (vlc != null)
                {
                    if (vlc.IsValid && vlc.Width > 0 && vlc.Height > 0)
                    {
                        DX11DynamicTexture2D t;
                        if (!this.FTextureOut[cnt].Contains(context))
                        {
                            t = new DX11DynamicTexture2D(context, vlc.Width, vlc.Height, SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                            #if DEBUG
                            t.Resource.DebugName = "Vlc";
                            #endif
                            this.FTextureOut[cnt][context] = t;
                        }
                        else
                        {
                            t = this.FTextureOut[cnt][context];
                            if (t.Width != vlc.Width || t.Height != vlc.Height)
                            {
                                this.FTextureOut[cnt].Dispose(context);
                                DX11DynamicTexture2D t2 = new DX11DynamicTexture2D(context, vlc.Width, vlc.Height, SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                                #if DEBUG
                                t2.Resource.DebugName = "Vlc";
                                #endif
                                this.FTextureOut[cnt][context] = t2;
                                t = t2;
                            }
                        }

                        if (vlc.Play)
                        {
                            IntPtr ptr = vlc.frontBuffer;

                            if (ptr != IntPtr.Zero)
                            {
                                if (vlc.Width * 4 == t.GetRowPitch())
                                {
                                    t.WriteData(ptr, vlc.Width * vlc.Height * 4);
                                }
                                else
                                {
                                    t.WriteDataPitch(ptr, vlc.Width * vlc.Height * 4);
                                }
                            }
                        }
                    }
                    else
                    {
                        this.FTextureOut[cnt].Dispose(context);
                    }
                }
                cnt++;
            }

            w.Stop();
            this.FPinOutCopyTime.SetValue(0, w.ElapsedMilliseconds);
        }
Beispiel #40
0
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteDataStride(this.rawdepth);
 }
Beispiel #41
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            Stopwatch w = Stopwatch.StartNew();

            int cnt = 0;
            foreach (VlcPlayer vlc in this.players)
            {

                if (vlc != null)
                {
                    if (vlc.IsValid)
                    {
                        DX11DynamicTexture2D t;
                        if (!this.FTextureOut[cnt].Contains(context))
                        {
                            t = new DX11DynamicTexture2D(context, vlc.Width, vlc.Height, SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                            #if DEBUG
                            t.Resource.DebugName = "Vlc";
                            #endif
                            this.FTextureOut[cnt][context] = t;
                        }
                        else
                        {
                            t = this.FTextureOut[cnt][context];
                            if (t.Width != vlc.Width || t.Height != vlc.Height)
                            {
                                this.FTextureOut[cnt].Dispose(context);
                                DX11DynamicTexture2D t2 = new DX11DynamicTexture2D(context, vlc.Width, vlc.Height, SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                                #if DEBUG
                                t2.Resource.DebugName = "Vlc";
                                #endif
                                this.FTextureOut[cnt][context] = t2;
                                t = t2;
                            }
                        }

                        if (vlc.Play)
                        {
                            IntPtr ptr = vlc.frontBuffer;

                            if (vlc.Width * 4 == t.GetRowPitch())
                            {
                                t.WriteData(ptr, vlc.Width * vlc.Height * 4);
                            }
                            else
                            {
                                t.WriteDataPitch(ptr, vlc.Width * vlc.Height * 4);
                            }
                        }
                    }
                    else
                    {
                        this.FTextureOut[cnt].Dispose(context);
                    }
                }
                cnt++;
            }

            w.Stop();
            this.FPinOutCopyTime.SetValue(0, w.ElapsedMilliseconds);
        }
 protected abstract void CopyData(DX11DynamicTexture2D texture);
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteDataStride(this.rawdepth);
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteData<ColorSpacePoint>(this.points);
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteData<byte>(this.colorimage);
 }
Beispiel #46
0
 public void Dispose()
 {
     if (this.blacktex != null) { this.blacktex.Dispose(); this.blacktex = null; }
     if (this.whitetex != null) { this.whitetex.Dispose(); this.whitetex = null; }
 }
        public void Update(IPluginIO pin, FeralTic.DX11.DX11RenderContext context)
        {
            for (int i = 0; i < this.FTextureOut.SliceCount; i++)
            {
                if (!this.FTextureOut[i].Contains(context))
                {
                    Bitmap bmp = ComputeQRCode(i);

                    DX11DynamicTexture2D tex = new DX11DynamicTexture2D(context, bmp.Width, bmp.Height, SlimDX.DXGI.Format.R8G8B8A8_UNorm);

                    int pitch = tex.GetRowPitch();

                    var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat);

                    if (pitch != bmp.Width * 4)
                    {
                        tex.WriteDataPitch(data.Scan0, bmp.Width * bmp.Height * 4);
                    }
                    else
                    {
                        tex.WriteData(data.Scan0, bmp.Width * bmp.Height * 4);
                    }

                    this.FTextureOut[i][context] = tex;

                }
            }
        }
Beispiel #48
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (this.reset)
            {
                if (this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0].Dispose(context);
                }

                DX11DynamicTexture2D t = new DX11DynamicTexture2D(context, this.videoin.GetWidth(), this.videoin.GetHeight(), SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                this.FTextureOutput[0][context] = t;
                this.reset = false;
            }

            if (this.invalidate)
            {
                this.FTextureOutput[0][context].WriteData(this.videoin.frontBuffer, this.videoin.size);
                this.invalidate = false;
            }
        }
 protected abstract void CopyData(DX11DynamicTexture2D texture);
Beispiel #50
0
            // ======================================================
            // dx11
            // ======================================================
            unsafe public void Update(DX11RenderContext context)
            {
                if (FOutTexture.SliceCount == 0 || glControl.Size.Width == 0 || glControl.Size.Height == 0)
                {
                    return;
                }

                if (this.invalidate || !FOutTexture[0].Contains(context))
                {
                    Format format = Format.R8G8B8A8_UNorm;
                    Texture2DDescription desc;

                    //this.width = glControl.Size.Width;
                    //this.height = glControl.Size.Height;
                    //pixelBuffer = new byte[this.width * this.height * channels];
                    //flippedBuffer = new byte[pixelBuffer.Length];

                    if (FOutTexture[0].Contains(context))
                    {
                        desc = FOutTexture[0][context].Resource.Description;
                        if (desc.Width != this.width || desc.Height != this.height || desc.Format != format)
                        {
                            FOutTexture[0].Dispose(context);
                            FOutTexture[0][context] = new DX11DynamicTexture2D(context, this.width, this.height, format);
                        }
                    }
                    else
                    {
                        FOutTexture[0][context] = new DX11DynamicTexture2D(context, this.width, this.height, format);
                    }

                    desc = FOutTexture[0][context].Resource.Description;

                    // GL.getPixels results is flipped vertically, so fix it
                    int rowIndex, colIndex, srcIndex, dstIndex;
                    for (int i = 0; i < this.width * this.height; i++)
                    {
                        rowIndex = (this.height - 1) - (i / this.width);
                        colIndex = i % this.width;
                        srcIndex = ((rowIndex * this.width) + colIndex) * channels;
                        dstIndex = i * channels;

                        flippedBuffer[dstIndex]     = pixelBuffer[srcIndex];
                        flippedBuffer[dstIndex + 1] = pixelBuffer[srcIndex + 1];
                        flippedBuffer[dstIndex + 2] = pixelBuffer[srcIndex + 2];
                        flippedBuffer[dstIndex + 3] = pixelBuffer[srcIndex + 3];
                    }

                    //int stride = channels;
                    var t = FOutTexture[0][context];
                    //t.WriteData(flippedBuffer);
                    //t.WriteData(pixelBuffer);

                    fixed(byte *b_ptr = &flippedBuffer[0])
                    {
                        IntPtr ptr = new IntPtr(b_ptr);

                        if (t.GetRowPitch() == desc.Width * channels)
                        {
                            t.WriteData(ptr, desc.Width * desc.Height * channels);
                        }
                        else
                        {
                            t.WriteDataPitch(ptr, desc.Width * desc.Height * channels, channels);
                        }
                    }

                    this.invalidate = false;
                }
            }