How to retain high resolution of a dynamically created image using ASP.NET and C#
March 27, 2009 by MK
Filed under C# / ASP.NET, web development
Today we will discuss about maintaining high resolution of dynamically created image using ASP.NET and C#. If you want to learn how to create an image - You can view this related article for creating an image dynamically using ASP.NET and C# (This article teaches about creating pie chart but can easily be altered to create any image).
This is a two step process -
First step is to define properties while declaring the Graphics class to be used for creating the image. Following properties can be used for attaining that -
objGraphics.SmoothingMode=System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
objGraphics.InterpolationMode=System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
objGraphics.CompositingQuality=System.Drawing.Drawing2D.CompositingQuality.HighQuality;
objGraphics.TextRenderingHint=System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
You can follow this link for more information on Graphics class and the properties used above - http://msdn.microsoft.com/en-us/library/system.drawing.graphics(VS.80).aspx
Second step is saving the image. For creating a high quality image we need to play around with the ImageCodecInfo class that we have created. Here we will loop through the MimeType property of encoders array and will select the matching MimeType.
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
Now we will define the response stream and the type of image we want to create.
using (System.Drawing.Image img = LoadImage()) //LoadImage() will return the image that we have created in the steps above.
{
ImageCodecInfo myImageCodecInfo;
Encoder myEncoder;
EncoderParameter myEncoderParameter;
EncoderParameters myEncoderParameters;
myImageCodecInfo = GetEncoderInfo(”image/jpeg”);
myEncoder = Encoder.Quality;
myEncoderParameters = new EncoderParameters(1);
myEncoderParameter = new EncoderParameter(myEncoder, 100L); //You can use 100L to increase or decrease the quality of the image.
myEncoderParameters.Param[0] = myEncoderParameter;
Response.ContentType = “image/gif”;
img.Save(Response.OutputStream, myImageCodecInfo, myEncoderParameters);
}
As you see its quite easy to create high quality images using the Graphics class in ASP.NET. Almost everything done by using third party components can be created using built in classes with ASP.NET. Happy Coding!!.
What is Bounce Rate? Seven easy steps to decrease the Bounce Rate of your Wordpress blog or website.
March 27, 2009 by MK
Filed under Blogging, Online Marketing, Wordpress, web development
In order to run a successful website you should know your site metrics. One key metric you should be aware of is Bounce Rate.
What is Bounce Rate?
Bounce rate is the percentage of single page visits or visits in which the person left your site from the entrance (landing) page. This entrance can be from any page on your site. Use this metric to measure visit quality - a high bounce rate generally indicates that site entrance pages are not relevant to your visitors.
If you haven’t been tracking your users, you should start now. Google Analytics is free and awesome. Google Analytics - You can sign up here
To view the bounce rates for your website using Google Analytics. Sign in and go to the Bounce Rate report under Visitors > Visitor Trending > Bounce Rate.
Why monitoring Bounce Rate Metrics is important?
Lets assume you own a physical electronics store.To run your store successfully you will require a lot of foot traffic and once your customers arrive you want them to make transactions. Or at least surf the store, you never know as they can find something interesting and useful while surfing that they would like to buy.
Same rule applies to the online world and this process of getting more traffic and converting them to sales is called conversion. You invite customers to your website by investing both time and money on good content, email and affiliate marketing, paid search etc. And once your online users hit your website you would like to capitalize on that investment.
Now this is where Bounce Rate Metric comes in handy. By measuring the bounce rate you can measure the effectiveness of your promotional marketing efforts. As you follow this metric at the landing page or the traffic source levels you can establish a baseline to track your success overtime.
We all spend a lot of money on conversions and this metrics can tell us where we are we acquiring quality traffic from and how successful we are on converting that traffic to sales or at the least have users stay on the site.
Bounce Rate metrics can be affected by a number of different variables. On an average bounce rate for your site should fall between 40 - 70%. You can not convince all the site traffic to stay but if your Bounce Rate is more then 70% you are doing something wrong.
Bounce rate is a great qualifying metric. Its a metric that helps you ask the right questions. Check the top web pages of your website from where people are entering the site and check there bounce rate. Remember as these pages are from where most of your online users are entering your site, you can determine by studying these pages if these pages are doing a good job.
How to bring down or decrease the bounce rate of your WordPress blog or website?
There are a number of measures that we can take to grab attention and compel users to stay on the site and thus decrease the bounce rate. I call them triggers or call to actions. Following are some of the steps that I follow rigorously and have been successful in decreasing the Bounce Rate for coolwebdeveloper.com over a period of time -
- Interesting Headline - Keep the title of your post interesting and should ignite quest to read the full post.
- Interactive Posts - Make your posts interactive by encouraging users to click on other useful links within your site. For example if you are writing a post on HP laptop, you can refer to previous posts you have written about HP laptop in this new article thus providing more options to your users.
- Best or Related Posts - Make sure your users can reach the Best or Related Posts from every page of your site.
Wordpress Plugin you can use - Yet Another Related Posts Plugin - BLOG’s design and SEO - Reconsider your blog’s navigation and overall theme design that could generate usability issues.
Thesis WordPress Theme
has the following functions automatically built in, so you do not need to use these plugins if you are using this theme. Just as an FYI - This theme is already getting some great reviews around the blogosphere (you can see some testimonials here). You can download Thesis Wordpress Theme here.
But if you are using other themes, the following plugins will give you a similar look/effect.
- All in One SEO Pack - This plugin makes it easy for you to optimize your article titles and other meta tags.
- Google Analytics - This plugin makes it easy for you to insert your Google Analytics code and start tracking your blog visitors.
- WP-Note - This plugin lets you insert notes in your article to make them stand out. Kind of similar to the yellow colored notes I have twice in this article.
- Wordpress Gravatars - This plugin lets you display Gravatars of your readers in the comments section and can put your Gravatar on top of your article to show who the article was written by.
- Error page - Make sure to use a 404 landing page on your blog or website. Users will hit this page if any link on your site is broken or not found. Using this page you can suggest your users about possible areas of site that can visit and might be interested in.
- Navigation - Easy to spot link to the Home Page. Use breadcrumbs feature for easier navigation. Categories and Posts should be easily visible on the site.
WordPress Plugin you can use - Breadcrumb Navigation - Not using relevant tags - One of the reasons why a lot of blogger’s and website owners have a high bounce rate is NOT using relevant tags while writing posts. Tag relevancy is very important. Users coming through Google or other sources are expecting to get the result based on there search keywqords. If you tags are not relevant, your bounce rate will definitely be higher.
- Incentive Offers - If you have something to give away like Free themes, free e-books, free reports etc then you will always be able attract visitors to click on that link.
- Interactive Elements - Use interactive elements that would require users to take small actions, such as polls.
By following these check points consistently you will be able to reduce the Bounce Rate of your site.
Do you have a high or a low bounce rate? How has the bounce rate affected your blog? What methods did you find most efficient to reduce the bounce rate? If you have suggestions or want to discuss more about Bounce Rate please leave your comments.
Web Platform Installer (Click once install) Beta 2.0 released for Windows 7, Vista SP1, and XP SP3
March 25, 2009 by MK
Filed under Online Media, Software Development, Tech News, web development
The Microsoft Web Platform Installer has evolved this week from version 1.0 to 2.0. In fact, as MIX09 debuted, the Redmond company made available for download the Beta development milestone of Web Platform Installer 2.0.
Web Platform installer 2.0 beta allows users to install popular open source ASP.NET and PHP web apps with the Web PI. This feature was not there in Web platform installer 1.0.
Web Platform Installer 2.0 Beta is only supported on Windows Vista RTM and SP1, Windows XP SP2 and SP3, Windows Server 2003 and Windows Server 2008. However, the bits also manage to integrate with the next iteration of the Windows operating system, Windows 7. With version 2.0 the software giant aims to take the already simplified download and install process of its collection of web solutions a step further.
“It includes everything that you need to get up and running to build your web solutions – from servers, tools, and technologies, including the most recently updated products. This means you don’t have to go to a different website and download to set up your dev machines or servers! With the WebPI, you can install the entire stack all from one website – www.microsoft.com/web and one installer. Additionally, the WebPI installs the community version of PHP 5.2.9-1 so you have easy integration with popular web applications. All you need is a Windows machine or hosted version of Windows,” revealed Mark Brown, Microsoft senior product manager.
What is Web Platform Installer? or as I call it - Click Once Install for Microsoft Web Solutions.
The WebPI provides a simplified download/install experience for Microsoft’s free web products. It includes everything that you need to get up and running to build your web solutions – from servers, tools, and technologies, including the most recently updated products. This means you don’t have to go to a different website and download to set up your dev machines or servers! With the WebPI, you can install the entire stack all from one website – www.microsoft.com/web and one installer. Additionally, the WebPI installs the community version of PHP 5.2.9-1 so you have easy integration with popular web applications. All you need is a Windows machine or hosted version of Windows.
What makes the Web Platform Installer 2.0 Beta -
- IIS 5.1, 6.0 or 7.0 depending on your version of Windows
- SQL Server 2008 Express
- .NET Framework 3.5 SP1
- Visual Web Developer 2008 Express Edition
- IIS Extensions including: Media Services 3.0, Admin Pack, DB Manager, WebDav 7.5, FTP 7.5, FastCGI for PHP support, URL Rewriter, Application Routing, Web Deployment Tool
- ASP.NET and features such as ASP.NET MVC
- Silverlight Tools for Visual Studio
- The Community Version of PHP v5.2.9-1
Microsoft Azure now supports PHP and allows full trust development
March 24, 2009 by MK
Filed under Online Media, web development
Microsoft at the Mix09 conference on Wednesday revealed several moves intended to bolster its Windows Azure cloud computing platform, adding support for PHP application development and native code as well as full trust capabilities.
Some important highlights of the announcements at conference -
- Managed code to native code support
- Enablement of full trust, which is how most applications or services are written
- Offering FastCGI support to allow PHP development
"Basically, the Windows Server team has done a ton of work with FastCGI that allows Windows Server to now support programming languages beyond just .Net and Visual Studio," said Prashant Ketkar, director of product marketing for cloud infrastructure services at Microsoft, in an interview at the conference in Las Vegas.. Through the FastCGI interface, developers can take existing PHP skills and PHP applications and services and run them on Azure.
Microsoft’s vision is to open up the platform to more languages, Ketkar said. Microsoft wants Azure to offer a "frictionless" development platform beyond just supporting .Net development, he said.
With full trust capabilities, Microsoft is expanding Azure beyond the medium trust capabilities that it had had since its original launch at the Microsoft Professional Developers Conference in October 2008.
What will FastCGI support do?
FastCGI allows developers to deploy and run web applications written with 3rd party programming languages such as PHP. This provides developers using non-Microsoft languages the ability to take advantage of scalability on Windows Azure.
From Azure’s official website -
One of our goals for MIX was to give our developers more flexibility while ensuring they still benefit from the unique time-saving deployment, monitoring, and management features of Windows Azure. One way in which we went about this was to enable IIS FastCGI module in the Web role. This module enables developers to deploy and run applications written with 3rd party programming languages such as PHP.
Now this is the good news for PHP developers. Probably we can see some fellow blogger’s moving there blog hosting to Windows Azure with there PHP built blogs in WordPress and Drupal (depending on the cost though).
PhoneGap - open source framework for mobile development with JavaScript.
March 24, 2009 by MK
Filed under Javascript, Online Media, Software Development, Tech News, web development
The creators of PhoneGap think it’s nonsense that developers have to write the same app in several different programming languages to reach the widest swath of mobile phone customers, so they developed an open source, cross-platorm framework that bridges the gaps among them.
“PhoneGap is an open source development tool for building fast, easy mobile apps with JavaScript. If you’re a web developer who wants to build mobile applications in HTML and JavaScript while still taking advantage of the core features in the iPhone, Android and Blackberry SDKs, PhoneGap is for you,” reads the Web site.
To get an idea of the types of mobile phone features PhoneGap supports currently (more are on the way), take a look at this quick reference chart the creators put together:
PhoneGap is the Adobe AIR of the IPhone, Blackberry, Android, Symbian and Windows Mobile. Just like Adobe AIR enables web developers to build Windows and OS X applications using the HTML and CSS skills that they know and love, PhoneGap allows web developers to build applications for the mobile devices with web technologies while taking advantage of the native mobile phone API’s.
Using PhoneGap, a developer need not write any Objective-C code and yet they can still have a proper app installed that is essentially a slightly customized PhoneGap application that sports a custom icon and a certain URL where application lives online (very much like AIR). When a user starts PhoneGap it essentially creates a browser on the mobile device and navigates to the specified URL where the author of the web page can access that particulars phone’s API through JavaScript like this:
getLocation();
//GAP will invoke this function once it has the location
function gotLocation(lat,lon){
$(’lat’).innerHTML = “latitude: ” + lat;
$(’lon’).innerHTML = “longitude: ” + lon;
}
Or access the accelerometer data like this:
function updateAccel(){
$('accel').innerHTML = "accel:"+accelX + " "+accelY+" "+accelZ;
setTimeout(updateAccel,100);
}
Seems like RIM needs some applications built on this API. And then all those RIM users might be able to run all the cool iPhone apps on there blackberries.
For a quick introduction to PhoneGap, watch this three-minute video:














