Click here to Skip to main content
16,005,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to check thread is running or not Pin
ThatsAlok26-Mar-06 17:55
ThatsAlok26-Mar-06 17:55 
QuestionDraw barcode and MapMode Pin
includeh1024-Mar-06 23:55
includeh1024-Mar-06 23:55 
QuestionSending Fax using the FaxSendDocuemnt API Pin
aasstt24-Mar-06 23:02
aasstt24-Mar-06 23:02 
QuestionProblem with Controls on dialog box with images Pin
Ganesh_T24-Mar-06 21:50
Ganesh_T24-Mar-06 21:50 
AnswerRe: Problem with Controls on dialog box with images Pin
Hamid_RT29-Mar-06 6:46
Hamid_RT29-Mar-06 6:46 
GeneralRe: Problem with Controls on dialog box with images Pin
Ganesh_T29-Mar-06 19:20
Ganesh_T29-Mar-06 19:20 
GeneralRe: Problem with Controls on dialog box with images Pin
Hamid_RT30-Mar-06 2:01
Hamid_RT30-Mar-06 2:01 
Questionpure C question about accessing bits Pin
bouli24-Mar-06 21:42
bouli24-Mar-06 21:42 
Dear Gurus,

I have a question concerning accessing bits from an array of unsigned char.

Considering a series of bytes read from an already coded file that I can't modify because it is coded "like that", I need to exctract the bits of the array in the following way:

consider the values in the file:
0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55

the vector (1D array) of unsigned char contents is the same of the file:
0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55

so, here we have 10 unigned char which is the way it is coded in the file.
Now, in the real visual world, it is in fact a 2D array. in our example, it should be an array of 2 lines and 20 columns! each unsinged char represent 4 cell of the real array these values are sets of 2 bits.

So, in our example, we should have the simple array after accessing the file:
L1: 11111111111111111111
L2: 11111111111111111111

if you take the file value as packet of bits you have:
L1: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
L2: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01

Now, group these vallues by packets of nibbles:
L1: 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101
L2: 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101

if you convet these values in hexa by nibbles; you have:
L1: 5 5 5 5 5 5 5 5 5 5
L2: 5 5 5 5 5 5 5 5 5 5

And finally if you group these nibbles by bytes you have the array:
L1: 55 55 55 55 55
L2: 55 55 55 55 55

In the file it is coded the way I told just above:
55 55 55 55 55 55 55 55 55 55

So, if you followed, my question is the following:
given the array read from the file (values just above), how can I access to the set of 2 bits???

the function's header looks like this:
int GetAt(unsigned char* compressedArray, int i, int j);
and it should return the cell content.

How to do such a function that read the compressed values????

I hope you understood my problem.

If so, can someone give me a hand shot please?

Best regards.

Fred.





There is no spoon.

-- modified at 3:45 Saturday 25th March, 2006
AnswerRe: pure C question about accessing bits Pin
Justin Tay25-Mar-06 0:17
Justin Tay25-Mar-06 0:17 
GeneralRe: pure C question about accessing bits Pin
bouli25-Mar-06 2:48
bouli25-Mar-06 2:48 
GeneralRe: pure C question about accessing bits Pin
Justin Tay25-Mar-06 5:25
Justin Tay25-Mar-06 5:25 
GeneralRe: pure C question about accessing bits Pin
bouli25-Mar-06 6:16
bouli25-Mar-06 6:16 
GeneralRe: pure C question about accessing bits Pin
Justin Tay25-Mar-06 6:33
Justin Tay25-Mar-06 6:33 
GeneralRe: pure C question about accessing bits Pin
bouli25-Mar-06 6:50
bouli25-Mar-06 6:50 
GeneralRe: pure C question about accessing bits Pin
bouli25-Mar-06 7:05
bouli25-Mar-06 7:05 
GeneralRe: pure C question about accessing bits Pin
bouli16-Apr-06 0:28
bouli16-Apr-06 0:28 
QuestionOnFind() Pin
fuschia24-Mar-06 21:35
fuschia24-Mar-06 21:35 
AnswerRe: OnFind() Pin
toxcct25-Mar-06 4:53
toxcct25-Mar-06 4:53 
GeneralRe: OnFind() Pin
fuschia25-Mar-06 16:07
fuschia25-Mar-06 16:07 
GeneralRe: OnFind() Pin
toxcct26-Mar-06 3:31
toxcct26-Mar-06 3:31 
QuestionRuntime Compression Pin
Waldermort24-Mar-06 21:19
Waldermort24-Mar-06 21:19 
AnswerRe: Runtime Compression Pin
Saurabh.Garg25-Mar-06 0:48
Saurabh.Garg25-Mar-06 0:48 
GeneralRe: Runtime Compression Pin
Waldermort25-Mar-06 1:28
Waldermort25-Mar-06 1:28 
AnswerRe: Runtime Compression Pin
Hamid_RT25-Mar-06 1:34
Hamid_RT25-Mar-06 1:34 
QuestionFlat DateTimePicker Class Pin
mikobi24-Mar-06 20:31
mikobi24-Mar-06 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.