Canvas to Bitmap
Hi guys, another question, is there any way to convert a canvas to an image? in standrd wpf I'd do something like this:
(which comes from http://stackoverflow.com/questions/2141 ... -sharp-wpf)
Code: Select all
Rect bounds = VisualTreeHelper.GetDescendantBounds(canvas);
double dpi = 96d;
RenderTargetBitmap rtb = new RenderTargetBitmap((int)bounds.Width, (int)bounds.Height, dpi, dpi, System.Windows.Media.PixelFormats.Default);
DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
VisualBrush vb = new VisualBrush(cnvs);
dc.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
}
rtb.Render(dv);
Re: Canvas to Bitmap
In Unity, you can user render to texture to generate a texture given a XAML.
Is that what you want?
Is that what you want?
Re: Canvas to Bitmap
I'm not sure, what I need is to get an image from a canvas where a user was printing with his finger (kind of signature)
can I do it through Unity render passing the canvas as param?
thanks!
can I do it through Unity render passing the canvas as param?
thanks!
Re: Canvas to Bitmap
Render to texture is useful to capture a XAML into a texture. That texture can be later used in the same scene or even in another XAML.
But if you just need an image (not a texture) then I think the best way would be capturing the main buffer rendered by Unity. Never did it, but I am sure there should be an easy way to achieve.
But if you just need an image (not a texture) then I think the best way would be capturing the main buffer rendered by Unity. Never did it, but I am sure there should be an easy way to achieve.
Re: Canvas to Bitmap
Ok, then how could I pass just the canvas (not the whole screen or usercontrol) to unity to do it?
thanks!
thanks!
Re: Canvas to Bitmap
Yes, but the canvas cannot be shared between several Unity components. So, you need to create a NoesisGUIPanel component and set its content to a FrameworkElement (the canvas itself, not active in a different NoesisGUIPanel ). Attach the NoesisGUIPanel to a GameObject having a RenderTexture and the content of the canvas will be rendered into that texture.
Who is online
Users browsing this forum: No registered users and 3 guests