|
jannathali wrote: Is there any maximum limit for the char array
What do you mean, exactly?
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]
|
|
|
|
|
Is there any limit for the array size.
i.e char a[Max_Value];
Is there a limit for this value
Or i can give any big value like char a[40000]; etc
|
|
|
|
|
If you're declaring it local to a function, the size is limited by the available stack space.
If you're declaring it globally, the size is limited by the data section size.
|
|
|
|
|
You may have such big values (why don't you try?).
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]
|
|
|
|
|
In most of the cases (but there are some few exceptions), when you have to ask yourself such a question, it probably means that you have taken a bad design decision.
|
|
|
|
|
|
Hello Friends
I am using namespace MSXML in my application to traverse and read XML file.But I have some confusion regarding MSXML is that this one is related to c++ DOM APIs na? And what its relation with COM?
And these both COM AND DOM are provoding different APIs?and then what is DCOM?
Please Suggest me something.I am too confused.
Thanks & Regards
Yogesh
modified on Wednesday, April 7, 2010 2:55 AM
|
|
|
|
|
Roughly speaking, DOM is just a way of representing (and accessing) the XML document (see [^] for a better definition).
There are many libraries dealing with XML documents and some of them, such as MSXML , implement DOM .
Incidentally MSXML is COM (see [^]) based, but that is a mere technological choice. When you use MSXML library, you deal with COM objects representing the corrensponding DOM ones (ADO library shows a similar approach, it exposes an object model for databases: every database object, such as, for instance, the recordset, is a COM one).
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]
|
|
|
|
|
I have a bunch of DXT5 DDS files, but information on the format is so sparse I have no idea how to write something to convert them. I have the following code as part of a library and this converts it to a format I can use, but I can't understand what I need to change to make it read the files as big endian.
If anyone could at least explain how the the *src variable is being used so I could determine where I need to convert stuff that would help, I currently don't get how values are being derived from it.
vlBool CVTFFile::DecompressDXT5(vlByte *src, vlByte *dst, vlUInt uiWidth, vlUInt uiHeight)
{
vlUInt x, y, i, j, k, Select;
vlByte *Temp;
Colour565 *color_0, *color_1;
Colour8888 colours[4], *col;
vlUInt bitmask, Offset;
vlByte alphas[8], *alphamask;
vlUInt bits;
vlByte nBpp = 4;
vlByte nBpc = 1;
vlUInt iBps = nBpp * nBpc * uiWidth;
Temp = src;
for (y = 0; y < uiHeight; y += 4)
{
for (x = 0; x < uiWidth; x += 4)
{
alphas[0] = Temp[0];
alphas[1] = Temp[1];
alphamask = Temp + 2;
Temp += 8;
color_0 = ((Colour565*)Temp);
color_1 = ((Colour565*)(Temp+2));
bitmask = ((vlUInt*)Temp)[1];
Temp += 8;
colours[0].r = color_0->nRed << 3;
colours[0].g = color_0->nGreen << 2;
colours[0].b = color_0->nBlue << 3;
colours[0].a = 0xFF;
colours[1].r = color_1->nRed << 3;
colours[1].g = color_1->nGreen << 2;
colours[1].b = color_1->nBlue << 3;
colours[1].a = 0xFF;
colours[2].b = (2 * colours[0].b + colours[1].b + 1) / 3;
colours[2].g = (2 * colours[0].g + colours[1].g + 1) / 3;
colours[2].r = (2 * colours[0].r + colours[1].r + 1) / 3;
colours[2].a = 0xFF;
colours[3].b = (colours[0].b + 2 * colours[1].b + 1) / 3;
colours[3].g = (colours[0].g + 2 * colours[1].g + 1) / 3;
colours[3].r = (colours[0].r + 2 * colours[1].r + 1) / 3;
colours[3].a = 0xFF;
k = 0;
for (j = 0; j < 4; j++)
{
for (i = 0; i < 4; i++, k++)
{
Select = (bitmask & (0x03 << k*2)) >> k*2;
col = &colours[Select];
if (((x + i) < uiWidth) && ((y + j) < uiHeight)) {
Offset = (y + j) * iBps + (x + i) * nBpp;
dst[Offset + 0] = col->r;
dst[Offset + 1] = col->g;
dst[Offset + 2] = col->b;
}
}
}
if (alphas[0] > alphas[1])
{
alphas[2] = (6 * alphas[0] + 1 * alphas[1] + 3) / 7;
alphas[3] = (5 * alphas[0] + 2 * alphas[1] + 3) / 7;
alphas[4] = (4 * alphas[0] + 3 * alphas[1] + 3) / 7;
alphas[5] = (3 * alphas[0] + 4 * alphas[1] + 3) / 7;
alphas[6] = (2 * alphas[0] + 5 * alphas[1] + 3) / 7;
alphas[7] = (1 * alphas[0] + 6 * alphas[1] + 3) / 7;
}
else
{
alphas[2] = (4 * alphas[0] + 1 * alphas[1] + 2) / 5;
alphas[3] = (3 * alphas[0] + 2 * alphas[1] + 2) / 5;
alphas[4] = (2 * alphas[0] + 3 * alphas[1] + 2) / 5;
alphas[5] = (1 * alphas[0] + 4 * alphas[1] + 2) / 5;
alphas[6] = 0x00;
alphas[7] = 0xFF;
}
bits = *((int*)alphamask);
for (j = 0; j < 2; j++)
{
for (i = 0; i < 4; i++)
{
if (((x + i) < uiWidth) && ((y + j) < uiHeight)) {
Offset = (y + j) * iBps + (x + i) * nBpp + 3;
dst[Offset] = alphas[bits & 0x07];
}
bits >>= 3;
}
}
bits = *((int*)&alphamask[3]);
for (j = 2; j < 4; j++)
{
for (i = 0; i < 4; i++)
{
if (((x + i) < uiWidth) && ((y + j) < uiHeight)) {
Offset = (y + j) * iBps + (x + i) * nBpp + 3;
dst[Offset] = alphas[bits & 0x07];
}
bits >>= 3;
}
}
}
}
return vlTrue;
}
|
|
|
|
|
do you have a type definition for v1Byte ?
(assuming its just 'byte' could be dangerous)
I am formulating a longer response, I just want to be careful in how I frame it
'g'
|
|
|
|
|
|
Just convert your src sequence
(with the length in bytes = uiWidth * uiHeight )
into the Intel-format (by granularity of DWORD )
at the beginning of the function...
virtual void BeHappy() = 0;
|
|
|
|
|
Hi,
the difference between little-endian and big-endian is: multi-byte values are stored with their least significant byte first for little-endian, and with their most significant byte first for big-endian.
This implies variables of type short, int, long, float, double get their bytes swapped, however byte-oriented values (such as char, and string) remain unchanged. Now, assuming vlByte is a byte, that may make no difference whatsoever to the code shown. Maybe the only difference is where you obtain uiWidth and uiHeight, however that must happen outside the function shown.
|
|
|
|
|
Could someone please explain to me why the following code does not work?
I build a new thread in a view process:
….
m_COpenHR_AutoCOM_Thread = (COpenHR_AutoCOM_Thread*) AfxBeginThread(ThreadFunction,this,THREAD_PRIORITY_LOWEST);
VERIFY(m_COpenHR_AutoCOM_Thread);
return 1;
}
Runs the thread function within the view class just fine.
Now I want to stop the process.
In property page I have this code to post thread message:
CWinThread* pCurrentThread = AfxGetThread( );
if(!pCurrentThread->PostThreadMessage(WM_USER_AUTO_COM , 0, 1))
{
TRACE("PostThreadMessage(WM_USER_AUTO_COM , 0, 1))");
}
In the derived CWinThread class I have this:
BEGIN_MESSAGE_MAP(COpenHR_AutoCOM_Thread, CWinThread)
//{{AFX_MSG_MAP(COpenHR_AutoCOM_Thread)
// NOTE - the ClassWizard will add and remove mapping macros here.
ON_THREAD_MESSAGE( WM_USER_AUTO_COM, ControlThread )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
I never get to the ControlThread function.
What am I missing or doing wrong? Should PostThreadMessage be directed to my new thread and how?
Thanks you for your help.
Vaclav
|
|
|
|
|
AfxGetThread( ) must be called from within the thread.
In your code, the pCurrentThread doesn't point to the thread you wish to send the message.
Instead you must use,
m_COpenHR_AutoCOM_Thread->PostThreadMessage(WM_USER_AUTO_COM , 0, 1))
Powered by Ctrl + C
Driven by Ctrl + V
|
|
|
|
|
I think you are creating a worker thread. As per my knowledge, you may need to create a UI thread inorder to post messages to the new thread. See the other version of AfxBeginThread function.
|
|
|
|
|
Use User Interface thread instead worker thread.
sthalasayanam
|
|
|
|
|
You need to create a thread with a message pump so that it can receive and process your message. Right now, you're creating a background worker, which won't have a message pump.
Take a look at this article to achieve what you're trying to do: www.flounder.com/uithreads.htm[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
You could use an event (e.g., CEvent ) between the two threads. Signal it in the primary thread, and check it in the secondary thread using WaitForSingleObject() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks y'all!
I guess I missed it somewhere in documentation that I need the message queue / pump. But I was puzzled why my CWinThread derived class was never constructed.Duh!
But I am beginning to see big flaw in my design - I need to "unload" processing time from the main thread ( I hope that is in English!) so I can click the button to stop my process. But I want to stop this process at specific location , so why am I going thru all this extra code if I can just put a global flag and set it in the worker thread?
What would be the difference between this (flag) and setting an event in worker thread and waiting for it in the main thread as suggested?
(BTW very good suggestion,thanks)
I prefer KISS methods! I was just trying to learn how to communicate between threads for future reference when the task won't be so simple.
Anyway, can someone elaborate on this: if I create worker thread variable in one thread (as I did ) how can I use that variable ( to control the thread as I wanted originaly) from another class ( object )?
Do I need a global variable? How would that appoach differ from my use of simple flag?
But I think I am getting too far into left field of what - if scenario.
Thanks again for all you suggestions, I really appreciate it.
Vaclav
PS Spring is finally here in Texas! Success!
|
|
|
|
|
Addendum
I decided to try the UI thread to stop the process. Seems like a challenge and I like to torture myself with goofy programming techniques.
Now I cannot figure out how to execute the process I was after. This process ( used to be worker thread "function") and its 300+ lines of code is in the view main thread!
It is OK to make the view variable in the new UI thread? On first thought it seems like "circular reference". Any other way to do this “ function transfer” from the view?
Thanks for all you help.
Vaclav
|
|
|
|
|
"Progress" report:
I have managed to execute an equivalent of "worker thread function" located in the UI thread class.
Two problems:
1. It needs access to document and it asserts there. I am working on why.
2. The big one:
If I temporary bypass the code( won't work witout the document) and just do an infinite loop ( even with some Sleep in it) I cannot click the UI button! That means only one thing - the OS is too busy letting the main thread messages thru! That is not what I was after in the first place!
If I continue with multithreaded approach (just for kiks) I need to write some more code! Joy!?
|
|
|
|
|
Can anybody tell me a function that resets the computer?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Resets it to what?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I mean to restart the computer, like pressing start -> Turn off computer -> Restart
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|