SRL Archive - SRL Archives

Store information with Bitmaps!


R0b0t1

2007-09-12 18:07:54

Yep, posted about earlier, I'm seeing how people like it.


program New;
//{.Include SRL/SRL.scar}

function IntToBool(TheInt: Integer): Boolean;
begin;
If (TheInt = 0) Then
Result:= False;
else
Result:= True;
end;

function BoolToInt(TheBool: Boolean): Integer;
begin;
If not (TheBool) Then
Result:= False;
else
Result:= True;
end;

{ function SetIntBMP ]
[ ]
[ Desc. : Returns True if it had to split the integer in half to ]
[ store it. In which case, you must specify if it has been ]
[ split on retrieval }

function SetIntBMP(BitMSet, Valu, X, Y: Integer): Boolean;
begin;
If not (Valu > 16777215) Then
begin;
FastSetPixel(BitMSet, X, Y, Valu);
Result:= False;
end else
begin;
FastSetPixel(BitMSet, X, Y, Round(Valu - Round(Valu/2)));
Result:= True;
end;
end;

function SetFloatBMP(BitMSet, X, Y: Integer; Valu: Extended): Boolean;
Var
S, L, sValu ssValu: Extended;
begin;
If not (Valu > 16777215) Then
begin;
sValu:= Valu - Round(Valu);
ssValu:= sValu - (sValu / 2);
FastSetPixel(BitMSet, X, Y, HSLToColor(Valu, ssValu, ssValu));
Result:= False;
end else
begin;
sValu:= Valu - Round(Valu);
ssValu:= sValu - (sValu / 2);
FastSetPixel(BitMSet, X, Y, HSLToColor(Valu/2, ssValu, 0.0));
Result:= True;
end;
end;

function SetBoolBMP(BitMSet, X, Y: Integer; Valu: Boolean): Boolean;
begin;
Result:= Valu;
FastSetPixel(BitMSet, X, Y, BoolToInt(Valu));
end;

function ReadIntBMP(BitMSet, X, Y: Integer, Halved: Boolean): Integer;
begin;
If (Halved) Then
Result:= FastGetPixel(BitMSet, X, Y) * 2;
else
Result:= FastGetPixel(BitMSet, X, Y);
end;

function ReadFloatBMP(BitMSet, X, Y: Integer; Halved: Boolean): Extended;
Var H, S, L, sValu: Extended;
begin;
If (Halved) Then
begin;
ColorToHSL(FastGetPixel(BitMSet, X, Y), H, S, L);
Result:= H+S+L*2;
end else
begin;
ColorToHSL(FastGetPixel(BitMSet, X, Y), H, S, L);
Result:= H+S+L;
end;
end;

function ReadBoolBMP(BitMSet, X, Y: Integer): Boolean;
begin;
Result:= IntToBool(FastGetPixel(BitMSet, X, Y));
end;

begin;
end.

{
This agreement may be ignored for identified members of SRL-Forums.com under the discretion of R0b0t1. All members of aforementioned website under the title of SRL Member, SRL Dev, Dev, SSRL (Senior Scar Resource Library Member), Admin, or Administrator, will be excused from the above clause and instead be able to use this file without discretion of R0b0t1, but may be asked to remove said file from use if required to by request from R0b0t1.

<OWNER> = User under the alias of R0b0t1, R0b0t1, unextended family of alias R0b0t1.
<ORGANIZATION> = R0b0t1
<YEAR> = 2007

Copyright (c) <YEAR>, <OWNER>

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of the <ORGANIZATION> nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

* You may not use this software for personal gain and/or bussiness
purposes without specific prior written permision.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. }

Bam Bam

2007-09-12 18:31:02

Me thinks its funny that you put it under a license agreement.

I have a question…
What did you create this intending it to be used for?

Special Ed

2007-09-12 19:43:43

I believe he created it to be a sort of Recorder that will store variable that you tell it to into a BMP using some sort of numbering technique, which I believe develops into color when you look at the BMP.

I don't know why he's so protective of it, but it is a good idea, although just storing a text document and reading from it is less efficient but a lot easier.

pwnaz0r

2007-09-12 19:43:43

i want to know what the use of this is for

Tim0suprem0

2007-09-12 19:51:05

From: r0b0t1
Yep, posted about earlier, I'm seeing how people like it.


{
<OWNER> = User under the alias of R0b0t1
<ORGANIZATION> = R0b0t1
<YEAR> = 2007

Copyright (c) <YEAR>, <OWNER>

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of the <ORGANIZATION> nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

* You may not use this software for personal gain and/or bussiness
purposes without specific prior written permision.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. }



Paranoid much? :p





*uploads torrent*

R0b0t1

2007-09-12 20:33:16

Huh? Oh shit… Sorry, forgot to leave that out. No, im over being paranoid.


Nut yes, you store stuff in a savable bitmap.


EDIT: Added escape clause.

EDIT: No strings, that would be too slow. But it is useful for storing integers, if you haven't caught on.

EDIT: Also, legal notices are more to scare people… Piracy much?

Santa_Clause

2007-09-21 18:49:31

function IntToBool(TheInt: Integer): Boolean;
begin;
If (TheInt = 0) Then
Result:= False;
else
Result:= True;
end;

function BoolToInt(TheBool: Boolean): Integer;
begin;
If not (TheBool) Then
Result:= False;
else
Result:= True;
end;

Erm…the function is meant to return an integer but you're making it return a boolean…

R0b0t1

2007-09-21 19:31:39

Grave dig: And BrainFuck!

Santa_Clause

2007-09-21 19:35:36

9 days isn't grave-digging. And…what's with the second part?

R0b0t1

2007-09-21 19:57:16

My brain wasn't working. Lol?

Santa_Clause

2007-09-21 20:22:41

I see that happens quite a lot lately :p

You did the same thing on some other thread.

R0b0t1

2007-09-21 20:56:07

Lolzmunch