mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-14 06:10:10 -05:00
Added StretchResize
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@131 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
c73e4df23d
commit
d69697a0d7
@ -49,7 +49,17 @@ end;
|
|||||||
procedure SetBitmapSize(Bmp,NewW,NewH : integer);
|
procedure SetBitmapSize(Bmp,NewW,NewH : integer);
|
||||||
begin;
|
begin;
|
||||||
if (NewW>=0) and (NewH >=0) then
|
if (NewW>=0) and (NewH >=0) then
|
||||||
CurrThread.Client.MBitmaps.Bmp[Bmp].SetSize(NewW,NewH);
|
CurrThread.Client.MBitmaps.Bmp[Bmp].SetSize(NewW,NewH)
|
||||||
|
else
|
||||||
|
raise exception.createfmt('Wrong Width or Height in SetBitmapSize: (%d,%d)',[NewW,NewH]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure StretchBitmapResize(Bmp,NewW,NewH : integer);
|
||||||
|
begin;
|
||||||
|
if (NewW>=0) and (NewH >=0) then
|
||||||
|
CurrThread.Client.MBitmaps.Bmp[Bmp].StretchResize(NewW,NewH)
|
||||||
|
else
|
||||||
|
raise exception.createfmt('Wrong Width or Height in ScretchResize: (%d,%d)',[NewW,NewH]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure GetBitmapSize(Bmp : integer; var BmpW,BmpH : integer);
|
procedure GetBitmapSize(Bmp : integer; var BmpW,BmpH : integer);
|
||||||
|
@ -85,6 +85,7 @@ Sender.AddFunction(@BitmapFromString,'function BitmapFromString(Width,Height : i
|
|||||||
Sender.AddFunction(@LoadBitmap,'function LoadBitmap(Path : string) : integer;');
|
Sender.AddFunction(@LoadBitmap,'function LoadBitmap(Path : string) : integer;');
|
||||||
Sender.AddFunction(@SetBitmapSize,'procedure SetBitmapSize(Bmp,NewW,NewH : integer);');
|
Sender.AddFunction(@SetBitmapSize,'procedure SetBitmapSize(Bmp,NewW,NewH : integer);');
|
||||||
Sender.AddFunction(@GetBitmapSize,'procedure GetBitmapSize(Bmp : integer; Var BmpW,BmpH : integer);');
|
Sender.AddFunction(@GetBitmapSize,'procedure GetBitmapSize(Bmp : integer; Var BmpW,BmpH : integer);');
|
||||||
|
Sender.AddFunction(@StretchBitmapResize,'procedure StretchBitmapResize(Bmp,NewW,NewH : integer);');
|
||||||
Sender.AddFunction(@CreateMirroredBitmap,'function CreateMirroredBitmap(Bmp : integer) : integer;');
|
Sender.AddFunction(@CreateMirroredBitmap,'function CreateMirroredBitmap(Bmp : integer) : integer;');
|
||||||
Sender.AddFunction(@CreateMirroredBitmapEx,'function CreateMirroredBitmapEx(Bmp : integer; MirrorStyle : TBmpMirrorStyle) : integer;');
|
Sender.AddFunction(@CreateMirroredBitmapEx,'function CreateMirroredBitmapEx(Bmp : integer; MirrorStyle : TBmpMirrorStyle) : integer;');
|
||||||
Sender.AddFunction(@FastSetPixel,'procedure FastSetPixel(bmp,x,y : integer; Color : TColor);');
|
Sender.AddFunction(@FastSetPixel,'procedure FastSetPixel(bmp,x,y : integer; Color : TColor);');
|
||||||
|
@ -43,6 +43,7 @@ type
|
|||||||
Index : integer;
|
Index : integer;
|
||||||
BmpName : string; //Optional?
|
BmpName : string; //Optional?
|
||||||
procedure SetSize(AWidth,AHeight : integer);
|
procedure SetSize(AWidth,AHeight : integer);
|
||||||
|
procedure StretchResize(AWidth,AHeight : integer);
|
||||||
property Width : Integer read w;
|
property Width : Integer read w;
|
||||||
property Height : Integer read h;
|
property Height : Integer read h;
|
||||||
procedure ValidatePoint(x,y : integer);
|
procedure ValidatePoint(x,y : integer);
|
||||||
@ -58,6 +59,7 @@ type
|
|||||||
procedure FastDrawTransparent(x, y: Integer; TargetBitmap: TMufasaBitmap);
|
procedure FastDrawTransparent(x, y: Integer; TargetBitmap: TMufasaBitmap);
|
||||||
procedure FastReplaceColor(OldColor, NewColor: TColor);
|
procedure FastReplaceColor(OldColor, NewColor: TColor);
|
||||||
procedure CopyClientToBitmap(MWindow : TMWindow; xs, ys, xe, ye: Integer);
|
procedure CopyClientToBitmap(MWindow : TMWindow; xs, ys, xe, ye: Integer);
|
||||||
|
function RotatedBitmap(angle: Extended): TMufasaBitmap;
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy;override;
|
destructor Destroy;override;
|
||||||
end;
|
end;
|
||||||
@ -458,6 +460,19 @@ begin
|
|||||||
Move(PtrRet.Ptr[y * (wi + PtrRet.IncPtrWith)], FData[y * self.w],wi * SizeOf(TRGB32));
|
Move(PtrRet.Ptr[y * (wi + PtrRet.IncPtrWith)], FData[y * self.w],wi * SizeOf(TRGB32));
|
||||||
MWindow.FreeReturnData;
|
MWindow.FreeReturnData;
|
||||||
end;
|
end;
|
||||||
|
//Scar rotates unit circle-wise.. Oh, scar doesnt update the bounds, so kinda crops ur image.
|
||||||
|
function TMufasaBitmap.RotatedBitmap(angle: Extended): TMufasaBitmap;
|
||||||
|
var
|
||||||
|
NewW,NewH : integer;
|
||||||
|
MiddlePoint : TPoint;
|
||||||
|
CosAngle,SinAngle : extended;
|
||||||
|
NewCorners : array[1..4] of TPoint; //(xs,ye);(xe,ye);(xe,ys);(xe,ys)
|
||||||
|
begin
|
||||||
|
MiddlePoint := Point(w/2,h/2);
|
||||||
|
CosAngle := Cos(Angle);
|
||||||
|
SinAngle := Sin(Angle);
|
||||||
|
// NewCorners[1] := Point(-
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TMBitmaps.Create(Owner: TObject);
|
constructor TMBitmaps.Create(Owner: TObject);
|
||||||
begin
|
begin
|
||||||
@ -520,6 +535,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMufasaBitmap.StretchResize(AWidth, AHeight: integer);
|
||||||
|
var
|
||||||
|
NewData : PRGB32;
|
||||||
|
i: integer;
|
||||||
|
x,y : integer;
|
||||||
|
begin
|
||||||
|
if (AWidth <> w) or (AHeight <> h) then
|
||||||
|
begin;
|
||||||
|
if AWidth*AHeight <> 0 then
|
||||||
|
begin;
|
||||||
|
NewData := GetMem(AWidth * AHeight * SizeOf(TRGB32));
|
||||||
|
FillDWord(NewData[0],AWidth*AHeight,0);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
NewData := nil;
|
||||||
|
if Assigned(FData) and Assigned(NewData) and (w*H <> 0) then
|
||||||
|
begin;
|
||||||
|
for y := 0 to AHeight - 1 do
|
||||||
|
for x := 0 to AWidth -1 do
|
||||||
|
NewData[y*AWidth + x] := FData[((y * h)div aheight) * W+ (x * W) div awidth];
|
||||||
|
end;
|
||||||
|
if Assigned(FData) then
|
||||||
|
FreeMem(FData);
|
||||||
|
FData := NewData;
|
||||||
|
w := AWidth;
|
||||||
|
h := AHeight;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMufasaBitmap.ValidatePoint(x, y: integer);
|
procedure TMufasaBitmap.ValidatePoint(x, y: integer);
|
||||||
begin
|
begin
|
||||||
if (x <0) or (x >= w) or (y < 0) or (y >= h) then
|
if (x <0) or (x >= w) or (y < 0) or (y >= h) then
|
||||||
|
Loading…
Reference in New Issue
Block a user