March 13, 2008
Sometimes while working with image, it become necessary to get all the properties of an image. This time, I had to find out all the properties of an Image deployed in a web site.Its interesting- that’s why I wanted to share the small code snippet. For our today’s example - let’s pick this gif from our favorite google.com -
We will find out all the properties from the Image URL.
Something About Bitmap Class of System.Drawing -
It represents the pixel data of the graphics image as GDI+ Bitmap and expose all the attributes related to the Image Graphics. In addition to that, it enables manipulation of the Bitmap and save it as File in different format.
There are many overloaded Constructor in the Bitmap class which enables to create image object in various way at developers convenience.
Using WebRequest and WebResponse class of we can retrieve the Stream of the Image.
string url = "http://www.google.com/intl/en_ALL/images/logo.gif";
WebRequest request = WebRequest.Create(url);
request.Method = "Get";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
And then we can just initialize a Bitmap object with the stream that we have just retrieved from the URL.
Bitmap bitmap = new Bitmap(stream);
We are done.
We can access all the properties exposed by the Bitmap object representing the Image Graphics -
No Comments » |
.Net, C# | Tagged: C#, Image |
Permalink
Posted by adiil
January 11, 2008
In this post, we will see how to pass parameter to a method representing Predicate.
Let’s say, we have a collection of SprintBacklogItems and we want to filter all the SprintBacklogItem with Title start’s with, let say “QA” or “Dev Task” depending on a input parameter. Now from the previous post http://adilakhter.wordpress.com/2008/01/11/using-predicate-actor-of-net20/ we know that , predicate only have 1 parameter of type T.

Then, how to pass a input parameter _HeaderToSearch in Predicate?
1. To do that, we need to a new object called ListMatcher -
public class ListMatcher
{
private string _HeaderToSearch;
public ListMatcher(string headerToSearch)
{
_HeaderToSearch = headerToSearch;
}
public bool Predicate(SprintBacklogItem item)
{
return item.Title.StartsWith(_HeaderToSearch, StringComparison.InvariantCultureIgnoreCase);
}
}
2. Next , I initialized the ListMatcher object and use the HeaderToSearch to filter the items-
ListMatcher matcher = new ListMatcher("QA");
this.FindAll(matcher.Predicate);
Done.:)
1 Comment |
.Net, C# | Tagged: .Net2.0, Actor, C#, List, Predicate |
Permalink
Posted by adiil