Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: Setup Project Pin
Heath Stewart2-Apr-04 10:04
protectorHeath Stewart2-Apr-04 10:04 
GeneralRe: Setup Project Pin
Demian Panello13-Apr-04 4:03
Demian Panello13-Apr-04 4:03 
GeneralDataGrid Pin
DucLinh1-Apr-04 20:12
DucLinh1-Apr-04 20:12 
GeneralRe: DataGrid Pin
benqazou2-Apr-04 5:46
benqazou2-Apr-04 5:46 
Generaldatatype check Pin
Anonymous1-Apr-04 19:01
Anonymous1-Apr-04 19:01 
GeneralRe: datatype check Pin
Andy Wieberneit1-Apr-04 20:19
Andy Wieberneit1-Apr-04 20:19 
GeneralRe: datatype check Pin
Anonymous2-Apr-04 2:21
Anonymous2-Apr-04 2:21 
GeneralOptimization of C# code!! Pin
abc8761-Apr-04 18:15
abc8761-Apr-04 18:15 
i have an image of size 3300 * 2100. I am looping through the pixels and counting the number of colors in image and total number of pixels for each color. This code takes about 9 Minutes to Run on PIV 1.6GHz with 512 MB RAM. I want to significantly reduce this time. I am using Hashtable whose key is color and value is number of pixels of that color. Any suggestion will be highly appreciated. Here is the code.
In this code image is the object of Bmp class which i have made to read and write Bitmap faster using unsafe code.
<br />
ArrayList GetAllObjects(); <br />
{    bool test;<br />
     int count=0;<br />
     ArrayList list=new ArrayList();<br />
     ArrayList final=new ArrayList();<br />
     Hashtable ObjHash=new Hashtable();<br />
<br />
     for(int y=0;y<image.Height;y++)<br />
     {		<br />
	for(int x=0;x<image.Width;x++)<br />
	{<br />
	   test = true;<br />
<br />
	     if( ObjHash.ContainsKey(image.pixel[x,y].GetColor()) )<br />
	     {<br />
		int val= (int)ObjHash[image.pixel[x,y].GetColor()];<br />
		ObjHash[image.pixel[x,y].GetColor()]=++val;<br />
		test=false;<br />
	     }<br />
				<br />
	     if(test)<br />
	     {<br />
		ObjHash.Add(image.pixel[x,y].GetColor(),1);<br />
		list.Add(image.pixel[x,y].GetColor());<br />
		count++;<br />
	     } // ending if (test)<br />
				<br />
	 }// ending inner loop<br />
      } //ending outer loop<br />
			<br />
   for(int i=0;i<list.Count;i++)<br />
   {<br />
	if( (int)ObjHash[(Pixel)list[i]] > 1000)<br />
		final.Add((Pixel)list[i]);<br />
   }<br />
<br />
 return final;<br />
}<br />


Any suggestions??

Thanks!


Muhammad Shoaib Khan
http://geocities.com/lansolution
GeneralRe: Optimization of C# code!! Pin
Tristan Rhodes1-Apr-04 20:02
Tristan Rhodes1-Apr-04 20:02 
GeneralRe: Optimization of C# code!! Pin
Daniel Turini1-Apr-04 20:35
Daniel Turini1-Apr-04 20:35 
GeneralRe: Optimization of C# code!! Pin
Kastellanos Nikos1-Apr-04 23:09
Kastellanos Nikos1-Apr-04 23:09 
GeneralRe: Optimization of C# code!! Pin
Kastellanos Nikos1-Apr-04 23:24
Kastellanos Nikos1-Apr-04 23:24 
GeneralA question of a Game Pin
lajiyo1-Apr-04 15:36
lajiyo1-Apr-04 15:36 
GeneralRe: A question of a Game Pin
Christian Graus1-Apr-04 15:53
protectorChristian Graus1-Apr-04 15:53 
GeneralRe: A question of a Game Pin
CWIZO2-Apr-04 2:42
CWIZO2-Apr-04 2:42 
GeneralRe: A question of a Game Pin
lajiyo2-Apr-04 23:01
lajiyo2-Apr-04 23:01 
GeneraldataSet, combobox Pin
DougW481-Apr-04 14:53
DougW481-Apr-04 14:53 
GeneralRe: dataSet, combobox Pin
Anonymous1-Apr-04 16:47
Anonymous1-Apr-04 16:47 
GeneralC# Whidbey Language Changes Pin
Eric Gunnerson (msft)1-Apr-04 13:57
Eric Gunnerson (msft)1-Apr-04 13:57 
GeneralRe: C# Whidbey Language Changes Pin
CWIZO2-Apr-04 2:46
CWIZO2-Apr-04 2:46 
Generalstruct conversion(VB-&gt;C#) problem Pin
Member 6548331-Apr-04 13:21
Member 6548331-Apr-04 13:21 
GeneralC# . Question on &quot;Microsoft Data Access Application Block&quot; Pin
abidkayani11-Apr-04 12:30
abidkayani11-Apr-04 12:30 
GeneralC# problem .. SQLParameters Pin
abidkayani11-Apr-04 12:25
abidkayani11-Apr-04 12:25 
GeneralRe: C# problem .. SQLParameters Pin
Charlie Williams1-Apr-04 13:25
Charlie Williams1-Apr-04 13:25 
GeneralChild windows opening outside the screen! Pin
Carl Mercier1-Apr-04 12:04
Carl Mercier1-Apr-04 12:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.