|
I'm glad it's helpfull for you.
Actually,I haven't used this before.
|
|
|
|
|
well, but is good and is working
thank you a lot.
|
|
|
|
|
You're welcome.
By the way,Have you find out a solution to solved your problem ?(" encrypt with private key and decrypt with public key ")
AS i know,RSA can not seem to do so .
|
|
|
|
|
yes, is not possible.
But I noticed that what I wanted it could be made with the method: signdata
It signs data with private key and unsign with public key =)
|
|
|
|
|
Hello!
I have a problem with getting the pixels from an image. I load a image, select a pixel from the image and retrieve it's color and then i generate a matrix indexMatrix[bitmap_height][bitmap_width] which contains 1 or 0 depending if the [x,y] color of the bitmap is the same as the color selected. The problem is that the program doesn't select all the pixels although it should. Here are some images of the bitmap and the bitmap generated from the matrix :
original:
http://img233.imageshack.us/i/hartap.jpg/
after matrix generation and the transform from the matrix to the new image
http://img826.imageshack.us/i/60079199.jpg
The wierd thing is that if i run my program for the new image ( the one constructed from the matrix ) it returns the same image( as it should ) but i can't figure out how to fix the problem.
Please Help!!!
Regards,
Alex Badescu
and some code from my project :
bitmap declaration:
m_Bitmap = (Bitmap)Bitmap.FromFile(openFileDialog.FileName, false);
Here i calculate the matrix:
int bitmapWidth = m_Bitmap.Width;
int bitmapHeight = m_Bitmap.Height;
indexMatrix = new int[bitmapHeight][];
if (imageIsLoaded && colorIsSelected)
{
for (int i = 0; i < bitmapHeight; i++)
{
indexMatrix[i] = new int[bitmapWidth];
for (int j = 0; j < bitmapWidth; j++)
{
Color temp = m_Bitmap.GetPixel(j, i);
if (temp == selectedColor)
indexMatrix[i][j] = 1;
else indexMatrix[i][j] = 0;
}
}
MessageBox.Show("matrix generated succesfully");
}
matrixIsCalculated = true;
}
|
|
|
|
|
Try using Color.ToArgb() method for the comparisons. ie,
if(temp.ToArgb() == selectedColor.ToArgb())<br /> The equality operator uses some state flags for the comparison in addition to the ARGB values.
|
|
|
|
|
|
I'm afraid there is a fundamental flaw in your approach: JPEG images tend to be highly compressed, which means every pixel is approximated in such a way that fewer bits are required. Applying an equal-test on jpegged images does not make much sense. What you should do is allow for some deviation, say:
deviation=deltaRed*deltaRed+deltaGreen*deltaGreen+deltaBlue*deltaBlue
or similar in another color space (e.g. HSB).
Only when the deviation is large enough you should call the pixel "not blue".
BTW: why don't you use a normal 2D matrix, as in int[bitmapWidth, bitmapHeight]?
|
|
|
|
|
I have custom windows user control. It is just a textbox puted on a panel. And panel is on User control. The panel OnPaint is overriden.
Everything looks fine except when some form comes on the control or menu open on it and I move or close the above form, the user control looks does not refresh completely extra lines from closed form remain on the panel. Should I call Invalidate() or Refresh() from specific event of user control?
Thanks
Mazy
"This chancy chancy chancy world."
|
|
|
|
|
does your Paint handler contain a base.OnPaint() ?
|
|
|
|
|
Hello,
I use a ColorEdit control in my form ( as picture )
I need to analyse the case when the user choose a color from Custom tab which the color is represtend in RGB structure as I know
the problem that i need to translate this value (ie 245;245;220) to the color name (ie "beige") that i can save it after to use an other time by methode Color.FromName(name)
please can someone help me.
thank you
http://yfrog.com/63clipboard01kg[^]
|
|
|
|
|
You can use the FromArgb method and pass it the integer values. That would make converting it obsolete. Not all values can be converted to a name either so converting would mean omitting many possibilities.
V.
|
|
|
|
|
So when its unknown color (ie its choosed in custom tab and not exist in the array of known colors)
how can i get its name?
|
|
|
|
|
That's the thing, you can't. You should save it's RGB values, not the name.
V.
|
|
|
|
|
Think about it. 8 Red bits, 8 Green bits, 8 Blue bits. (and 8 alpha channel, but lets ignore those for a moment)
2^8 * 2^8 * 2^8 = 256 * 256 * 256 = 16,777,216 different colours.
Who do you think is going to name them all? The whole of the English language has less than 1 million words.
If you used each of them for a colour, you would still need French, and German, and Spanish, and Italian, and Manderin, and ...
Use the numbers, Luke!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I do.
|
|
|
|
|
I was going to reply that I didn't remember proposing , but...
...then I read my post and realised what you were talking about.
I'm sure you meant to say:
Luc Pattyn wrote: [AsthmaticVoice] I do. [/AsthmaticVoice]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
You can't, or at least you shouldn't.
All colornames map to a hex value (though not reliably), but not all hex color values map to a color name.
Additionally, different systems have different colornames.
|
|
|
|
|
Yeah, what they said.
If it was an easy task Microsoft would have provided it already.
I store (database, XML, etc.) the value as #AARRGGBB; it works.
|
|
|
|
|
Not sure why you want the # sign there? I can see the advantage of using hex, but then I'd do either 0xAARRGGBB or simply AARRGGBB.
|
|
|
|
|
Because HTML uses it. This keeps that common look and feel. I see that, and know that it's a color that has been serialized.
|
|
|
|
|
I see.
|
|
|
|
|
A quick and accurate solution for colors that actually have names:
Consider your color fields as a long (32 bit) unsigned int.
i.e., RGB(16,32,64) are actually the values (for three) of bytes.
Convert them so that each takes it's proper place in the long.
Find the value of the long for each of the named colors.
[How you decide to do this I leave as an exercise]
Then, create a switch with each of the known values as a case.
A default value catches the rest (convert to a sting "#rrggbb", for example)
Since this is C#, you can also do the reverse.
Other solution could involve you with the Color enum's.
Loads of ways to do this.
They can be built into a set of overloaded functions so you can make it even easier to convert from the RGB values to string and enum values.
Think of this as a viable (if not always the most efficient) pattern for many similar problems.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek dissappointment. If you are searching for perfection in yourself, then you seek failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
My Vote of one:
Did you bother to read the other posts? The chaps with the orange diamonds are pretty experience, and they say he shouldn't do it (reasons below) Your reply is very misleading because:
Balboos wrote: .... Convert RGB to long........
Find the value of the long for each of the named colors.
What about the longs that don't have named colors (which are the majority, there are > 16 million colours available)? Make one up? Find the closest (Now what do I do if it is exactly between to colors?)?
Normally I'd chalk this down to lack of experience, but several people have given clear reasons why it can't be done.
|
|
|
|
|
I was fairly sure his tongue was in his cheek.
|
|
|
|