tag:blogger.com,1999:blog-563071785757928434.post2501743908932264561..comments2024-02-21T08:31:04.853+01:00Comments on Kodierer [Coder]: One Bitmap to Rule Them All - WriteableBitmapEx for WinRT Metro StyleRene Schultehttp://www.blogger.com/profile/12777157871967896549noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-563071785757928434.post-818803447499040902016-03-09T07:07:53.395+01:002016-03-09T07:07:53.395+01:00I think your logic might be wrong. If you want to ...I think your logic might be wrong. If you want to merge multiple images and save it, you probably want to manually draw each image on top of each other and then save the resulting bitmap. I know there are methods available that let you render a control to a bitmap, but I don't think it would be efficient if you're developing a high-performance image-processing application. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-3228671103706058482015-12-15T15:44:44.574+01:002015-12-15T15:44:44.574+01:00Not really. You have to create a TextBlock add it ...Not really. You have to create a TextBlock add it to the visual tree and then use RenderToBitmap.Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-75643094434159085492015-12-15T15:38:07.330+01:002015-12-15T15:38:07.330+01:00Hello,
I'm developing an app for Windows 10 (...Hello,<br /><br />I'm developing an app for Windows 10 (UWP)and I'm looking for a way to draw some text over an image (all in background). I've tried creating all UIElements programmatically but writeableBmp.RenderAsync crashes :( Is it possible to use WritableBitmapEx to achieve that? Many thanks!Ernestonoreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-87228695534479466182014-04-23T08:50:12.149+02:002014-04-23T08:50:12.149+02:00I'm not the author of the WinRTXamlToolkit, so...I'm not the author of the WinRTXamlToolkit, so this is the wrong place to ask. Check their CodePlex Discussions. <br />But if you read my blog posts, you can see here how to render any UIElement like your photoCanvas into a WB: <br />http://kodierer.blogspot.de/2013/12/easy-render-writeablebitmapex-with.html<br />And how to encode that WB into a JPEG or PNG:<br />http://kodierer.blogspot.de/2013/12/how-to-encode-and-save-writeablebitmap.htmlRene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-31058390166366392482014-04-23T06:24:45.924+02:002014-04-23T06:24:45.924+02:00Hi Rene, I have seen this blog post of yours. But ...Hi Rene, I have seen this blog post of yours. But the problem is while i convert the canvas to WritableBitMap to use the function in your blog post, i do not get the exact bitmap. I use Windows.UI.Xaml.Media.Imaging.WriteableBitmap bitmap = await WriteableBitmapRenderExtensions.Render(photoCanvas); This is from WinRTXamlToolkit. This is not working properly. My canvas has two images. one on top of the other. photoCanvas is the name of my canvas. Any suggestions to convert canvas with two images to WritableBitmap? Anju Edadanhttps://www.blogger.com/profile/10261769594398524920noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-3946882340905766232014-04-22T21:07:10.716+02:002014-04-22T21:07:10.716+02:00Well, see this blog post which covers that: http:/...Well, see this blog post which covers that: http://kodierer.blogspot.de/2013/12/how-to-encode-and-save-writeablebitmap.htmlRene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-53856523285269697892014-04-22T13:43:03.294+02:002014-04-22T13:43:03.294+02:00Please let me know how to convert canvas to image(...Please let me know how to convert canvas to image(jpg/png) in Windows 8 app written in C# and XAML. I have one image over another image in canvas.Anju Edadanhttps://www.blogger.com/profile/10261769594398524920noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-20298969631069326722012-09-27T18:17:37.709+02:002012-09-27T18:17:37.709+02:00Indeed.
Unfortunately there's no way. Not eve...Indeed.<br /><br />Unfortunately there's no way. Not even with DirectX. Only if you render all in DirectX.<br />:(<br /><br />MS is aware of this and we can only hope a Service Pack will bring this feature.Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-13322611475548136672012-09-27T18:08:14.412+02:002012-09-27T18:08:14.412+02:00Hi Rene,
I am sure you might have got this questi...Hi Rene,<br /><br />I am sure you might have got this question a lot but I was wondering if WriteableBitmapEx has a feature that I can use to save a Canvas as image(jpg/png) in a Windows 8 app written in C# and XAML. Please let me know.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-50733830061926739662012-09-11T14:55:46.615+02:002012-09-11T14:55:46.615+02:00Sure. Taken from the Blit sample you can find in t...Sure. Taken from the Blit sample you can find in the source code repository:<br /><br />var particleBmp = await LoadBitmap("///Assets/FlowerBurst.jpg");<br /><br />async Task LoadBitmap(string path)<br />{<br /> Uri imageUri = new Uri(BaseUri, path);<br /> var bmp = await BitmapFactory.New(1, 1).FromContent(imageUri);<br /> return bmp;<br />}Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-91695059738166664232012-09-11T13:31:18.648+02:002012-09-11T13:31:18.648+02:00Do you have an example of using FromContent in a W...Do you have an example of using FromContent in a WinRT app? I looked at the StackOverflow answer you gave, but that doesn't show calling the method.Dennishttps://www.blogger.com/profile/03609255085621514906noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-8173084181289174302012-05-31T21:53:46.776+02:002012-05-31T21:53:46.776+02:00Hello David,
You're encoding the bitmap as &...Hello David, <br /><br />You're encoding the bitmap as "BMP" format and there's some header / footer information additionally to the bitmap data. <br />Use the FromByteArray() method with data you got from the WriteableBitmap.ToByteArray().Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-22045909387703777372012-05-31T06:53:45.371+02:002012-05-31T06:53:45.371+02:00Hello Renè, I was trying to use your fantastic lib...Hello Renè, I was trying to use your fantastic library with WInRT to capture live snapshots from a webcam (without passing from isolated storage ;).<br /><br />I noticed that there are more bytes than expected, and I have to jump two bytes in FromByteArray in order to display a clear image.<br /><br />This is the (working) code:<br /><br /><br />ImageEncodingProperties imageProperties = new Windows.Media.MediaProperties.ImageEncodingProperties();<br />var devInfoCollection = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);<br /><br />var mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();<br />await mediaCaptureMgr.InitializeAsync();<br /><br />capturePreview.Source = mediaCaptureMgr;<br />await mediaCaptureMgr.StartPreviewAsync();<br /><br />imageProperties.Subtype = "BMP";<br />imageProperties.Width = 320;<br />imageProperties.Height = 240;<br /><br />WriteableBitmap w = new WriteableBitmap(320, 240);<br />MemoryStream s = new MemoryStream();<br /><br /><br />IRandomAccessStream rs = new InMemoryRandomAccessStream();<br />await mediaCaptureMgr.CapturePhotoToStreamAsync(imageProperties, rs); <br /><br />DataReader rd = new DataReader(rs.GetInputStreamAt(0));<br />await rd.LoadAsync((uint)rs.Size);<br />byte[] b = new Byte[rs.Size];<br />rd.ReadBytes(b);<br />Debug.WriteLine(b.Length); // 307254 bytes instread of 307200 (ARGB: 320x340x4) !!<br /><br />w.FromByteArray(b, 2, (int)w.PixelBuffer.Length); // => I found that it is good starting from the 3rdbyte, ignoring last 51 (???)<br /><br />imgFrame.Source = w; // s;<br /><br /><br />Any ideas what are those exceeding bytes...?<br /><br />Best,<br />DavidDavidhttp://www.devtek.itnoreply@blogger.com