A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Converting Graphics to HD Photo (WDP / HDP)Learn how to convert popular graphic files such as JPEG, GIF or PNG to the new HD Photo format from Microsoft. HD Photo debuted in Windows Vista, with the file extension WDP and recently HDP. |
On Sunday, May 27th 2007 at 11:13 PM By Andrew Pociu (View Profile) ![]() ![]() ![]() ![]() (Rated 4 with 5 votes) |
||
|
The new HD Photo file format from Microsoft is available in Windows Vista and included in .NET Framework 3.0. It offers better quality than JPEG at (most of the time) half the file size. The file format has recently had its name changed from Windows Media Photo to HD Photo. Also, aside from WDP which we will be using in this tutorial, a new file extension will be handled by HD Photo: HDP. We are sticking to WDP in this tutorial since the HDP extension was introduced only recently and its thus not recognized by most of the software that handles HD Photos, such as the initial release of Windows Vista. WDP and HDP are one and the same, the only different is in the name of the final extension. For more information on HD Photo, see Bill Crow's HD Photo Blog at MSDN.com. He talks about the purpose of the new HD Photo format: We've very specifically targeted printing with support for CMYK and n-Channel pixel formats. In fact, Windows Media Photo is the preferred image format for XML Paper Specification (XPS), the new printer spool file and portable document format being launched with Windows Vista. Windows Media Photo is also designed to be a great web image format, with support for excellent compression, alpha channels, region decode, progressive decode and high performance compressed domain operations. Of course, any data format for the web requires very broad support from a variety of client and server components. As a brand new format, it will take a little time for this support to develop for Windows Media Photo. However, it's already in development for several important "behind the scenes" web tasks from both Microsoft and our partners. - Bill Crow, Program Manager for Windows Media Photo In order to get this tutorial and the source-code attached to it working, you will need to run Windows Vista or install .NET Framework 3.0 on your Windows XP or Windows Server 2003 machine. This will give you access to two DLLs that are crucial for the application to do its job. ![]() Start by creating a new project in Visual Studio 2005 and adding the following as a reference: PresentationCore and WindowsBase. You'll need a little help in adding these, so here it goes: in the Add Reference window, go to the Browse tab and navigate to C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\ - there you will see PresentationCore.dll which you need to add as a reference. The next DLL you need to add as a reference is in the same path - C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\ - and its name is WindowsBase.dll ![]() Now that you added the PresentationCore.dll and WindowsBase.dll references to your Visual Studio 2005 Windows Project, don't forget the two extra using statements: using System.IO; On the form add a button named btnConvert, an OpenFileDialog openPicture and a SaveFileDialog saveWdp. Now double-click btnConvert and you'll get to its click event. Inside it we will open the proper dialogs: private void btnConvert_Click(object sender, EventArgs e) { // Prompt to open the file if (openPicture.ShowDialog() == DialogResult.OK) { // Prompt to save the file if (saveWdp.ShowDialog() == DialogResult.OK) { // Call the method that does all the work FileToWmp(openPicture.FileName, saveWdp.FileName); } } } Obviously, next comes the FileToWmp() method: public static void FileToWmp(string inFile, string outFile) { // Container for bitmap frames BitmapDecoder bdFile = null; // Read the source file into a FileStream object FileStream readFile = File.OpenRead(inFile); // Set the BitmapDecoder object from the source file bdFile = BitmapDecoder.Create(readFile, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None); // Prepare the output file FileStream writeFile = File.OpenWrite(outFile); // All the magic done by WmpBitmapEncoder WmpBitmapEncoder wbeFile = new WmpBitmapEncoder(); // Set the quality level to... pretty good wbeFile.ImageQualityLevel = 0.9f; // Add the bitmap frame to the encoder object wbeFile.Frames.Add(bdFile.Frames[0]); // Write the output file wbeFile.Save(writeFile); writeFile.Close(); readFile.Close(); } Believe or not, that's all you need to convert pretty much every popular file format - such as JPEG, GIF and PNG - to the brand new HD Photo format. And in most cases it will reduce the file size by over 50% too. |
|||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|||
|
|||
Current CommentsAttached project zip file seems corrupted :(
Try downloading it again. I verified the ZIP and it worked.
this works on windows 7...please tell me??
superb
superb
I follow the instruction but it
every time I convert, it seems to
direct printing option. Can you help me?
thanks
i am a total noob. cannot, for life of me find the .uckin! add ref. window. HELP!
where do the two using states go!"not in words" any visuals? this sucks!? .uck!
lost... this program sucks. what do you have to do get hd!? .uck!
Related Tutorials
Related Source Code
C# Job Search