|
Thanks CPallini,
So, you agree with my analysis in my original post?
regards,
George
|
|
|
|
|
Yes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks CPallini,
Question answered.
regards,
George
|
|
|
|
|
George,
I really think type casting should be avoided at all matters!!
If you stick with compiler native conversion, you would probably get a warning or even an error (like you did casting an int out of a void *).
int type is totally architecture dependent. That's why I'd stick with __int[8,16,32,64] or boost::int[8,16,32,64]
|
|
|
|
|
Could we use __int[8,16,32,64] in VC? I did some search but not find results.
regards,
George
|
|
|
|
|
just a note: the "DWORD" type is 32 bits in both Win32 and x64
|
|
|
|
|
I understand and agree. But does it relates to my original question?
regards,
George
|
|
|
|
|
Hello
I'm looking for a fast way to scan a buffer and check if a pixel color is between a color range, or not.
Maybe some code explains it better:
I have a buffer with 32Bits per Pixel (RGBA => R=8Bit, G=8Bit, B=8Bit, A=8Bit => 32Bit).
This buffer is... let's say 200x200 pixels.
char redUpper = 100;
char redLower = 50;
char greenUpper = 150;
char greenLower = 130;
char blueUpper = 20;
char blueLower = 10;
int* pBuffer = new int[200*200];
fillBufferWithData(pBuffer, 200*200);
char* pCursor = (char*)pBuffer;
for (int i = 0; i < 200*200; i++)
{
if ((pCursor[0] > redLower) && (pCursor[0] < redUpper)
&& (pCursor[1] > greenLower) && (pCursor[1] < greenUpper)
&& (pCursor[2] > blueLower) && (pCursor[2] < blueUpper))
{
pCursor[3] = 0;
}
else
{
pCursor[3] = 255
}
pCursor += 4;
}
delete [] pBuffer;
Okay. I hope that helps to understand what i want to do. I know thats not the fastest way (at least I hope so). Maybe someone knows a better way, perhaps with bit-shifting, or bit-masking?
Thanks in advance,
SnowProg
|
|
|
|
|
Due to short-circuit of the boolean operations inside the if statement, the code is reasonably fast.
Maybe using three look-up tables will improve the code speed, but I'm not an expert.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello everyone,
I found some weird issues when using x64 Windbg debugger to debug x86 binary on x64 machine, then I have tried to install x86 Windbg debugger to debug x86 binary on x64 machine, seem every weird issues is gone.
My questions,
1. Install two debuggers, Windbg x86 and x64 on one machine will be ok? No conflict?
2. Both debugger could automatically resolve system dependent resources -- for example, x64 debugger knows to load x64 system DLL and x86 debugger knows to load x86 system DLL, the same to registry settings?
thanks in advance,
George
|
|
|
|
|
how can i restrict user from pressing shift key in editbox ..
plz help me
|
|
|
|
|
Can you tell us why you want to block it?
|
|
|
|
|
i want to make user to only input numbers (1 to so on) but not spectial charters using shift like (%,#,@,!,^,&,*,()) etc
|
|
|
|
|
ani_ikram wrote: i want to make user to only input numbers
You can handle the WM_CHAR message of edit control and inside that, you can check, whether the character is number or not. If it is not number, just return from that function, with out calling the base class'( CEdit ) function.
|
|
|
|
|
can u plz send me code so that i can get idea
|
|
|
|
|
The below code will block the special charcters but permits alphabets and numbers
void EditEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if( !isdigit(nChar) && !isalpha( nChar ))
{
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
|
|
|
|
|
void EditEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if( !isdigit(nChar) && !isalpha( nChar )) { return; } CEdit::OnChar(nChar, nRepCnt, nFlags);}
i hv used this method but its also restricting to enter float value while i want to enable float numbers as well plz tell me how to do it
|
|
|
|
|
ani_ikram wrote: well plz tell me how to do it
Just modify the checking as follows
if( !isdigit(nChar) && !isalpha( nChar ) && nChar != _T('.'))
|
|
|
|
|
thanks alot nave u really solved my problem
|
|
|
|
|
You are welcome...
|
|
|
|
|
BTW, if you only wanted to have an edit control into which you can enter a float value, there are hundreds of article about that subject, you only have to search for it on codeproject. Here[^] is an example.
The problem with your approach is that it is not secure: nothing prevents the user to enter a dot several time. So, instead of reinventing the wheel and rewriting the validation code all over again(it's not that trivial because, you have also to take into account that the user might delete some characters, change the cursor location, ...) why don't you look for a control that does this already ?
|
|
|
|
|
If you do not want floating point numbers you can set the Numbers only property in resource editor.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
if you want to use only numbers than you can use number property of EditBox.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
if you want to block Special character than you can subclass your edit control and handle OnChar function like this.
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
char szBuffer[100] = {0};
short int nCounter = 0;
short int iTemp = 0;
int iStartChar = 0;
int iEndChar = 0;
if(nChar != VK_BACK && nChar != VK_TAB )
{
if(nChar != '.' (nChar < '0' || nChar > '9')
&& (nChar < 'a' || nChar > 'z')&&(nChar < 'A' || nChar > 'Z'))
{
return;
}
GetWindowText((LPTSTR)szBuffer, sizeof(szBuffer));
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Do you have an aversion against isalpha() and isdigit() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|