CopyClientToBitmap.

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@118 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-10-08 03:54:14 +00:00
parent 2cb6eac33c
commit e9d2c0a614
6 changed files with 225 additions and 208 deletions

View File

@ -312,9 +312,13 @@ One may know DTM's as a different type:
end;
\end{verbatim}
MML provides the two functions \textbf{pDTMtoTDTM} and \textbf{TDTMtopDTM} to
The MML provides the two functions \textbf{pDTMtoTDTM} and \textbf{TDTMtopDTM} to
directly convert between the two types.
\subsection{Main Point and AreaSize / Shape}
\subsection{DTM algorithm}
\section{Bitmaps and the Bitmaps Class}

View File

@ -7,7 +7,7 @@
<TargetFileExt Value=""/>
<Title Value="Mufasa Stand Alone"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="5"/>
<ActiveEditorIndexAtStart Value="12"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -302,7 +302,7 @@
<Filename Value="../../Units/MMLCore/client.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Client"/>
<CursorPos X="36" Y="19"/>
<CursorPos X="69" Y="8"/>
<TopLine Value="1"/>
<EditorIndex Value="4"/>
<UsageCount Value="141"/>
@ -313,7 +313,7 @@
<IsPartOfProject Value="True"/>
<UnitName Value="MufasaTypes"/>
<CursorPos X="37" Y="54"/>
<TopLine Value="39"/>
<TopLine Value="37"/>
<EditorIndex Value="3"/>
<UsageCount Value="141"/>
<Loaded Value="True"/>
@ -339,7 +339,7 @@
<UnitName Value="Window"/>
<CursorPos X="30" Y="458"/>
<TopLine Value="427"/>
<EditorIndex Value="6"/>
<EditorIndex Value="7"/>
<UsageCount Value="141"/>
<Loaded Value="True"/>
</Unit41>
@ -406,8 +406,8 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/>
<CursorPos X="34" Y="114"/>
<TopLine Value="101"/>
<CursorPos X="31" Y="135"/>
<TopLine Value="120"/>
<EditorIndex Value="10"/>
<UsageCount Value="130"/>
<Loaded Value="True"/>
@ -517,9 +517,9 @@
</Unit65>
<Unit66>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<CursorPos X="60" Y="12"/>
<TopLine Value="1"/>
<EditorIndex Value="11"/>
<CursorPos X="37" Y="61"/>
<TopLine Value="51"/>
<EditorIndex Value="12"/>
<UsageCount Value="39"/>
<Loaded Value="True"/>
</Unit66>
@ -539,9 +539,11 @@
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="bitmaps"/>
<CursorPos X="31" Y="430"/>
<TopLine Value="419"/>
<CursorPos X="50" Y="83"/>
<TopLine Value="63"/>
<EditorIndex Value="5"/>
<UsageCount Value="120"/>
<Loaded Value="True"/>
</Unit69>
<Unit70>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-image/src/fpcanvas.pp"/>
@ -559,9 +561,11 @@
<Unit72>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/bitmap.inc"/>
<IsPartOfProject Value="True"/>
<CursorPos X="11" Y="61"/>
<TopLine Value="65"/>
<CursorPos X="32" Y="96"/>
<TopLine Value="75"/>
<EditorIndex Value="11"/>
<UsageCount Value="119"/>
<Loaded Value="True"/>
</Unit72>
<Unit73>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-image/src/fpcanvas.inc"/>
@ -846,9 +850,9 @@
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dtm"/>
<CursorPos X="36" Y="384"/>
<TopLine Value="641"/>
<EditorIndex Value="5"/>
<CursorPos X="39" Y="401"/>
<TopLine Value="384"/>
<EditorIndex Value="6"/>
<UsageCount Value="77"/>
<Loaded Value="True"/>
</Unit115>
@ -865,7 +869,7 @@
<UnitName Value="colourpicker"/>
<CursorPos X="53" Y="33"/>
<TopLine Value="15"/>
<EditorIndex Value="12"/>
<EditorIndex Value="13"/>
<UsageCount Value="73"/>
<Loaded Value="True"/>
</Unit117>
@ -941,9 +945,7 @@
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<CursorPos X="2" Y="23"/>
<TopLine Value="6"/>
<EditorIndex Value="13"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit127>
<Unit128>
<Filename Value="../../../../Documents/lazarus/lcl/graphics.pp"/>
@ -972,9 +974,7 @@
<UnitName Value="mmath"/>
<CursorPos X="35" Y="45"/>
<TopLine Value="14"/>
<EditorIndex Value="7"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit131>
<Unit132>
<Filename Value="../../../../Documents/fpc/rtl/objpas/types.pp"/>
@ -987,123 +987,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="8" Column="66" TopLine="1"/>
<Caret Line="8" Column="28" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="389" Column="16" TopLine="374"/>
<Caret Line="676" Column="43" TopLine="661"/>
</Position2>
<Position3>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="21" Column="28" TopLine="21"/>
<Caret Line="675" Column="29" TopLine="651"/>
</Position3>
<Position4>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="26" Column="28" TopLine="21"/>
<Caret Line="251" Column="20" TopLine="232"/>
</Position4>
<Position5>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="32" Column="30" TopLine="21"/>
<Caret Line="236" Column="38" TopLine="217"/>
</Position5>
<Position6>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="37" Column="29" TopLine="21"/>
<Caret Line="643" Column="19" TopLine="630"/>
</Position6>
<Position7>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<Caret Line="13" Column="42" TopLine="1"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<Caret Line="32" Column="36" TopLine="11"/>
</Position8>
<Position9>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<Caret Line="23" Column="50" TopLine="1"/>
</Position9>
<Position10>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="26" Column="1" TopLine="8"/>
</Position10>
<Position11>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="24" Column="41" TopLine="9"/>
</Position11>
<Position12>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="33" Column="37" TopLine="18"/>
</Position12>
<Position13>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="21" Column="32" TopLine="6"/>
</Position13>
<Position14>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="439" Column="31" TopLine="418"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="422" Column="47" TopLine="418"/>
</Position15>
<Position16>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="447" Column="34" TopLine="425"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="393" Column="3" TopLine="380"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="451" Column="43" TopLine="434"/>
</Position18>
<Position19>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="8" Column="28" TopLine="1"/>
</Position19>
<Position20>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="676" Column="43" TopLine="661"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="675" Column="29" TopLine="651"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="251" Column="20" TopLine="232"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="236" Column="38" TopLine="217"/>
</Position23>
<Position24>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="643" Column="19" TopLine="630"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="700" Column="23" TopLine="685"/>
</Position25>
<Position26>
</Position7>
<Position8>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="233" Column="44" TopLine="217"/>
</Position26>
<Position27>
</Position8>
<Position9>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="687" Column="30" TopLine="675"/>
</Position27>
<Position28>
</Position9>
<Position10>
<Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="28" Column="37" TopLine="11"/>
</Position28>
<Position29>
</Position10>
<Position11>
<Filename Value="project1.lpr"/>
<Caret Line="10" Column="71" TopLine="1"/>
</Position29>
<Position30>
</Position11>
<Position12>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="83" Column="9" TopLine="61"/>
</Position12>
<Position13>
<Filename Value="../../Units/MMLCore/client.pas"/>
<Caret Line="8" Column="69" TopLine="1"/>
</Position13>
<Position14>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="36" Column="33" TopLine="11"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="50" Column="20" TopLine="31"/>
</Position15>
<Position16>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="51" Column="61" TopLine="31"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="134" Column="22" TopLine="122"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="36" Column="33" TopLine="13"/>
</Position18>
<Position19>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="414" Column="18" TopLine="403"/>
</Position19>
<Position20>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="24" Column="28" TopLine="9"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="305" Column="16" TopLine="290"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="318" Column="18" TopLine="290"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/bitmap.inc"/>
<Caret Line="98" Column="33" TopLine="70"/>
</Position23>
<Position24>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="50" Column="20" TopLine="35"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="51" Column="61" TopLine="35"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="408" Column="43" TopLine="393"/>
</Position26>
<Position27>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="21" Column="48" TopLine="1"/>
</Position27>
<Position28>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="50" Column="20" TopLine="35"/>
</Position28>
<Position29>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="51" Column="61" TopLine="35"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="50" Column="11" TopLine="31"/>
</Position30>
</JumpHistory>
</ProjectOptions>

View File

@ -1,94 +1,104 @@
function CreateBitmap(w,h : integer):integer;
begin
result := CurrThread.Client.MBitmaps.CreateBMP(w,h);
end;
procedure FreeBitmap(Number : integer);
begin
CurrThread.Client.MBitmaps.FreeBMP(Number);
end;
procedure SaveBitmap(Bmp : integer; path : string);
begin;
CurrThread.Client.MBitmaps.Bmp[Bmp].SaveToFile(Path);
end;
function BitmapFromString(Width,height : integer; Data : string) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateBMPFromString(Width,Height,Data);
end;
function LoadBitmap(Path : String) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateBMPFromFile(Path);
end;
procedure SetBitmapSize(Bmp,NewW,NewH : integer);
begin;
if (NewW>=0) and (NewH >=0) then
CurrThread.Client.MBitmaps.Bmp[Bmp].SetSize(NewW,NewH);
end;
procedure GetBitmapSize(Bmp : integer; var BmpW,BmpH : integer);
begin;
With CurrThread.Client.MBitmaps.Bmp[bmp] do
begin;
BmpW := width;
BmpH := Height;
end;
end;
function CreateMirroredBitmap(Bmp : integer) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateMirroredBitmap(Bmp, MirrorWidth);
end;
function CreateMirroredBitmapEx(Bmp : integer; MirrorStyle : TBmpMirrorStyle) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateMirroredBitmap(Bmp,MirrorStyle);
end;
function FastGetPixel(bmp,x,y : integer) : LongWord;
begin;
Result := CurrThread.Client.MBitmaps.Bmp[Bmp].FastGetPixel(x,y);
end;
function FastGetPixels(bmp : integer; TPA : TPointArray) : TIntegerArray;
begin;
result := CurrThread.Client.MBitmaps.Bmp[Bmp].FastGetPixels(TPA);
end;
procedure FastSetPixel(Bmp,x,y : integer; Color : TColor);
begin
CurrThread.Client.MBitmaps.Bmp[bmp].FastSetPixel(x,y,color);
end;
procedure FastSetPixels(Bmp : integer; TPA : TPointArray; Colors : TIntegerArray);
begin;
CurrThread.Client.MBitmaps.Bmp[Bmp].FastSetPixels(TPA,Colors);
end;
procedure FastDrawClear(bmp : integer; Color : TColor);
begin;
CurrThread.Client.MBitmaps.Bmp[bmp].FastDrawClear(Color);
end;
procedure FastDrawTransparent(x, y: Integer; SourceBitmap, TargetBitmap: Integer);
begin;
CurrThread.Client.MBitmaps.Bmp[SourceBitmap].FastDrawTransparent(x,y,CurrThread.Client.MBitmaps.Bmp[TargetBitmap]);
end;
procedure SetTransparentColor(Bmp : integer; Color : TColor);
begin
CurrThread.Client.MBitmaps.Bmp[Bmp].SetTransparentColor(Color);
end;
function GetTransparentColor(Bmp : integer) : TColor;
begin;
Result := CurrThread.Client.MBitmaps.Bmp[bmp].GetTransparentColor;
end;
procedure FastReplaceColor(bmp: Integer; OldColor, NewColor: TColor);
begin
CurrThread.Client.MBitmaps.Bmp[Bmp].FastReplaceColor(OldColor,NewColor);
end;
function CreateBitmap(w,h : integer):integer;
begin
result := CurrThread.Client.MBitmaps.CreateBMP(w,h);
end;
procedure FreeBitmap(Number : integer);
begin
CurrThread.Client.MBitmaps.FreeBMP(Number);
end;
procedure SaveBitmap(Bmp : integer; path : string);
begin;
CurrThread.Client.MBitmaps.Bmp[Bmp].SaveToFile(Path);
end;
function BitmapFromString(Width,height : integer; Data : string) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateBMPFromString(Width,Height,Data);
end;
function LoadBitmap(Path : String) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateBMPFromFile(Path);
end;
procedure SetBitmapSize(Bmp,NewW,NewH : integer);
begin;
if (NewW>=0) and (NewH >=0) then
CurrThread.Client.MBitmaps.Bmp[Bmp].SetSize(NewW,NewH);
end;
procedure GetBitmapSize(Bmp : integer; var BmpW,BmpH : integer);
begin;
With CurrThread.Client.MBitmaps.Bmp[bmp] do
begin;
BmpW := width;
BmpH := Height;
end;
end;
function CreateMirroredBitmap(Bmp : integer) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateMirroredBitmap(Bmp, MirrorWidth);
end;
function CreateMirroredBitmapEx(Bmp : integer; MirrorStyle : TBmpMirrorStyle) : integer;
begin;
Result := CurrThread.Client.MBitmaps.CreateMirroredBitmap(Bmp,MirrorStyle);
end;
function FastGetPixel(bmp,x,y : integer) : LongWord;
begin;
Result := CurrThread.Client.MBitmaps.Bmp[Bmp].FastGetPixel(x,y);
end;
function FastGetPixels(bmp : integer; TPA : TPointArray) : TIntegerArray;
begin;
result := CurrThread.Client.MBitmaps.Bmp[Bmp].FastGetPixels(TPA);
end;
procedure FastSetPixel(Bmp,x,y : integer; Color : TColor);
begin
CurrThread.Client.MBitmaps.Bmp[bmp].FastSetPixel(x,y,color);
end;
procedure FastSetPixels(Bmp : integer; TPA : TPointArray; Colors : TIntegerArray);
begin;
CurrThread.Client.MBitmaps.Bmp[Bmp].FastSetPixels(TPA,Colors);
end;
procedure FastDrawClear(bmp : integer; Color : TColor);
begin;
CurrThread.Client.MBitmaps.Bmp[bmp].FastDrawClear(Color);
end;
procedure FastDrawTransparent(x, y: Integer; SourceBitmap, TargetBitmap: Integer);
begin;
CurrThread.Client.MBitmaps.Bmp[SourceBitmap].FastDrawTransparent(x,y,CurrThread.Client.MBitmaps.Bmp[TargetBitmap]);
end;
procedure SetTransparentColor(Bmp : integer; Color : TColor);
begin
CurrThread.Client.MBitmaps.Bmp[Bmp].SetTransparentColor(Color);
end;
function GetTransparentColor(Bmp : integer) : TColor;
begin;
Result := CurrThread.Client.MBitmaps.Bmp[bmp].GetTransparentColor;
end;
procedure FastReplaceColor(bmp: Integer; OldColor, NewColor: TColor);
begin
CurrThread.Client.MBitmaps.Bmp[Bmp].FastReplaceColor(OldColor,NewColor);
end;
procedure ps_CopyClientToBitmap(bmp, xs, ys, xe, ye: Integer);
var
mBMP: TMufasaBitmap;
begin
mBMP := CurrThread.Client.MBitmaps.GetBMP(bmp);
if mBMP = nil then
exit;
mBMP.CopyClientToBitmap(CurrThread.Client.MWindow, xs, ys, xe, ye);
end;

View File

@ -72,6 +72,7 @@ Sender.AddFunction(@FastDrawTransparent,'procedure FastDrawTransparent(x, y: Int
Sender.AddFunction(@SetTransparentColor,'procedure SetTransparentColor(bmp : integer; Color : TColor);');
Sender.AddFunction(@GetTransparentColor,'function GetTransparentColor(bmp: integer) : TColor;');
Sender.AddFunction(@FastReplaceColor,'procedure FastReplaceColor(Bmp : integer; OldColor,NewColor : TColor);');
Sender.AddFunction(@ps_CopyClientToBitmap, 'procedure CopyClientToBitmap(bmp, xs, ys, xe, ye: Integer);');

View File

@ -47,6 +47,7 @@ uses
uPSR_extctrls, //Runtime-libs
Graphics, //For Graphics types
math, //Maths!
bitmaps,
lclintf; // for GetTickCount and others.
@ -132,6 +133,7 @@ end;
// include PS wrappers
{$I PSInc/Wrappers/other.inc}
{$I PSInc/Wrappers/bitmap.inc}
{$I PSInc/Wrappers/colour.inc}
{$I PSInc/Wrappers/math.inc}
{$I PSInc/Wrappers/mouse.inc}

View File

@ -402,10 +402,10 @@ begin
B.Y2 := Max(B.Y2, dtm.p[i].Y + dtm.asz[i]);
end;
x1 += -B.X1 * 2;
y1 += -B.Y1 * 2;
X2 -= B.X2 * 2;
Y2 -= B.Y2 * 2;
x1 += -Sqr(B.X1);
y1 += -Sqr(B.Y1);
X2 -= Sqr(B.X2);
Y2 -= Sqr(B.Y2);
end;
{
Tries to find the given DTM (index). If found will put the point the dtm has