|
OK, some comments:
1.
a general GDI+ image does not have a pallette, each pixel has ARGB values, typically 32-bit in total, and those can take any value. Your image source may be encoded by color index (e.g. 8-bit pallette) but AFAIK that is lost when the image gets loaded into an Image/Bitmap instance.
2.
with two arrays, their size would have to be the size (area) of the input image, that could be rather large. And you would have to implement your own sort algorithm to keep both arrays in sync.
3.
I would consider using a single Dictionary<Color,int> where the key is the pixel color and the value is the multiplicity. So the code to add a pixel would be: if already in dictionary increment value, else insert with value=1. Performing this on a megapixel image will be a slow operation!
BTW: make sure you allocate the dictionary with a well chosen initial capacity, I would pick image area divided by say 4 to avoid dictionary growth which would reallocate and copy all current data.
|
|
|
|
|
Hi Luc,
Reply to 1: Yes, I verified that just after I posted the reply.
Reply to 2: Agree.
Reply to 3: In fact, to use statistics I'd need a SortedDictionary since after I insert the values on this dictionary I need to sort them according to the number of hits. The problem here is that I verified that on SortedDictionary, as opposed to Dictionary, when you call Add method for an specific key, it does not update the value of the key, instead you have to remove the element using Remove and add it again using method. Therefore many search calls are done.
To illustrate:
if (color.ContainsKey(intColor))
{
int value = color[intColor] + 1;
color.Remove(intColor);
color.Add(intColor, value);
}
else
{
color.Add(intColor, 1);
}
Is there any other way to do that?
Regards,
|
|
|
|
|
|
No. You don't need a SortedList, as it does not make sense to get the order updated after every pixel, you only need it sorted when done collecting all info. And you want to sort by value, not by key.
Furthermore:
if (colorHistogram.ContainsKey(intColor)) colorHistogram[intColor]++;
else colorHistogram.Add(intColor, 1);
|
|
|
|
|
Hi all,
Can some one help me ?
where to post the questions related DOM and BHO that is on C#?
i never get answers for those questions.
can some one guide me for the proper place to post ! so that it cold be useful or me and others as well...
thanks
|
|
|
|
|
I'm developing a messenger like yahoo or windows live. I'm almost done and the way I choose is Web Service. One method receives byte array from user, some user info and saves in DB. Another method checks if any message available for that user if yes then return byte array. Its fine but I'm just confuse now that how to transfer a file. What I thought is that write chunk by chunk of file to server with last offset of original file. And when a chunk is read by other-end user the sender will write next part of file. So in that way transfer can be resume. But I'm wondering that is there any other better way to do that ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hey budy am not here to answer ur question. But to ask u something on the Messenger .........
I am also to develop an application similar to urs ..... I have been doing C# applications for 1 and half year ...... but I havent do any applications that include networking ............. So what is the general idea behind that ...... Or can u point me a site or notes which help me to do Messenger in C#.
Thank you.
|
|
|
|
|
I could collect all of features about any hardware but i could not obtain information about manufacture of RAM and MONITOR .
If it's possible help me about collectiong information about Ram and Monitore manufacture
|
|
|
|
|
Add a reference to Microsoft.VisualBasic; there's a ComputerInfo[^] class and a Computer[^] class that holds info on the screen
"Optimism is an occupational hazard of programming; feedback is the treatment."
-- Kent Beck
|
|
|
|
|
i ask this question in c# form body!
NOT VISUAL BASIC
|
|
|
|
|
moein.serpico wrote: i ask this question in c# form body!
NOT VISUAL BASIC
I think he knows that, so no need to shout. What he said was "Add a reference to Microsoft.VisualBasic; there's a ComputerInfo class and a Computer class" These are available to and fully usable in C#, but you have to add the reference to your project or VS can't find them. Why are they in Microsoft.VisualBasic.dll? Ask Mr Gates.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
You can try getting the required information using WMI[^].
Have a look at the Win32_PhysicalMemory[^] and Win32_DesktopMonitor[^] classes. They both contain an attribute for manufacturer name.
Here[^] and here[^] you can find some useful tutorials about using WMI in C#.
I hope this helps.
Regards
Nuri Ismail
|
|
|
|
|
I have made a simple game and for the name and score/top score, number of turns etc. of the players, I have used an xml file of my own.
Would I have any reason to store all that information in the .config file, making my own sections or key value pairs in appSettings.
Or is the .config file is only useful when we are talking configuration?
I have read many articles on codeproject/msdn etc., but still confused.
|
|
|
|
|
If you want to save the user data like High scores you can use xml.But if you want to use any application settings like path or something you are using in some code behind classes you can use configuration file.
For example if you have an upload path in server you can use appSettings.
|
|
|
|
|
humayunlalzad wrote: Would I have any reason to store all that information in the .config file
No. I always roll my own.
|
|
|
|
|
My personal preference for your problem is to use XML files, because I follow the simple rule,
'Use static configuration settings in App.Config file and Runtime settings in a separate file, preferably in XML format for easy reading and writing'.
|
|
|
|
|
Hi all,
i am working with webbrowser control.
is there any way to identify the network usage of IE.
for example:
from the time of IE open and till the end of IE Close,
just i want to calculate the entire network usage or page download and upload size(may be in bytes)
can we do it ondocument_complete event and ....
pls help me, if some one has any idea...
you can suggest some other idea also other than webbrowser
thanks in advance.
modified on Wednesday, September 9, 2009 5:31 AM
|
|
|
|
|
IE does not track these statistics.
You MAY be able to get some of this by using the Performance Counters, but I don't know if your going to be able to track it by application. I think you'll only get it on an Interface-by-Inerface basis. This will also pickup non-IE traffic and may affect the results you want.
AFAIK, the only way to track this would be to use a proxy server and point IE at it.
|
|
|
|
|
hi thank you for your suggestion
i am already using api hooking for this but my browser get hangs some time
so that i am trying to get it done in web browser itself and thank you for your suggestion if you come across any idea on that please let me know it
thank you
|
|
|
|
|
1) try to monitor the '80' port;
2) try to find the 'HttpAlicationRequest' object refer and so on, to get the stream.
3) if you want to get the 'web page' size, you can get the html text object to get it.
you can go to msdn to know more about webbrowser control.
modified 27-May-14 5:34am.
|
|
|
|
|
Hi all,
I am trying to crop an image based on a transparent panel that I have placed on the image. The transparent panel is placed on the image control based on certain coordinates (selected by a user based on mouse events). This works fine.
Now I want to try and crop the piece where the transparent panel is located on the image, but I keep receiving an exception: OutOfMemoryException => rect is outside of the source bitmap bounds.
But why is this happening? (note: The image Bounds value of X and Y is 0 and the transparent panel width and height is in bounds with the height and width of the image) The transparent panel is located within the picturebox, shouldn't it be able to get the correct position ??
Here is the code ...
...
TransparentPanel tmpPnl = e.ClickedItem.Tag as TransparentPanel;
Rectangle rec = tmpPnl.Bounds;
Bitmap bmpImage = new Bitmap(base.Image);
Bitmap bmpCrop = bmpImage.Clone(rec, bmpImage.PixelFormat);
...
FYI
That "out of memory" exception appears when you attempt to crop a piece of the image outside itself.
Eg: If the image is 800×600 and you go:
Bitmap b = CropBitmap(myPic, 700, 500, 200, 200);
That’ll try select from 700×500 to 900×700, which does not actually exist.
Many thanks in advance
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
modified on Wednesday, September 9, 2009 6:01 AM
|
|
|
|
|
Ok, so the new method doesn't cause an exception.
But the new cropped image's position is a bit out. It crops more to the right. What am I doing wrong?
public static Bitmap CropBitmap(Bitmap srcBitmap, int cropX, int cropY, int cropWidth, int cropHeight)
{
Bitmap bmp = new Bitmap(cropWidth, cropHeight);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(srcBitmap, new Rectangle(0, 0, cropWidth, cropHeight), cropX, cropY, cropWidth, cropHeight, GraphicsUnit.Pixel);
g.Dispose();
return bmp;
}
Thanks again.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
there is an error 'bmpImage.Clone(rec, bmpImage.PixelFormat);'.
i think it might be 'bmpImage.size'<'rec.size',
so bmpImage's memory < rec's memory ,and it caused the error .
modified 27-May-14 5:34am.
|
|
|
|
|
Hi, can you get the Clone to work if you hard-code the rectangle to say {0, 0, 50, 50}? Try putting a trace on tmpPnl.Bounds too, so you can see what's being passed to Clone - unless tmpPnl is a member of the pictureBox.Controls collection, it's bounds are likely to be relative to the pictureBox.Parent control. Also, wrap up bmpImage var in a using() block to ensure you don't leak memory.
Perhaps you could post the code that creates tmpPnl if this doesn't help
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Hi,
Thanks for the reply.
Rob Smiley wrote: can you get the Clone to work if you hard-code the rectangle to say {0, 0, 50, 50}?
Yes, it takes the top left-hand corner and computes the correct image result based on the width and the height.
Rob Smiley wrote: unless tmpPnl is a member of the pictureBox.Controls collection, it's bounds are likely to be relative to the pictureBox.Parent control
The transparent panel is part of the control collection of the image, so it should be in bounds. I think
Values of rec1 and rec2 are the same..
TransparentPanel tmpPnl = e.ClickedItem.Tag as TransparentPanel;
Rectangle rec1 = base.Controls[tmpPnl.Name].Bounds;
Rectangle rec2 = tmpPnl.Bounds;
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|