Gamestudio Links
Zorro Links
Newest Posts
zorro license, IB connection
by miwok. 12/06/23 16:32
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (miwok, AndrewAMD, TipmyPip, 3run, Quad, 1 invisible), 645 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
BMAP* to char ... and ... char to BMAP* ??? #243523
12/30/08 15:14
12/30/08 15:14
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi,

is it possible to write the data of a BMAP* into a char array and back ???

I have a struct that looks like this:

typedef struct SAVEGAME {
char savegameName[64];
char picture[20000];

char currentRoomName[100];
char currentPlayerName[100];

char player1IsInRoom[100];
VECTOR player1Position;
ANGLE player1Rotation;
char player1Inventory[1024];

char player2IsInRoom[100];
VECTOR player2Position;
ANGLE player2Rotation;
char player2Inventory[1024];

char player3IsInRoom[100];
VECTOR player3Position;
ANGLE player3Rotation;
char player3Inventory[1024];

int playtime;
char objectStates[2000];
} SAVEGAME;

Later in my code I use the following code to store the BMAP*:

BMAP* picture = bmap_createblack(245,110,24);
bmap_for_screen(picture, 4, 0);
wait(1);
savegame->picture = (char*)picture;

But I don't know how the get the BMAP* back from the char.
I tried:

BMAP* picture = bmap_createblack(245,110,24);
picture = (BMAP*)savegame->picture;

But that doesn't seem to work.

Can someone help?

Regards,
Pegamode.

Re: BMAP* to char ... and ... char to BMAP* ??? [Re: pegamode] #243626
12/30/08 23:54
12/30/08 23:54
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
you assigned the BMAP pointer to the char and not the BMAP itsself. _maybe_ it will work if you change that.

Re: BMAP* to char ... and ... char to BMAP* ??? [Re: Scorpion] #243655
12/31/08 07:00
12/31/08 07:00
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi Scorpion,

how can I assign the BMAP itself to the char? I'm not sure how to get the BMAP from the BMAP*.

Re: BMAP* to char ... and ... char to BMAP* ??? [Re: pegamode] #243921
01/01/09 18:10
01/01/09 18:10
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
No one any idea?

Re: BMAP* to char ... and ... char to BMAP* ??? [Re: pegamode] #243929
01/01/09 19:00
01/01/09 19:00
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
I do not fully understand what you want to accomplish.
Do you want to save a bitmaps filename in a char array?

Apparently the BMAP struct doesn't contain the bitmaps filename, so this wont work.

Re: BMAP* to char ... and ... char to BMAP* ??? [Re: Saturnus] #243937
01/01/09 20:06
01/01/09 20:06
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
20000 chars array feels like he is trying to store file in struct.


3333333333
Re: BMAP* to char ... and ... char to BMAP* ??? [Re: Quad] #244045
01/02/09 09:35
01/02/09 09:35
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Correct.
I want to save the BMAP data in the char array.

I save the SAVEGAME struct in a file.
Now I'd like to add a screenshot for every savegame into that struct to avoid saving the screenshot in a seperate file.

Re: BMAP* to char ... and ... char to BMAP* ??? [Re: pegamode] #244142
01/02/09 22:36
01/02/09 22:36
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
The actual picture data is larger than you've planned for, so you will need to change you're
struct definition from "char picture[20000];" to "char picture[81000];" [or 80500 to be exact].

To store the picture in your struct, replace
Code:
   BMAP* picture = bmap_createblack(245,110,24);
   bmap_for_screen(picture, 4, 0);
   wait(1);
   savegame->picture = (char*)picture;
with
Code:
   BMAP* pic = bmap_createblack(245,110,24);
   bmap_for_screen(pic, 4, 0);
   wait(1);
   var picsize = pic.width*pic.height*pic.bytespp;   //number of bytes in snapshot == Width X Height X BytesPerPixel.  BytesPerPixel= color bits / 8
   var byt; for(byt=0; byt<picsize; byt++)	savegame->picture[byt] = (pic.pixels)[byt];   //copy pixels to struct->picture from BMAP

Then to retrieve the snapshot, use this
Code:
   BMAP* pic = bmap_createblack(245,110,24);
   var byt; for(byt=0; byt<picsize; byt++)	(pic.pixels)[byt] = savegame->picture[byt];      //copy pixels from struct->picture to BMAP

I havent compiled this, so we may need to tweak it to get it to compile, but I believe the design is right.

Any problems or questions from anyone, let me know.

[EDIT] Ive changed your BMAP name from picture to pic JUST for ease of reading. Change my code to match its old name if you wish.

Last edited by EvilSOB; 01/02/09 22:40. Reason: Footnote Added

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: BMAP* to char ... and ... char to BMAP* ??? [Re: EvilSOB] #244197
01/03/09 10:29
01/03/09 10:29
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Thanks EvilSOB ... I'll try that and give feedback.

Re: BMAP* to char ... and ... char to BMAP* ??? [Re: pegamode] #244200
01/03/09 11:24
01/03/09 11:24
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi EvilSOB,

I tested the code.
Saving seems to work,
but when I try to retrieve the snapshot with
Code:
for(byt=0; byt<savegame->picsize; byt++) {  	
  (pic.pixels)[byt] = savegame->picture[byt];      //copy pixels from struct->picture to BMAP
}

the line:

(pic.pixels)[byt] = savegame->picture[byt];

results in an error "crash in ...".

Any ideas???

Regards,
Pegamode.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1