Saving image in windows 8.1 using stream and bitmap encoder id

Hi
var renderTargetBitmap = new RenderTargetBitmap();
await renderTargetBitmap.Render(myElementTree);
var pixels = await renderTargetBitmap.GetPixelsAsync();
var picker = new FileSavePicker();
// Picker setup
var file = await picker.PickSaveFileAsync();
// File validation
using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
var encoder = await
BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream);
encoder.SetPixelData(BitmapPixelFormat.Rgba8, 100, 0, 96, 96,
await renderTargetBitmap.GetPixelsAsync());
await encoder.FlushAsync();
I have already used the code snippet. Could you please tell me how to save UIElement tree by having the stream and bitmap encoder id as input?
Thanks
Satheesh

Here you go. Set up the file picker and call our CaptureElementToFile function. In this case it's passing the page to capture the whole screen:
FileSavePicker picker = new FileSavePicker();
picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
picker.SuggestedFileName = "capture.bmp";
picker.FileTypeChoices.Add("Bitmap File",new List<string>() { ".bmp" });
StorageFile file = await picker.PickSaveFileAsync();
CaptureElementToFile(this, file);
And here's CaptureElementToFile. The BitmapEncoder needs to know information about the size and shape of the pixel buffer and it needs to have the pixels as an Array. If you want to encode to a different size you can include a BitmapTransform.
async void CaptureElementToFile(UIElement element, StorageFile file)
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
await renderTargetBitmap.RenderAsync(element);
IBuffer pixelBuffer = await renderTargetBitmap.GetPixelsAsync();
DisplayInformation dispInfo = DisplayInformation.GetForCurrentView();
using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream);
encoder.SetPixelData(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Straight,
(uint)renderTargetBitmap.PixelWidth,
(uint)renderTargetBitmap.PixelHeight,
dispInfo.LogicalDpi,dispInfo.LogicalDpi,
pixelBuffer.ToArray());
await encoder.FlushAsync();
--Rob

Similar Messages

  • In windows cmd lueo used \ \ server and get to the pc but mac as done

    in windows cmd lueo used \ \ server
    and get to the pc but mac as done

    Your question (if it is one) makes no sense whatever.
    Please describe your problem in greater detail, and include details of what Mac you have and what version of OS X.

  • I allocated too much space on the Windows side when using bootcamp and want to take some space back for the Mac side is there any easy way to do this?

    I allocated too much space on the Windows side when using bootcamp and want to take some space back for the Mac side is there any easy way to do this?

    Purchase and use Paragon Camp Tune

  • How can I erase images from the clipboard while using ink and slide or sketches and lines apps?

    I've been having trouble with my clipboard while using my adobe ink. Is there any way I can erase the images saved on the clipboard, because have been trying and I can't find a way to do it, it seems like the only option is by turning the selection into favorites and then a trashcan icon appears, but even if I choose delete it will only be erased from the clipboard favorites while remaining on the clipboard.
    I've thought erasing the sketches App, or deleting the project but I don't want to risk losing my work.
    Thanks!

    I posed a similar question in the Draw forum and got this reply:
    Re: How to clear the clipboard and empty drawings ?
    In short: you can't erase those clippings, at least not currently.

  • Windows Authentication by using HTMLDB and Active directorty (AD)

    Is it possible to write an application by using HTMLDB to use windows authentication by using Active Directory (AD) ?
    Thanks!

    Hi Tanya,
    The IS_MEMBER routine won't necessarily work with AD since it actually checks for the sort of user/group relationship that is stored in OID (AD can store the relationship in a different way).
    To check group membership you will need to write your own code which checks the group and/or user to determine whether they are in a specific group or not. I believe there are already some examples of that code in this forum, if you search for 'group and ldap' you should be able to find some examples.
    If not, then post back and I'll try and dig something out.

  • How do I backup an older 3GS saving ipod library that I'm using temporarily and restore it later?

    Can I restore a different backup on the phone in the time I'm using it? My 3Gs went completely and unexpectantly dead and my brother had one I put my SIMM card in to use for awhile. I want to preserve all his music and data but in the meantime load my last backup on this phone so I have access to my information. I want to do this in a way to be sure to preserve his ipod music. Please tell me the right steps so I don't lose his data and can restore it when I give it back.  Thanks

    iTunes places the backup file here:
    Where iTunes backups are stored on your computer
    The folder where your backup data are stored varies depending on the computer's operating system. Make sure the backup folder is included in your periodic data-backup routine.
    iTunes places the backup files in the following places:
    Mac:~/Library/Application Support/MobileSync/Backup/
    Windows XP:\Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    Note: To quickly access the Application Data folder, click Start, and choose Run. Type %appdata% and click OK.
    Windows Vista and Windows 7:\Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\
    Note: To quickly access the AppData folder, click Start. In the search bar, type %appdata% and press theReturn key.
    Yes, if something happens to the iPod, you can restore the iPod from backup.
    You can copy the iTunes library as a backup by:
    iTunes: Back up your iTunes library by copying to an external hard drive
    You can also save the iPod backup there incase there is a problem with the computer.
    Using the information in my first reply you can backup to you computer and transfer iTunes purchases to your computer as wll as to hers. You do not need iCloud.
    If you have non-iTunes music on the iPod you will need a third-party program to transfer/copy them to a computer. Some are discussed here:
    newer copy

  • Problem in adding "TableLayoutPanel" control array type functionality on windows form dynamically using drag and drop

    Environment: -
     (Application Machine)
    OS Name             : -
    Microsoft Windows 7 Professional/XP SP2/SP3            
    OS Bit Version      : -
    32 Bit                     
    Application Name: - Designer.exe                                  
    IDE                  
        : - Visual Studio 2008                        
    EXE Application development: -
    VB. Net
    Application Type: -
    Application “Designer.exe” was designed in vb6.0 and now, it has been upgraded to Visual Studio 2008 and it works properly.
    Product Description: -
                 We have an application Designer.exe, which is used for designing “Forms”.
    It has menu option with following option like Panel, Text Box, Combo Box, Button etc. We drag any of this menu items and place it to form.
    Requirement: -
    We have
    critical requirement in product. In Designer.exe, we need to align form margin, while we increase or decrease window. And for that we have searched that 
     “TableLayoutPanel” components can be helpful.
    Problem description: -
    Earlier code was in vb6.0, now it has upgraded to Visual Studio 2008. In vb6.0, we have used control array for memory utilization with Combo Box, Group Box, and Text
    Box etc.
    But, for alignment we have to use “TableLayoutPanel”
    control array type functionality on form.
    Code Snippet: - For earlier designing component e.g. Frame
    'Required by the Windows Form Designer
    Public WithEvents Frame1 As Microsoft.VisualBasic.Compatibility.VB6.GroupBoxArray
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.components = New System.ComponentModel.Container
    Me.Frame1 = New Microsoft.VisualBasic.Compatibility.VB6.GroupBoxArray(Me.components)
    CType(Me.Frame1, System.ComponentModel.ISupportInitialize).BeginInit()
    . Kindly suggest approach for implementing requirement.
    Kindly help us to complete the requirement. I will be really
    thankful for any assistance.

    Hi S.P Singh,
    Welcome to MSDN.
    I am afraid that as Renee Culver said, these forums donot support VB6, you could refer to this thread:
    Where to post your VB 6 questions
    You could consider posting this issue in these forums below:
    These forums do not support Visual Basic 6, however there are many third-party support sites that do. If you have a VB6-related question please visit these popular forums:
    VB Forums
    VB City
    Thanks for your understanding.
    Best Regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I downloaded the web developer tool bar and after using it my images are gone. I use google and a home page and the big google is gone. I uninstalled firefox and reinstalled it but I still don't have any images. How can I get them back?

    Two days ago I downloaded the web developer tool bar (aus2.mozilla.com). I tried to use it but gave up. I deleted the tool bar.
    I don't have any images anymore. I use Google.com as my home page (default) and the large GOOGLE isn't there anymore. I've also noticed some of the sites I use don't have the continue or next or enter keys anymore. It seems the only thing I have now is the text.

    Are you sure you are looking at the Google page?? In Firefox 4.0 the default homepage / Start Page in Firefox was changed to '''about:home''' which looks a lot like the former www.google.com/firefox homepage.

  • How to use offline map for windows store app using c# and xaml

    Hi friends,
    I want to integrate offline map in my windows store app but I am not able to achieve that.
    Below is my requirement:
    When a user wants to go somewhere where she/he doesn't want to use wi-fi or mobile data but wants to use map to assist her/him to roam around. For this I want to give an option to download the map for that region/area before leaving for that place and there
    she/he can use map even in offline.
    Is it possible that I can achieve this using Bing maps?
    If yes then tell me the processes to follow.
    If no then can I achieve this using "Here" or by using any other API or by tweaking any way?
    Note: I am showing maps in case of online and user can search for directions or any places in that. I am using Bing maps for that.
    Thanks,
    S.Sandeep

    Hi Sandeepmsandy,
    There is no available code sample for this scenario. You may write your own.
    Step 1: Get pdf URL from sqlite database. Please refer to the following MSDN blog and see a code sample.
    http://blogs.msdn.com/b/robertgreen/archive/2012/11/13/using-sqlite-in-windows-store-apps.aspx. Note, you need to retarget the project to 8.1 and then get two sqlite packages from NuGet before building this sample.
    Step 2: Use some special classes to get file from serer.
    HttpWebRequest can help download small pdf files. For more information to see
    https://social.msdn.microsoft.com/Forums/windowsapps/en-US/de96a61c-e089-4595-8349-612be5d23ee6/download-file-with-httpwebrequest?forum=winappswithcsharp. It’s easy for use, but if you want to download the larger or many files, it’s recommend to use
    BackgroundTransfer namespace. The classes in this namespace provide a power way to transfer files in the background. See a code sample from MSND.
    https://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

  • Album keeps saving images from emails, such as corporate logos and empty images

    For some odd reason my Sony Xperia Z2 adds images to my Album which I have not taken nor asked to save myself. These include images attached to emails - typcially corporate logos, but also seems to add blank images (which show as a logo of what looks like a mountain image used on cameras to show "landscape"). I therefore regularly have to go in and delete all these extra images which load up quite quickly....somewhat annoying.
    Is there a setting I have missed somewhere?

    I am facing same issue in my Xperia Z . All my fb stickers and walkman album art just shows up after somedays.. and then i have to individualy delete around 700-800 photos  creates too much trouble.
    Did clearing cache helped? 
    What to do about it?

  • Acquiring images from an Analog Camera using Arduino and LabVIEW

    Hi All,
    I posted this on the LabVIEW Arduino community but I am not sure it went through.
    Check out this project I have been working on for the last two weeks.
    It allows you to capture lowres/low bit depth images with arduino with LabVIEW (needs NI vision).
    Here is the link
    Feel free to use the code (it is all downloadable).

    Hello cagell
    I just wanted to exprees my thanks for sharing your awesome project with our community.  I am a huge analog video enthusiast myself.  All the best!
    Sincerely,
    Greg S.

  • How can i get windows 7 to use plug and play features

    I am trying to load a game using windows 7 and no matter what I do I cannot get the game to install or load up!

    Try to right click on the game install and tell it to run as administrator.
    Reminder: Please select the "Accept as Solution" button on the post that best answers your question. Also, you may click on the white star in the "Kudos" button for any helpful post to give that person a quick thanks. These feedback tools help keep our community active, so you receive better answers faster.

  • Export Grid to PDF file In windows Store app using Xaml and C#

    I am working on windows store and have multiple data field  which I have to export to PDF  file 
    In wpf  project i easily export gridview data to pdf file but need help to do same thing in windows metro app.
    Thanks in Advance

    There is no in-box PDF writing API. You will need to find a third party component. If you search the forum there are several threads (as recent as yesterday) with discussing this with component suggestions.

  • Saving image in ms sql database.

    Hi all, i have a problem saving image in the database.i used
    request.getParameter("imagename"), to get the content of the textfield in the html file but the problem is that it omits the filepath and gives me just the image name and that gives me an error.. Pls help me

    Your actual problem is less or more web browser related. The right way is that the browser should only send the filename, but a certain widely used browser developed by a team in Redmond would send the full file path as it is at the client side, which is completely wrong.
    The bigger picture what you're trying to achieve, uploading a file from the client to the server, shouldn't be done that way, simply because this isn't going to work at all if the client runs at a completely different machine on the other side of the network than where the server runs. You need to send the actual file contents to the server. Just set the form's enctype to multipart/form-data and parse the body of the request to get the actual file contents. To ease the work I recommend you to use Apache Commons FileUpload API for parsing the multipart/form-data request. Go to their homepage and check out the 'User guide' and 'Frequently Asked Questions' how to use it and for some tricks.

  • Saving image without bits loss/change

    hi there,
    I was trying to save an Image (which i created myself with MemoryImageSource, and proper bit manipulation where red bits hold some characters, very important)and then i saved the image to jpeg by by using BufferedImage and com.sun.image.codec pacakage...its very important that when i read back the saved image, the bits the pixels array are the same as they had been created....but i found them changing...though image looks almost similar....can anybody out there help me how can i recover the same bits in Image pixel array or save it properly using some other technique, so that when i read the image the bits are not changed???
    helps would be appreciated a lot..and your name would appear in my software's about dialog..that's a deal..plz help...
    kushal

    What codec were you using.
    You want one that has "lossless" compression.
    i.e. GIF, TIFF, TGA, BMP, etc.
    JPEG has "lossy compression" although as someone mentioned you may be able to call a method to force it to be lossless.

Maybe you are looking for

  • Can't open pdf files-get error message

    I'm trying to open pdf files from a CD, but when I do I get this message in Adobe Reader: "Adobe Reader could not open part1.pdf because it is either not a supported file type or because the file has become corrupted." I've tried other copies of the

  • IMAP - see deleted mail yes/no - auto expunge?

    Have a strange situation on IMAP. My phone. 1. If I delete on my iPhone: a) The message is copied to a Deleted folder b) The message is deleted from the Inbox c) An expunge is sent immediately and the message has totally left my Inbox 2. If I mark as

  • Omitting the negative sign in SAP scripts

    Hi All, I have a requirement to print the quantity without the negative sign. I have used (S) , &symbol(S)& to compress the sign but that seems to be not working.

  • Airport Express not showing up on airport utility

    I've connected Aiport Express for the forst time via an internet cable to my wireless router, and Have got the flashing amber light. Have I missed something, does anyone know/ Thanks Chris

  • Assessment & Distribution

    Hi,          What is the meaning and difference between Assessment & Distribution. Its Urgent. Thanks in Advance Yours S.VINAYA KUMAR