Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / of memblocks and images

Author
Message
Me!
18
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 16th Oct 2005 18:09 Edited at: 16th Oct 2005 18:31
this code is supposed to get an image from a screen then put it into a memblock, read the bytes from the memblock into a file, then remove all the old data, reload a new memblock with the image data, make an image from it then use it as sprite and save the image to disk.



the only trouble is that it doesnt work, this isn`t actualy my problem, this was actualy going to be the example code that would demonstrate the problem, but it crashes with an internal error 12002 according to the crash report, it doesn`t like the line where you make the image from the memblock, I assume that the data is getting corrupted in some manner, but I can`t work out how, anyway, here is a description of the actual problem I am having and was trying to describe with the help of this code.

(if anyone is wondering why this post gradualy gets bigger with every edit??...well..you recall the forum didn`t like me trying to post?...well it`s at it again, I have to add a bit at a time or it just eats it )

in my full program I create some DBPro rendered images, grab em to an image number, make a memblock from that number, read the numbers byte by byte from the memblock, write em to a file, close the file, delete all previous objects, images and media, open the file, make a memblock, read the data back byte by byte, close the file, make an image from the memblock, and this is where my problems start, I get a image that has magical properties, you can paste it to the screen and it looks ok, you can use "save image" to save it to a hard drive and it looks ok in preview or inside paint etc, but if I try to use the image for a sprite it just turns into about 12 or so pixels that take up the same area as the sprite, have the right color for parts of the sprite, but its obviously wrong, and I can`t work it out

it isn`t some code error to do with using the right image number, I defined a variable called uniqueimagenumber and used that, I had a bit of code that was just the loader and the lines that made and displayed the image, if I use paste image or save the image to disk it looks ok, if I try to use it as a sprite it just goes La-La, I just subsituted the lines that saved/pasted or tried to display the sprite, same result, it will paste or save, but it refuses to be a sprite

(I have done editing...feel free to comment...and someone ought to fix up these forum bugs, they are getting silly)



Tyger software
Me!
18
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 16th Oct 2005 19:03 Edited at: 16th Oct 2005 19:04
more curious, at certain sizes DB can`t load the images it saved it`self, I just get an "unable to load image at line xxx" error, this leads me to think the data has been corrupted somehow (these images still preview in windows and load into paint though)



Tyger software
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Oct 2005 22:52
Don't know what the problem is, but it crashed silently on me.

But this works...



Me!
18
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 17th Oct 2005 11:21
yeah! I got that working earlier too, but that wasn`t exactly what I was trying to do, the idea was to eventualy create one large 3D looking bitmap on the hardrive (the 3d rendered in detail slowly in a DB editor and then composited together), this would save the system memory, and then I could load sections of that large bitmap as zones, (think Chaos engine with logicaly connected regions) but I cannot isolate the bug and it would be asking too much of other peoples systems to hold an entire 250000x250000 bitmap in memory, its a lot to ask for 4gig for just a game bitmap off the hardrive as it is.

I wanted to use DB generated images since while I can create hard coded objects that look ok, my 2D art makes the average 4 yr old look like a Dutch renaissance painter, making hardcoded objects and grabbing them is the way to go for me, I hate 3D editors, none of them do it properly, too fiddley with millions of features I would never use, (I used to like Real3D on the Amiga though, that was about the only editor I could do anything with), plus the download file would be realy small with objects/textures created from a data file, the full bitmap would be created right after the install onto the hardrive as a run once initialisation routine for the game.

trouble is I can`t find the cause of the image corruption, it seems to be in the file save/load routines but on the Darkbasic rather than the user code side, as you say, just saving seperate memblocks works fine with no issues, btw, there are some other reasons for needing it as one large "on drive" bitmap, but they come under "trade secret original idea" , I think maybe I could put this into the Bugs section if nobody can work out whats happening or why.



Tyger software
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 20th Oct 2005 14:25
Bug in your code I'm afraid.

You can't hold size of memblock in a 'word' which is only 2 bytes - that only goes up to 65535

change to;

write long 1,memblocksize

and

read long 1,filesize

and also change open command to this;

f$="custom.sav"
if file exist(f$) then delete file f$
open to write 1,f$

as write command will fail if file already exists.

Voila! Your sprite then loads perfectly!

Boo!
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 20th Oct 2005 14:34
Games like chaos engine use lots of tiles for engine so their are just a handful of graphics that get repeated. Having a huge bitmap for a game, even if you load it in bits just isn't feasible in my opinion.

Chaos engine rocks.

I remember guessing loads of passwords for Amiga version and finding some that work and gave you loads of extras.

Boo!

Login to post a reply

Server time is: 2024-05-06 17:15:05
Your offset time is: 2024-05-06 17:15:05