|
|
I have an array of BYTEs named aBytes. As you know, It looks some thing like this in the memory:
1000100110001010100011011011010110110101 ...
memory increase ---->
Now I want to separate 6-Bit chunks from the begin, as follow:
100010011000101010001101101101011011 ...
memory increase ---->
I used this code:
typedef unsigned __int32 BASE64
struct CHUNKS
{
BASE64 First:6;
BASE64 Second:6;
BASE64 Third:6;
BASE64 Fourth:6;
}*pChunk = NULL;
for (int iCountor = 0; iCountor < Size_Of_aBytes; iCountor++)
{
pChunk = (CHUNKS*) (aBytes + iCountor);
} But each time, I get wrong values. Where is the problem?
Thank you masters!
|
|
|
|
|
Hi Jusef,
iCountor is counting 4-byte integers and you want the pChunk pointer to advance by 4 bytes, however aBytes is a char pointer, so adding iCountor to it is not correct. You should use one of these:
pChunk = (CHUNKS*) (aBytes + 4*iCountor);
pChunk = ((CHUNKS*)aBytes) + iCountor;
|
|
|
|
|
What type is aBytes ?
I'll presume it's a char or BYTE pointer. You want to increment it by sizeof (struct CHUNKS) , as you want to manipulate items of that type. One wrinkle - making sure you don't increment off the end of the byte array and making sure that all of a CHUNK is in the array.
Anyway - try this:
for (int chunkCountor = 0; chunkCountor < Size_Of_aBytes/sizeof (struct CHUNKS); chunkCountor++)
{
pChunk = ((CHUNKS*) (aBytes)) + chunkCountor;
}</pchunk>
|
|
|
|
|
You're on the right track, but remember that a BYTE is 8 bits, so you can't just use aBytes + iCountor to increment the way you are.
One suggestion would be to decode three bytes (four values) at a time in your loop:
struct CHUNKS
{
DWORD First:6;
DWORD Second:6;
DWORD Third:6;
DWORD Fourth:6;
} *pChunk = NULL;
int iCountor = 0;
for (iCountor = 0; iCountor < Size_Of_aBytes; iCountor += 3)
{
if ((iCountor + 3) <= Size_Of_aBytes)
{
pChunk = (CHUNKS*) (aBytes + iCountor);
}
else
{
}
}
Note that this is UNTESTED code, but should give you what you're looking for.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hai all,
We have around 7 dialog boxes in our application. And to navigate from one dialog box to the other dialog box we use doModal(). After navigating for some time between the dialog boxes we get a debug assertion failure and when checked through call stack all the error falls into doModal() and pretranslatemessage(). Please help us out..........
Thanks and Regards
Bhanu
|
|
|
|
|
Please paste code snippets...
Regards,
Sandip.
|
|
|
|
|
are you opening model dialog on model dialog box?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
i have a c library which sends and receives video from other peer, so i have to display video..i have created window for viewing video using mfc...what would be ur suggestion how to send/receive the video data from c library to my mfc application... does sendMsg can handle that huge data (around 3k-4k bytes per message)or should i go for any shared memory kindof stuff....
i have even tried of drawing my video on win32 app but it looked some what weird.....
surender9
|
|
|
|
|
If i were you i'd try making it a DirectShow filter.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi all,
I have a Rect,
e.g:
CRect rect=CRect(10,20,20,40);
i have new width for rect like 80.
now how can i create rect with this width and other values are remains same.
please help me for this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
I think you can use of CRect::DeflateRect .
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hamid. wrote: CRect::DeflateRect.
but this use for Decreases the width and height of CRect.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You can decrease your width of current width with this function.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
rect.InflateRect(0,0,70,0);
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]
|
|
|
|
|
please explain why this.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Your original rect (10,20,20,40) has
width = right - left = 20 - 10 = 10 pixels.
If you want it 80 pixels wide (with minimum change on coordinates) then you should move its right side 70 pixels to the right:
left<sub>new</sub> = left;
right<sub>new</sub> = right + 70;
top<sub>new</sub> = top;
bottom<sub>new</sub> = bottom;
That's what InflateRect(0,0,70,0) does.
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 ,
if new width is decrease so i can use DeflateRect or InflateRect.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You may also use inflate with negative values.
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]
|
|
|
|
|
Juat assign a new value to the right member:
rect.right = rect.left + the_new_width;
|
|
|
|
|
Hi all,
I have made a Dialog box in vc2008 and have made several control on it....
at end i want to release memory occupied by all the controls...
How can i do this??
Thanks in advance
|
|
|
|
|
|
How did you make them?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Although your instincts may tell you otherwise, this is not how memory management[^] works. Your application has an internel working set[^] of memory. The operating system uses this extra memory to make your application faster since the memory is already allocated but simply marked as "stand-by". When you free your memory it does not mean your working set will decrease in size. The memory is simply marked as "not needed now, but maybe later" or "standby". I hope this makes sense.
It is possible to force all standby memory to be released by calling the SetProcessWorkingSetSize Function[^] with -1 for both arguments although its not recommended. It required the PROCESS_SET_QUOTA access right. You can severly harm application performance by abusing SetProcessWorkingSetSize. Note that this technique is not recommended for most applications.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi all,
I need help for coloring the CTabCtrl Window to white in MFC.
Actually I have a Tab control having Two tabs,I have not added Property pages, just put some controls like Edit box and Radio buttons on Tab control and on click of Each tab I am just hiding and showing some controls.
I want to make Tab control color white..
Please give me some sample code or some link for help..
Thanks in advance
|
|
|
|