|
this can help you
Image img=new Bitmap("filepath.jpg");
Bitmap bmp=null;
for(int i=0;i<img.Width;i++)
{
for(int j=0;j<img.Height;j++)
{
Color col=img.GetPixel(i,j);
int avg=((col.R+col.G+col.B)/3);
img.SetPixel(i,j,Color.FromArgb(avg,avg,avg));
}
}
MemoryStream mem=new MemoryStream();
img.Save(mem,ImageFormat.Gif);
bmp=new Bitmap(mem);
this.pictureBox1.Image=bmp;
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Very nice, but that still doesn't make a 256 colour jpg (from what I can tell, it'd make a greyscale gif), which isn't what the OP wanted
|
|
|
|
|
i know i only mentioned, that can help
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
|
I have a simple C#-(Windows-)Application. The Main-Form has two COM-Members. Working with this variables is ok, everything works as expected. When i close the application by the menu, i call Close() in the event-handler and everything is ok, but when i close by systemmenu or alt-f4 i got a com-leak. What is the reason, what is missing ?
|
|
|
|
|
Hi,
sorry for asking you, but what is a COM-leak? How does you know it is one? (Exception, error etc.?)
Regards
Sebastian
|
|
|
|
|
At the end of the programm, INSIDE the COM-Component it is checked wether all references are "freed", this means if the refcounts are down to zero. The component is not only one single object, instead the library contains an object-hierarchy.
|
|
|
|
|
It is possible to "hook" into the event if Alt-F4 is called. Do you got a Forms-application? If yes you can register an event handler for FormClosing. Within this handler you can call the close-method for your COM.
|
|
|
|
|
If have tried Form_Closed and/or Form_Closing event to call Marshal.ReleaseCOMObject(). But it doesn't help,
|
|
|
|
|
Hmmmm... Other way could be to go into the Dispose()-method of the form and to call the release-method there.
|
|
|
|
|
Thanks for the tip.
In the ...Designer.cs i modified Dispose
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
if (m_Session != null)
{
while (true)
{
if (Marshal.ReleaseComObject(m_Session) <= 0)
{
m_Session = null;
break;
}
}
}
if (m_System != null)
{
while (true)
{
if (Marshal.ReleaseComObject(m_System) <= 0)
{
m_System = null;
break;
}
}
}
}
base.Dispose(disposing);
}
but it doesnt't help, because the code isn't called at all, have i misunderstood you ?
|
|
|
|
|
No, you didn't misunderstood me
Hmm... now i'm just at a loss. Normally, if you press Alt-F4 the FormClosing-event should be called. At least Dispose...
|
|
|
|
|
Hi,
I have customized my openfiledilaog. & i would like to replace it with windows OS standard openfiledialog.
|
|
|
|
|
Namaste (or Vannacum) Satish,
I think you can get helpful responses to this question if you first describe what you are doing in more detail.
Since using the standard .NET WinForms OpenFileDialog is so well documented, and easy to do, what's stopping you at this point from using the same way you use a Button or anything else on the ToolBox.
Is the problem that you have some custom features in your customized OpenFileDialog that you don't know how to "move over" when you change to the standard OpenFileDialog ?
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Namaste Bill Ji,
My problem is, i have customized open file dialag by adding some picture box & it works fine in my application.Now i would like to implement it in my Operating System. that is
if i open notepad Or Mspaint when i click on File->open menu then it should show my open file dialog .
Thanks
|
|
|
|
|
Namaste Satish Ji,
Here I am afraid I cannot help you : extending a .NET modified OpenFileDialog control so it replaces the default operating system OpenFileDialog which is integrated at so many levels deep into the OS, is outside my technical abilities.
Which doesn't mean it can't be done. But I think you'll need a "guru" who really knows a lot about COM and the internals of the OS to know if it's possible.
I do think the only helpful thing I can say is that you might re-frame your question like this :
"How can I take my .NET created/modified OpenFileDialog control, and EXTEND the OS so when I context click on a file or folder I now have an optional menu item that launches my custom OpenFileDialog ?"
Since many applications I use every day add something custom to the default OS context-menu, I would start by looking at how they do that, and how, when the menu item is invoked, it is passed, somehow, a reference to what it was invoked (i.e., what was "selected," for example.
I would start by searching CodeProject on terms like "Extending," and try and then narrow the search terms down from there; I'd also check out StackOverFlow.com and search there, and, of course, Google on "windows adding a custom menu item" and things like that.
good luck, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Hello Im new to C# and I am trying to search an algorithm using a Sequential Search but I keep receiving the following error:
The name 'SequentialSearch' does not exist in the current context.
Can someone please tell me what exactly this error message means. Thank you
|
|
|
|
|
The error means exactly what it's telling you; the name you're trying to use doesn't exist. Are you sure you're calling the correct function on the correct object?
|
|
|
|
|
|
lol
ok well it would help if i could spell ....
Direct Link[^]
Next time just try google, if your comming from a C/C+ background always throw "equivalent" in the search terms
|
|
|
|
|
|
How can I know the coordinates of the image within the picturebox when clicked?
Subject to:
1. The picturebox mode is Zoom
2. The picturebox can have any size (but the image inside is uniformely scaled because of Zoom mode)
I would appreciate ideas for solving this,
Thanks
|
|
|
|
|
|
Did you find an answer to this? If so, can you please share? I need to do exactly the same.
Thanks.
|
|
|
|
|
Whats wrong with the one I posted?
|
|
|
|