Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User csu_nj's Avatar
    Join Date
    Jul 2008
    Posts
    142
    how to capture screen on windows phone, what api will be used?

  2. #2
    Nokia Developer Champion james1980's Avatar
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    916
    Hi,

    Check this page may be it is useful for you .

    http://stackoverflow.com/questions/5...om-application
    Last edited by james1980; 2011-12-15 at 10:26.
    Jajal Mehul

  3. #3
    Registered User hungnm.hq's Avatar
    Join Date
    Oct 2011
    Posts
    5
    Code:
    public static void SaveToMediaLibrary(
        FrameworkElement element, 
        string title)
    {
        try
        {
            var bmp = new WriteableBitmap(element, null);
    
            var ms = new MemoryStream();
            bmp.SaveJpeg(
                ms,
                (int)element.ActualWidth,
                (int)element.ActualHeight,
                0,
                100);
            ms.Seek(0, SeekOrigin.Begin);
    
            var lib = new MediaLibrary();
            var filePath = string.Format(title + ".jpg");
            lib.SavePicture(filePath, ms);
    
            MessageBox.Show(
                "Saved in your media library!",
                "Done",
                MessageBoxButton.OK);
        }
        catch
        {
            MessageBox.Show(
                "There was an error. Please disconnect your phone from the computer before saving.",
                "Cannot save",
                MessageBoxButton.OK);
        }
    }
    This method can save any FrameworkElement. Typically I use it to save a whole page, but you can pass any other element to it.

    On line 7, we create a new WriteableBitmap. This excellent class can render a visual tree into a bitmap. Note that for even more features, you can use the great WriteableBitmapEx class library (which is open source).

    On lines 9 to 16, we save the WriteableBitmap to a MemoryStream. The only format supported by default is JPEG, however it is possible to convert to other formats with the ImageTools library (also open source).

    Lines 18 to 20 save the picture to the Windows Phone device’s media library.

  4. #4
    Registered User csu_nj's Avatar
    Join Date
    Jul 2008
    Posts
    142
    thanks. but the code don't work on the emulator

  5. #5
    oh man, it didnt worked for me too.... lemme try it again..

  6. #6
    Registered User jsriram's Avatar
    Join Date
    Jan 2012
    Posts
    1
    Any fix to the given method or other solution for taking screenshot on the device. Thank you

  7. #7
    Registered User dheeraj_pk@hotmail.com's Avatar
    Join Date
    Jan 2012
    Location
    Kochin
    Posts
    10
    Hi,
    You can use WritableBitmap Class to capture the screen..
    pls refer this link...
    http://www.jeff.wilcox.name/2011/10/...n-your-device/

    Thanks
    Dheeraj

  8. #8
    Registered User eortega11's Avatar
    Join Date
    Feb 2012
    Location
    Winchester, UK
    Posts
    4
    Erm,... I supossing that you want to capture the screen from the codebehind, don't you? Because if the topic is:
    "how to capture screen on windows phone" you can use the additional tools of the Emulator

    If not , WrittableBitMap is the solution yes.

    Cheers,
    Eduardo Ortega

Similar Threads

  1. Replies: 10
    Last Post: 2011-07-08, 18:14
  2. Replies: 1
    Last Post: 2008-12-14, 17:10
  3. Capture a "secret" code - Idle screen/Phone app
    By heuven in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-02-21, 10:14
  4. Replies: 6
    Last Post: 2007-12-17, 07:06
  5. Replies: 1
    Last Post: 2002-07-16, 06:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved