|
3 registered members (AndrewAMD, Grant, valino),
3,361
guests, and 13
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: BMAP* to char ... and ... char to BMAP* ???
[Re: pegamode]
#244285
01/03/09 20:14
01/03/09 20:14
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
not sure, but try these combos pic.pixels[byt] = savegame->picture[byt]; or pic.pixels[byt] = (savegame->picture)[byt]; or (pic.pixels)[byt] = (savegame->picture)[byt];
Accessing arrayed structure elements is always a fuzzy part for me...
Also, make sure savegame->picsize is being saved correctly.
"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]
#244355
01/04/09 09:10
01/04/09 09:10
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
Hmmm ...
the first two combos end in a compiler error.
With the last one I get the same result as before ... crash in function.
savegame->picsize is correct, but the crash occurs with the first call of the line in the for-loop.
Maybe pic.pixels is read-only?
I also tried to use bmap_lock and bmap_unlock.
Any other idea?
Last edited by pegamode; 01/04/09 09:21.
|
|
|
Re: BMAP* to char ... and ... char to BMAP* ???
[Re: pegamode]
#244358
01/04/09 09:38
01/04/09 09:38
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
As a workaround I'm currently using the following code: I changed from char to var in the struct. To save the picture in my struct:
bmap_lock(screenshot_pic,0);
int x=0;
int y=0;
int z=0;
for(y=1;y<=110;y++) {
for(x=1;x<=245;x++) {
savegame->picture[z] = pixel_for_bmap(screenshot_pic,x,y);
z++;
}
}
bmap_unlock(screenshot_pic);
And to load it back:
BMAP* pic = bmap_createblack(245,110,24);
bmap_lock(pic,0);
int x=0;
int y=0;
int z=0;
for(y=1;y<=110;y++) {
for(x=1;x<=245;x++) {
pixel_to_bmap(pic,x,y,savegame->picture[z]);
z++;
}
}
bmap_unlock(pic);
This works fine, but I think the other version would be faster, wouldn't it? But it seems writing directly into pic.pixels is crashing the engine. Regards, Pegamode.
|
|
|
Re: BMAP* to char ... and ... char to BMAP* ???
[Re: pegamode]
#244457
01/04/09 20:22
01/04/09 20:22
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Hmm, yes mine would be much faster....if it was working!
I'll look into it today and actually compile and test this time. I'll post back my results when Im done.
Sorry for the inconveniance.
"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]
#244480
01/04/09 23:56
01/04/09 23:56
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Dammit. Looks like this is a dead issue, except by using the pixel_for_bmap and pixel_to_bmap functions, which are fairly slow.
BMAPs seem to jump back and forth with whether the ACTUAL data is stored in the friendly *pixels data blocks and the evil *d3dtex data blocks,which are too complex.
I'll keep looking into it, but I dont have very high hopes, either on chance of sucess OR time to resolve...
I'll give you a hand with pixel_for_bmap and pixel_to_bmap if you want, as a savegame function doesnt really need speed.
"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: pegamode]
#244637
01/05/09 23:00
01/05/09 23:00
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
So why the preference of a CHAR array rather than a VAR array? I only looked into this as I saw a potential shortcut for you that didnt pan out.
If you dont want to have VARs in your struct you could use FLOATs instead. Change your struct to float picture[20000]; and replace you encoding line savegame->picture[z] = pixel_for_bmap(screenshot_pic,x,y); with savegame->picture[z] = floatv(pixel_for_bmap(screenshot_pic,x,y));
and your decoding line pixel_to_bmap(pic,x,y,savegame->picture[z]); MAY need to change to pixel_to_bmap(pic,x,y,(var)savegame->picture[z]);
Then all the data will be stored as a clean single FLOAT for every pixel. Also would it possible be better to store the picture data is a TWO dimensional array like this? float picture[245][110];
"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: pegamode]
#244831
01/07/09 02:28
01/07/09 02:28
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Maybe savegame->picture[z] = (float)pixel_for_bmap(screenshot_pic,x,y); instead of savegame->picture[z] = floatv(pixel_for_bmap(screenshot_pic,x,y)); Its possible the floatv function does something off to the pixel data.
But if you are happy with VAR's then its no propblem.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|