Click here to Skip to main content
16,010,650 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
Hi,

I was wrong by talking about short sorry.

by 1 0 0 0 I was meaning 01 00 00 00 = 8 bits = 1 byte.

The values are stored as set of 2 bits (values are between 0 - 3), but the sets are inverted in the file.

The values meaning are the following:
00 : nothing
01 : wall
10 : ladder
11 : tree

So, for example, when in the file there is the byte value:
0x68 : 01 10 10 00

the real values should be interpreted as:
0x29 : 00 10 10 01

1 byte means 4 cells of the array.
The series of 2 bits are inverted.
See what I mean?

So, the compressed array's size is (MapWidth/2)x(MapHeight/2).

for example if you have a tiny 4x8 map like this: (t1)
1 1 1 1 1 1 1 1
1 0 2 2 0 0 0 1
1 0 2 2 0 0 0 1
1 1 1 1 1 1 1 1

In the collision map coded like this in memory: (t2)
01 01 01 01 01 01 01 01
01 00 10 10 00 00 00 01
01 00 10 10 00 00 00 01
01 01 01 01 01 01 01 01

and in the file it is like this: (t3)
01 01 01 01 01 01 01 01
10 10 00 01 01 00 00 00
10 10 00 01 01 00 00 00
01 01 01 01 01 01 01 01

in hexa as bytes it looks like this:
0x55 0x55
0xa1 0x40
0xa1 0x40
0x55 0x55
the size of the compressed array is 2x4 like I wrote above (MapWidth/2)x(MapHeight/2)

In the unsigned char* it is coded like this (in the file)
0x55 0x55 0xa1 0x40 0xa1 0x40 0x55 0x55

so, in our example, GetAt(compressedArray, 3, 1) should returns 2 (0x10 - column 3, line 1 from t2)

while it is read from the compressedArray...

I hope it is clearer with a concrete example.

I'm sure there is a way to decode it on the fly without storing the decompressed array.

Thanks for the help

Best regards.

Fred.




There is no spoon.

-- modified at 12:20 Saturday 25th March, 2006
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 
AnswerRe: Flat DateTimePicker Class Pin
mikobi25-Mar-06 3:16
mikobi25-Mar-06 3:16 
Questionproblem with m_strCursor Pin
Kranti125198424-Mar-06 20:21
Kranti125198424-Mar-06 20:21 
QuestionVS2005 - ellipsis in a macro Pin
Chintoo72324-Mar-06 18:42
Chintoo72324-Mar-06 18:42 
AnswerRe: VS2005 - ellipsis in a macro Pin
Michael Dunn25-Mar-06 0:23
sitebuilderMichael Dunn25-Mar-06 0:23 

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.