Blogger news

Blogger templates

Thursday, February 17, 2011

Displaying Images in Windows 7 Phone

The three most popular bitmap(image) formats are:

JPEG (Joint Photography Experts Group)

PNG (Portable Network Graphics)

GIF (Graphics Interchange File)

Silverlight supports only JPEG and PNG

The compression algorithms implemented by PNG and GIF do not result in the loss of any data. The original bitmap can be reconstituted exactly. For that reason, these are often referred to as “lossless” compression algorithms.

JPEG implements a “lossy” algorithm by discarding visual information that is less perceptible by human observers. This type of compression works well for real-world images such as photographs, but is less suitable for bitmaps that derive from text or vector-based images, such as architectural drawings or cartoons.

Now let’s start example to add image to the content panel of Windows mobile.

a. Open Visual Studio for Windows Mobile as below image. Please click image to expand,

Right click on the project and add new folder to store image as show image below. Click to expand,

name the folders "Images"

Right click on newly created folder and click add existing item to get image from local system. Please click image below,

Add image from your local system. Keep in mind that silverlight supports JPEG and PNG files only.

The final step: Right-click the bitmap(Image) filename and display Properties. Note that the Build Action is Resource.

In Silverlight, we can use Image element to display bitmaps just as you use the TextBlock

element to display text. Set the Source property of Image to the folder and filename of the
bitmap within the project:

Go to your XAML code and add an image element inside Grid with name content panel.

Please click image below to see Image element to add image,

Everything is fine now so run the application. Phone emulator will load and your image will display in Phone as image below,

So this all about very simple basics of image element in Silverlight for windows 7 phone.

No comments:

Post a Comment