|
So you googled enough! Instead of typing this long long question you should have googled this:
".NET" +"C#" +"system tray" +"pop up"
And Oh noze, even here on CP:
http://www.codeproject.com/miscctrl/balloonhelp.asp
Yes I see that was clearly asking to much of you.
*Sadly shakes head*
|
|
|
|
|
Dear,
I would like to please you if someone can help me with using .m files in C#. I have made some function in Matlab and now I need to use it in C# application. I made .dll file with matlab deploy tool but I have problem when I use it in C#, my programs dosn`t execute, when I run it?
Thanks
|
|
|
|
|
|
anyone know of a way of subtract image from image to get the difference?
|
|
|
|
|
This really depends on what you mean by difference (i.e. subtraction).
You could iterate over the points and subtract the
RGB values from each other to gain your new image.
Leaving open what to do with the edge case when the
difference goes below zero. You also need to remember
that subtraction is not commutative.
What kind of difference do you really mean?
Cheers
Manfred
|
|
|
|
|
http://yfrog.com/j227627210j i have this two images wanting to find either the difference or the similarities of the image and display the output in a pictureBox.
will this work?
or i have to convert image to bytes?
modified on Sunday, November 21, 2010 11:14 PM
|
|
|
|
|
You would need to do this pixel for pixel. Just iterate through all pixels in the image and substract them. Store the substraction result as pixel in a new bitmap of the same size as the two images you want to compare.
|
|
|
|
|
do you have an example? meaning example pixel(0,0) of image 1 minus pixel(0,0) of image 2?
|
|
|
|
|
public static Bitmap Diff(Bitmap src1, Bitmap src2, int x1, int y1, int x2, int y2, int width, int height)
{
Bitmap diffBM = new Bitmap(width, height, PixelFormat.Format24bppRgb);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Color col1 = src1.GetPixel(x1 + x, y1 + y);
Color col2 = src2.GetPixel(x2 + x, y2 + y);
int r = 0, g = 0, b = 0;
r = Math.Abs(col1.R - col2.R);
g = Math.Abs(col1.G - col2.G);
b = Math.Abs(col1.B - col2.B);
int dif = 255 - ((r+g+b) / 3);
Color newcol = Color.FromArgb(dif, dif, dif);
diffBM.SetPixel(x, y, newcol);
}
}
return diffBM;
}
This code should create a greyscale image that shows the difference between two bitmaps. If you need more information, ask google. There's lots of information to be found about this topic.
|
|
|
|
|
|
Sorry this question might seem vague, but I was wondering how to create dynamic installers? Maybe I'm not wording it right so let me explain the situation. We use a monitoring software and with this software you can create clients that have location(s). Each time you create a location within a client, you will see another installer popup on the web interface. Now what you do is you download this agent installer for your location, and it will install the agent on your computer. This agent creates a directory on your filesystem along with installs and runs two services.
So my question is.. how exactly are they doing this? Because when you create the location it automatically creates a link on the webpage for a installer. Now with this certain installer it somehow has embedded your location ID which makes it when that agent installs it already puts you under that location. I noticed that the location is set in the registry so when it is dynamically creating it, it is embedding it to install setting that registry to that location ID.
I've looked using reflector and wasn't able to find it.. it was a pretty large program so I'm still looking. I would love to hear your ideas on making this work similar to that way
|
|
|
|
|
Hi Jacob,
My first guess might be that they are using the Windows Installer API to create MSI databases.
See about it here:
http://msdn.microsoft.com/en-us/library/aa372860(v=VS.85).aspx[^]
See also the database manipulation functions:
[^]
The difficult we do right away...
...the impossible takes slightly longer.
modified on Sunday, November 21, 2010 4:42 PM
|
|
|
|
|
I don't think they are doing that. Reason is because it is not a MSI file, it is a exe file. I did open reflector on the exe file and see where the install can take arguments but I just don't know how it is getting those arguments from that file you download.
I found stuff like this:
set.ReadXml(Assembly.GetEntryAssembly().GetManifestResourceStream(Assembly.GetEntryAssembly().GetName().Name.ToString() + ".Template.xml"), XmlReadMode.ReadSchema);
So it appears to me that someway when you create a client, they are changing the Template.xml embedded resource.
When you go to the webpage and click the link for your agent it is actually pointing to a Deployment.aspx?ID=LOCATIONID page. The number cooresponds with the location ID. Which there are templates that coorespond with that location. So it is changing that template.xml file based upon the location ID and the template is a embedded resource
modified on Sunday, November 21, 2010 6:34 PM
|
|
|
|
|
Using the Microsoft API you have the option to create a MSI or a an exe. Without seeing anything you are talking about it is difficult to even guess, however the code could be embedded in the msi database or the code could be constructed on the fly using CodeDOM with the code embedded within it
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ahh I was thinking since it was talking about a MSI installer it only did MSI. I don't really have any code. I used reflector to look at the code to see what they were doing. I can try to explain this..
Ok there are agents and each agent have a "location" (city, town, etc). Now there are templates assigned to each location. These templates can contain stuff such as the server address, port, location id, tray icon file, etc. So in the control center application you create your locations and pick the template that goes with them. When you create a location and set the template it creates a link on the webpage for that installer (so it automatically creates a custom installer)
So on the web interface where you download the agent EXE file, it is going to a Deployment.aspx page and is passed the LocationID as a query string. You download the EXE file, install it, and now your computer shows up automatically under the correct location.
So after digging around in reflector I noticed that the installer is default for all of them. The only thing that changes is the embedded resource Template.xml. So what I think is happening is the Deployment.aspx page is querying the database for the locationid template information and creating a new Template.xml file. It is then replacing the Template.xml that is already in the agent installer with this new Template.xml. So when you install it, it is setting all the information in the template.
So my question is if I have a EXE that I created, how do I replace the embedded resource with a updated file? This means I would have to open the EXE file and somehow figure out where the embedded resource file is and replace it programmically.
|
|
|
|
|
Get a look to Wix.
It's essentialy an XML file that contains instructions for generating an MSI. So you could create an XML base template, customize it with the data required by the specific installer you need and then build id by using MSBuild.
|
|
|
|
|
Ahhh I'll take a look at that too.
Note: I removed the code since it is not mine. It is code I found using reflector. I feel that I might of violated some license agreement by posting snippets of the code that I found. Although I would love to learn how they were capable of reading the bytes of the executable and replacing only the bytes that related to the Template.xml.... it is not worth being sued over lol
modified on Monday, November 22, 2010 7:08 PM
|
|
|
|
|
Hello i have this grayscale image and i wan to convert the pixel black all to white.
for (int i = 0; i < grayImage.Height; i++)
{
for (int j = 0; j < grayImage.Width; j++)
{
if (grayImage.GetPixel(j, i).A.ToString() == "0" && grayImage.GetPixel(j,
i).B.ToString() == "0" && grayImage.GetPixel(j, i).G.ToString() ==
"0" && grayImage.GetPixel(j, i).R.ToString() == "0")
{
grayImage.SetPixel(j, i, Color.White);
}
}
}
pictureBox5.Image = grayImage;
i use the above code however it dont seems like it is working when i assign the grayscale image to another pictureBox it appear as the original image.
needing help!
modified on Sunday, November 21, 2010 11:00 AM
|
|
|
|
|
Don't put that pixel.A stuff in there as it will only work if all pixels are totally transparent (alpha == coverage ==> zero coverage == everything is transparent)
If you want to check for black only use the components R, G and B and leave A out.
And one more thing: Get rid of this ToString stuff. We're dealing with numbers here, so use those instead of comparing with string literals.
cheers
Manfred
modified on Sunday, November 21, 2010 11:10 AM
|
|
|
|
|
Set a breakpoint on this line to be sure it is executing:
grayImage.SetPixel(j, i, Color.White);
|
|
|
|
|
thank you ManfredRBihy and Richard Andrew x64. it works!
now my image is this http://i51.tinypic.com/9uvvag.jpg
how do i further process it till i only get the grey portion?
|
|
|
|
|
If you used really gray scale images, I mean, with pixel format set to Format8bppIndexed, you might do most of these things just changing and playing with the palette. For example, for changing black pixels to white ones, assuming the black color is in the first position of the palette:
ColorPalette pal = bmp.Palette;
pal.Entries[0] = Color.White;
bmp.Palette = pal;
But it seems that you are using the default Format32bppArgb, so you will have to iterate over the pixels once and again. For the further processing you need, you will just have to discard the pixels which are too light or too dark, iterating over all of them again.
|
|
|
|
|
Hi all,
I got a problem on calling acmStreamOpen() in C#.When I 'm calling acmStreamOpen(), on WAVEFORMATEXsrc and WAVEFORMATEXdest are both with the wFormatTag of WAVE_FORMAT_PCM,it returns 0(Successful).but if I changed any of them (or both )to be WAVE_FORMAT_ALAW, I got a 512 error. Did I miss something on defining the ALAW WAVAFORMATEX?Thanks.
CWavConvertor.WAVEFORMATEX WAVEFORMATEXsrc = new CWavConvertor.WAVEFORMATEX();
WAVEFORMATEXsrc.wFormatTag = CWavConvertor.WAVE_FORMAT_PCM;
WAVEFORMATEXsrc.nChannels = 1;
WAVEFORMATEXsrc.nSamplesPerSec = 22050;
WAVEFORMATEXsrc.wBitsPerSample = 16;
WAVEFORMATEXsrc.nBlockAlign = Convert.ToUInt16(WAVEFORMATEXsrc.nChannels * WAVEFORMATEXsrc.wBitsPerSample / 8);
WAVEFORMATEXsrc.nAvgBytesPerSec = WAVEFORMATEXsrc.nSamplesPerSec * WAVEFORMATEXsrc.nBlockAlign;
CWavConvertor.WAVEFORMATEX WAVEFORMATEXdest = new CWavConvertor.WAVEFORMATEX();
WAVEFORMATEXdest.wFormatTag = CWavConvertor.WAVE_FORMAT_ALAW;
WAVEFORMATEXdest.nChannels = 1;
WAVEFORMATEXdest.nSamplesPerSec = 8000;
WAVEFORMATEXdest.wBitsPerSample = 8;
WAVEFORMATEXdest.nBlockAlign = Convert.ToUInt16(WAVEFORMATEXdest.nChannels * WAVEFORMATEXdest.wBitsPerSample / 8);
WAVEFORMATEXdest.nAvgBytesPerSec = WAVEFORMATEXdest.nSamplesPerSec * WAVEFORMATEXdest.nBlockAlign;
WAVEFORMATEXdest.cbSize = 0;
CWavConvertor.WAVEFILTER wfltr = new CWavConvertor.WAVEFILTER();
IntPtr mystreamptr = IntPtr.Zero;
int a = CWavConvertor.acmStreamOpen(out mystreamptr, IntPtr.Zero, ref WAVEFORMATEXsrc, ref WAVEFORMATEXdest, wfltr, 0, 0, CWavConvertor.ACM_STREAMOPENF_NONREALTIME);
|
|
|
|
|
I am not familiar with any of this, however:
1.
getting 0 (success) on some parameter values is good, it indicates your P/Invoke stuff could be correct (or pretty close).
2.
A little Google action led to pages such as this one[^] which states:
All newly defined WAVE types must contain both a fact chunk and an extended wave format description within the 'fmt' chunk. RIFF WAVE files of type WAVE_FORMAT_PCM need not have the extra chunk nor the extended wave format description.
That might be a strong clue, although I couldn't tell you what it really means.
|
|
|
|
|
Is the codec for WAVE_FORMAT_ALAW installed?
Next, some codecs can be used for playback only, not for recording or conversion. On Windows XP, you could try to do the conversion with Windows Audio Recorder in order to find out if it is possible at all.
You might also have a look at NAudio: http://naudio.codeplex.com/[^]
|
|
|
|