mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-18 07:15:00 -05:00
Added CreateBitmapString which turns a bitmap into a mufasa-bitmapstring ;-). And made the Bufferstring global rather than in DTM only...
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@460 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
1fb4a6d44a
commit
73a9e15650
@ -20,6 +20,11 @@
|
|||||||
|
|
||||||
Bitmap.inc for the Mufasa Macro Library
|
Bitmap.inc for the Mufasa Macro Library
|
||||||
}
|
}
|
||||||
|
function CreateBitmapString(bmp : integer) : string;
|
||||||
|
begin;
|
||||||
|
result := CurrThread.Client.MBitmaps[bmp].ToString;
|
||||||
|
end;
|
||||||
|
|
||||||
function GetMufasaBitmap(bmp : integer): TMufasaBitmap;
|
function GetMufasaBitmap(bmp : integer): TMufasaBitmap;
|
||||||
begin;
|
begin;
|
||||||
result := CurrThread.Client.MBitmaps[bmp];
|
result := CurrThread.Client.MBitmaps[bmp];
|
||||||
|
@ -179,6 +179,7 @@ AddFunction(@MaskFromText, 'function MaskFromText(text, font: String): TMask;');
|
|||||||
|
|
||||||
{Bitmaps}
|
{Bitmaps}
|
||||||
SetCurrSection('Bitmaps');
|
SetCurrSection('Bitmaps');
|
||||||
|
AddFunction(@CreateBitmapString,'function CreateBitmapString(bmp : integer) : string;');
|
||||||
AddFunction(@GetMufasaBitmap,'function GetMufasaBitmap(bmp : integer) : TMufasaBitmap;');
|
AddFunction(@GetMufasaBitmap,'function GetMufasaBitmap(bmp : integer) : TMufasaBitmap;');
|
||||||
AddFunction(@CreateBitmap,'function CreateBitmap(w,h :integer) : integer;');
|
AddFunction(@CreateBitmap,'function CreateBitmap(w,h :integer) : integer;');
|
||||||
AddFunction(@FreeBitmap,'procedure FreeBitmap(Bmp : integer);');
|
AddFunction(@FreeBitmap,'procedure FreeBitmap(Bmp : integer);');
|
||||||
|
@ -81,6 +81,7 @@ type
|
|||||||
procedure Posterize(Po : integer);overload;
|
procedure Posterize(Po : integer);overload;
|
||||||
function Copy: TMufasaBitmap;
|
function Copy: TMufasaBitmap;
|
||||||
function ToTBitmap: TBitmap;
|
function ToTBitmap: TBitmap;
|
||||||
|
function ToString : string;
|
||||||
procedure LoadFromTBitmap(bmp: TBitmap);
|
procedure LoadFromTBitmap(bmp: TBitmap);
|
||||||
procedure LoadFromRawImage(RawImage: TRawImage);
|
procedure LoadFromRawImage(RawImage: TRawImage);
|
||||||
function CreateTMask : TMask;
|
function CreateTMask : TMask;
|
||||||
@ -265,6 +266,8 @@ var
|
|||||||
DestLen : LongWord;
|
DestLen : LongWord;
|
||||||
Dest,Source : string;
|
Dest,Source : string;
|
||||||
DestPoint, Point : PByte;
|
DestPoint, Point : PByte;
|
||||||
|
MufRaw : PRGB24;
|
||||||
|
MufDest : PRGB32;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -272,35 +275,49 @@ begin
|
|||||||
if (Data <> '') and (Length(Data) <> 6) then
|
if (Data <> '') and (Length(Data) <> 6) then
|
||||||
begin;
|
begin;
|
||||||
Point := Pointer(BmpArray[Result].FData);
|
Point := Pointer(BmpArray[Result].FData);
|
||||||
if Data[1] = 'b' then
|
if (Data[1] = 'b') or (Data[1] = 'm') then
|
||||||
begin;
|
begin;
|
||||||
Source := Base64DecodeStr(Copy(Data,2,Length(Data) - 1));
|
Source := Base64DecodeStr(Copy(Data,2,Length(Data) - 1));
|
||||||
Destlen := Width * Height * 3;
|
Destlen := Width * Height * 3;
|
||||||
Setlength(Dest,DestLen);
|
Setlength(Dest,DestLen);
|
||||||
if uncompress(PChar(Dest),Destlen,pchar(Source), Length(Source)) = Z_OK then
|
if uncompress(PChar(Dest),Destlen,pchar(Source), Length(Source)) = Z_OK then
|
||||||
begin;
|
begin;
|
||||||
DestPoint := @Dest[1];
|
if data[1] = 'm' then //Our encrypted bitmap! Winnor.
|
||||||
i := 0;
|
begin
|
||||||
ii := 2;
|
MufRaw:= @Dest[1];
|
||||||
Dec(DestLen);
|
MufDest:= PRGB32(Point);
|
||||||
if DestLen > 2 then
|
for i := width * height - 1 downto 0 do
|
||||||
begin;
|
begin
|
||||||
while (ii < DestLen) do
|
MufDest[i].R:= MufRaw[i].R;
|
||||||
Begin;
|
MufDest[i].G := MufRaw[i].G;
|
||||||
Point[i]:= DestPoint[ii+2];
|
MufDest[i].B := MufRaw[i].B;
|
||||||
Point[i+1]:= DestPoint[ii+1];
|
end;
|
||||||
Point[i+2]:= DestPoint[ii];
|
end else
|
||||||
ii := ii + 3;
|
if Data[1] = 'b'then
|
||||||
i := i + 4;
|
begin
|
||||||
|
DestPoint := @Dest[1];
|
||||||
|
i := 0;
|
||||||
|
ii := 2;
|
||||||
|
Dec(DestLen);
|
||||||
|
if DestLen > 2 then
|
||||||
|
begin;
|
||||||
|
while (ii < DestLen) do
|
||||||
|
Begin;
|
||||||
|
Point[i]:= DestPoint[ii+2];
|
||||||
|
Point[i+1]:= DestPoint[ii+1];
|
||||||
|
Point[i+2]:= DestPoint[ii];
|
||||||
|
ii := ii + 3;
|
||||||
|
i := i + 4;
|
||||||
|
end;
|
||||||
|
Point[i] := DestPoint[1];
|
||||||
|
Point[i+1] := DestPoint[0];
|
||||||
|
Point[i+2] := DestPoint[ii];
|
||||||
|
end else if (Width = 1) and (Height =1 ) then
|
||||||
|
begin;
|
||||||
|
Point[0] := DestPoint[1];
|
||||||
|
Point[1] := DestPoint[0];
|
||||||
|
Point[2] := DestPoint[2];
|
||||||
end;
|
end;
|
||||||
Point[i] := DestPoint[1];
|
|
||||||
Point[i+1] := DestPoint[0];
|
|
||||||
Point[i+2] := DestPoint[ii];
|
|
||||||
end else if (Width = 1) and (Height =1 ) then
|
|
||||||
begin;
|
|
||||||
Point[0] := DestPoint[1];
|
|
||||||
Point[1] := DestPoint[0];
|
|
||||||
Point[2] := DestPoint[2];
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end else if Data[1] = 'z' then
|
end else if Data[1] = 'z' then
|
||||||
@ -448,6 +465,31 @@ begin
|
|||||||
Result.LoadFromRawImage(tr, false);
|
Result.LoadFromRawImage(tr, false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TMufasaBitmap.ToString: string;
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
DestLen : longword;
|
||||||
|
DataStr : string;
|
||||||
|
CorrectData : PRGB24;
|
||||||
|
begin
|
||||||
|
SetLength(DataStr,w*h*3);
|
||||||
|
CorrectData:= PRGB24(@DataStr[1]);
|
||||||
|
for i := w*h - 1 downto 0 do
|
||||||
|
begin
|
||||||
|
CorrectData[i].R := FData[i].R;
|
||||||
|
CorrectData[i].G := FData[i].G;
|
||||||
|
CorrectData[i].B := FData[i].B;
|
||||||
|
end;
|
||||||
|
DestLen := BufferLen;
|
||||||
|
if compress(Pchar(BufferString),destlen,PChar(DataStr),w*h*3) = Z_OK then
|
||||||
|
begin;
|
||||||
|
SetLength(DataStr,DestLen);
|
||||||
|
move(bufferstring[0],dataStr[1],DestLen);
|
||||||
|
result := 'm' + Base64EncodeStr(datastr);
|
||||||
|
SetLength(datastr,0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMufasaBitmap.LoadFromRawImage(RawImage: TRawImage);
|
procedure TMufasaBitmap.LoadFromRawImage(RawImage: TRawImage);
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -70,10 +70,6 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
private
|
private
|
||||||
Client: TObject;
|
Client: TObject;
|
||||||
|
|
||||||
// For decompressing.
|
|
||||||
BufferString: String;
|
|
||||||
|
|
||||||
DTMList: Array Of pDTM;
|
DTMList: Array Of pDTM;
|
||||||
FreeSpots: Array Of Integer;
|
FreeSpots: Array Of Integer;
|
||||||
end;
|
end;
|
||||||
@ -85,9 +81,7 @@ uses
|
|||||||
math // for max
|
math // for max
|
||||||
;
|
;
|
||||||
|
|
||||||
type
|
|
||||||
TBufferByteArray = Array[0..524287] of Byte;
|
|
||||||
PBufferByteArray = ^TBufferByteArray;
|
|
||||||
|
|
||||||
|
|
||||||
constructor TMDTM.Create(Owner: TObject);
|
constructor TMDTM.Create(Owner: TObject);
|
||||||
@ -97,7 +91,6 @@ begin
|
|||||||
|
|
||||||
SetLength(DTMList, 0);
|
SetLength(DTMList, 0);
|
||||||
SetLength(FreeSpots, 0);
|
SetLength(FreeSpots, 0);
|
||||||
SetLength(BufferString, 524288);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$DEFINE DTM_DEBUG}
|
{$DEFINE DTM_DEBUG}
|
||||||
@ -126,7 +119,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
SetLength(DTMList, 0);
|
SetLength(DTMList, 0);
|
||||||
SetLength(FreeSpots, 0);
|
SetLength(FreeSpots, 0);
|
||||||
SetLength(BufferString, 0);
|
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -170,8 +162,8 @@ begin
|
|||||||
SetLength(Source,ii);
|
SetLength(Source,ii);
|
||||||
for i := 1 to ii do
|
for i := 1 to ii do
|
||||||
Source[i] := Chr(HexToInt(S[i * 2 - 1] + S[i * 2]));
|
Source[i] := Chr(HexToInt(S[i * 2 - 1] + S[i * 2]));
|
||||||
DestLen := Length(Self.BufferString);
|
DestLen := BufferLen;
|
||||||
if uncompress(PChar(Self.Bufferstring),Destlen,pchar(Source), ii) = Z_OK then
|
if uncompress(Bufferstring,Destlen,pchar(Source), ii) = Z_OK then
|
||||||
begin;
|
begin;
|
||||||
if (Destlen mod 36) > 0 then
|
if (Destlen mod 36) > 0 then
|
||||||
begin;
|
begin;
|
||||||
@ -185,7 +177,7 @@ begin
|
|||||||
SetLength(Result.asz,DestLen);
|
SetLength(Result.asz,DestLen);
|
||||||
SetLength(Result.ash,DestLen);
|
SetLength(Result.ash,DestLen);
|
||||||
SetLength(Result.bp,DestLen);
|
SetLength(Result.bp,DestLen);
|
||||||
b := @Self.Bufferstring[1];
|
b := PBufferByteArray(BufferString);
|
||||||
for i := 0 to DestLen - 1 do
|
for i := 0 to DestLen - 1 do
|
||||||
begin;
|
begin;
|
||||||
c := i * 36;
|
c := i * 36;
|
||||||
|
@ -43,7 +43,10 @@ operator + (PT1,PT2 : TPoint) : TPoint;
|
|||||||
operator - (PT1,PT2 : TPoint) : TPoint;
|
operator - (PT1,PT2 : TPoint) : TPoint;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TRGB24 = packed record
|
||||||
|
B, G, R : byte;
|
||||||
|
end;
|
||||||
|
PRGB24 = ^TRGB24;
|
||||||
TRGB32 = packed record
|
TRGB32 = packed record
|
||||||
B, G, R, A: Byte;
|
B, G, R, A: Byte;
|
||||||
end;
|
end;
|
||||||
@ -120,8 +123,13 @@ type
|
|||||||
Str : string;
|
Str : string;
|
||||||
Key : byte;
|
Key : byte;
|
||||||
end;
|
end;
|
||||||
|
type
|
||||||
|
TBufferByteArray = Array[0..524287] of Byte;
|
||||||
|
PBufferByteArray = ^TBufferByteArray;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
BufferString : PChar;
|
||||||
|
BufferLen : LongWord;
|
||||||
VirtualKeys : array[0..173] of VirtualKeyInfo = (
|
VirtualKeys : array[0..173] of VirtualKeyInfo = (
|
||||||
(str :'UNKNOWN'; key : 0),
|
(str :'UNKNOWN'; key : 0),
|
||||||
(str :'LBUTTON'; key : 1),
|
(str :'LBUTTON'; key : 1),
|
||||||
@ -313,5 +321,11 @@ begin
|
|||||||
Result.y := Pt1.y - PT2.y;
|
Result.y := Pt1.y - PT2.y;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
BufferString := StrAlloc(524288);
|
||||||
|
BufferLen := 524288;
|
||||||
|
finalization
|
||||||
|
StrDispose(bufferstring);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user