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 / Write Memblock to file adds a byte to the beginning?

Author
Message
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 2nd Jun 2012 08:10
I'm trying to create "encrypted" images for a program by:
1. Loading the image,
2. Making a Memblock from it,
3. Then writing the Memblock to a file.

Then, to open the "encrypted" image, I'm:
1. Loading the file,
2. Making a Memblock from it,
3. Then making an image from the Memblock.

When I load the new file, and make a Memblock from it, it has an extra byte of data at the beginning! I can copy the Memblock to a new one by skipping the first byte but that seems like a workaround for something I may not be understanding and doing correctly.

Does the extra byte of information have a purpose, is it a bug, or is it something that I am doing incorrectly?

Here is some code for an example of my situation:


Here is the image I'm using for the example:


And here is an image of the above code running:



Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 2nd Jun 2012 12:23
If I am right the first 4 bytes are the size of the memblock. If you don't want them you can use make file from memblock instead of write memblock. or you can use read memblock instead of make memblock from file when loading it.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2012 16:20
Yes, make file from memblock is the command to use - no need to mess about with extra bytes then.

Here's the code I used:

zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 2nd Jun 2012 22:34
Thanks, guys! It works great. I'm usually pretty meticulous about crawling through the help files and forum searches. Don't know why I didn't notice the different make file from memblock and write memblock. Either way, thanks again!

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.

Login to post a reply

Server time is: 2026-07-08 21:14:55
Your offset time is: 2026-07-08 21:14:55