Revision as of 05:10, 29 June 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to capture screen programmatically in Windows Phone 7 (ِArabic)

From Nokia Developer Wiki
Jump to: navigation, search

وهذا المقال يوضح كيفية التقاط الشاشة من داخل ويندوز فون 7 التطبيق..

WP Metro Icon Multimedia.png
SignpostIcon XAML 40.png
SignpostIcon WP7 70px.png
Article Metadata
Code ExampleTested with
SDK: Windows Phone 7.1 SDK
Devices(s): Emulator
Platform(s): Windows Phone 7.5
Windows Phone 7.5
By bintk
Last edited: hamishwillee (29 Jun 2013)


لا يبدو أن هناك أي طريقة على ويندوز فون 7 لبرمجه تطبيق تصوير الشاشة لالتقاط واجهة المستخدم من تطبيق آخر. ومع ذلك فمن الممكن تصوير الشاشة من التطبيق الخاص - وهذا ما تغطية هذه المقالة.



سوف نستخدم WriteableBitmap لألتقاط الشاشة . Its Render method takes two parameters, UIElement and Transform. We specify the LayoutRoot (the root element for the UI defined in XAML) as the UIElement which renders the whole UI into the bitmap. The second parameter is the MatrixTransform which is applied to elements before they are drawn into the bitmap - we specify an empty transform in this case so that elements are drawn as they would be to the device screen.

Here is the code snippet:

private void ApplicationBarIconButton_Click(object sender, EventArgs e)
var fileName = String.Format("WmDev_{0:}.jpg", DateTime.Now.Ticks);
WriteableBitmap bmpCurrentScreenImage = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);
bmpCurrentScreenImage.Render(LayoutRoot, new MatrixTransform());
SaveToMediaLibrary(bmpCurrentScreenImage, fileName, 100);
MessageBox.Show("Captured image " + fileName + " Saved Sucessfully", "WmDev Capture Screen", MessageBoxButton.OK);
currentFileName = fileName;
public void SaveToMediaLibrary(WriteableBitmap bitmap, string name, int quality)
using (var stream = new MemoryStream())
// Save the picture to the Windows Phone media library.
bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, quality);
stream.Seek(0, SeekOrigin.Begin);
new MediaLibrary().SavePicture(name, stream);

After rendering all the UIElements on the WriteableBitmap, we call the Invalidate() method to force it to redraw its contents and display properly.Then the capture image is saved in media library using the SaveToMediaLibrary() method which takes three parameters WriteableBitmapObject, filename, quality of JPEG photo.

This page was last modified on 29 June 2013, at 05:10.
129 page views in the last 30 days.