SRL Archive - OSR Help

Take screenshot of specific area?


Brotein

2012-02-27 00:41:11

Ok so I hope my question is simple. I want to take a screenshot of a specific area of the rs screen, lets say the inventory or chat box as an example. I looked at how FindMod works and it uses TakeScreen(), but that takes a picture of the whole screen. Any suggestions?

*To make it clear, I want this to be done by the script, not me using PrintScreen and cropping it ;) *

Er1k

2012-02-27 02:40:39

Your best bet is to store the screenshot of the picture as a bitmap, then crop the bitmap and finally save it as a bmp.

This is done in some of the debug functions in debug.simba at SRL/SRL/misc/debug.simba. I don't really know how to do it exactly, but I think there's the code you can explore.

Brotein

2012-02-27 12:57:30

Ok thanks for the tip, I'll post back if I find the answer.

Shatterhand

2012-02-27 14:02:04

I made a cool procedure for screenshots. It will make a small sized jpg file.
procedure MakeScreenShot(const FilePath : String);
var
fileName : String;
Year, Month, Day : Word;
i : Integer;
begin
if not DirectoryExists(FilePath) then
CreateDirectory(FilePath);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
fileName := ToStr(Year)+'-'+ToStr(Month)+'-'+ToStr(Day)+' ('+IntToStr(i)+')';
until not FileExists(FilePath+FileName+'.jpg')
SaveScreenShot(FilePath+FileName+'.jpg');
end;

Example:
MakeScreenShot('C:\Simba\Screenshots\');
But my problem is: SMART paints wont show up on these pictures. Any way to capture SMART paints too? I tried SaveBitmap too…

Brandon

2012-02-27 14:09:42

I currently use this to create SPS map Snippets without blurs.. U can try it and modify it so that it does the chatbox instead.. It won't be that hard.. Just some math and knowledge of TPA's and ur good to go.


program SPS_MapMaker;
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}

Procedure GetMinimap(Name: String);
var
TPA, Draw: TPointArray;
TIA: TIntegerArray;
I, BMP: Integer;
begin
BMP:= CreateBitmap(MMX2 - MMX1 + 1, MMY2 - MMY1 + 1);
TPA:= TPAFromBox(MMBox);
FilterPointsPie(TPA, 0.0, 360.0, 0.0, 75.0, MMCX, MMCY);
TIA:= GetColors(TPA);

TPA:= TPAFromBox(IntToBox(0, 0, MMX2 - MMX1, MMY2 - MMY1));
DrawTPABitmap(BMP, TPA, 16777215);
FilterPointsPie(TPA, 0.0, 360.0, 0.0, 75.0, (MMX2 - MMX1)/2, (MMY2 - MMY1)/2);

For I:= 0 To High(TPA) do
begin
SetLength(DRAW, 1);
Draw[0]:= TPA[I];
DrawTPABitmap(BMP, Draw, TIA[I]);
end;

DebugBitmap(BMP);
SaveBitmap(BMP, 'C:/Users/Brandon/Desktop/' + Name + '.bmp');
FreeBitmap(BMP);
end;

begin
SetupSRL;
GetMinimap('Testing');
end.

Shatterhand

2012-02-27 14:28:43

From: ggzz
I currently use this to create SPS map Snippets without blurs.. U can try it and modify it so that it does the chatbox instead.. It won't be that hard.. Just some math and knowledge of TPA's and ur good to go.


program SPS_MapMaker;
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}

Procedure GetMinimap(Name: String);
var
TPA, Draw: TPointArray;
TIA: TIntegerArray;
I, BMP: Integer;
begin
BMP:= CreateBitmap(MMX2 - MMX1 + 1, MMY2 - MMY1 + 1);
TPA:= TPAFromBox(MMBox);
FilterPointsPie(TPA, 0.0, 360.0, 0.0, 75.0, MMCX, MMCY);
TIA:= GetColors(TPA);

TPA:= TPAFromBox(IntToBox(0, 0, MMX2 - MMX1, MMY2 - MMY1));
DrawTPABitmap(BMP, TPA, 16777215);
FilterPointsPie(TPA, 0.0, 360.0, 0.0, 75.0, (MMX2 - MMX1)/2, (MMY2 - MMY1)/2);

For I:= 0 To High(TPA) do
begin
SetLength(DRAW, 1);
Draw[0]:= TPA[I];
DrawTPABitmap(BMP, Draw, TIA[I]);
end;

DebugBitmap(BMP);
SaveBitmap(BMP, 'C:/Users/Brandon/Desktop/' + Name + '.bmp');
FreeBitmap(BMP);
end;

begin
SetupSRL;
GetMinimap('Testing');
end.


Great idea, im working on it! Thanks! :D
EDIT: I managed to get it work, but it still wont draw the things what I painted on SMART. :(
This DebugImgForm looks cool.
procedure MakeScreenShotDebug(const FilePath : String);
var
fileName : String;
Year, Month, Day : Word;
TPA, Draw: TPointArray;
TIA: TIntegerArray;
BMP, W, H, i: Integer;
begin
GetClientDimensions(W, H);
BMP:= CreateBitmap(W, H);
TPA:= TPAFromBox(PointToBox(Point(0,0),Point(W-1,H-1)));
TIA:= GetColors(TPA);
For I:= 0 To High(TPA) do
begin
SetLength(DRAW, 1);
Draw[0]:= TPA[I];
DrawTPABitmap(BMP, Draw, TIA[I]);
end;
DebugBitmap(BMP);


if not DirectoryExists(FilePath) then
CreateDirectory(FilePath);
DecodeDate(Date,Year,Month,Day);
i := 0;
repeat
i := i+1;
fileName := ToStr(Year)+'-'+ToStr(Month)+'-'+ToStr(Day)+' ('+IntToStr(i)+')';
until not FileExists(FilePath+FileName+'.bmp')
SaveBitmap(BMP,FilePath+FileName+'.bmp');
end;

Brotein

2012-02-27 19:02:03

Yah I tried using the debug in my script as
procedure SaveProggy;
begin
SmartProggy;
wait(1000);
TakeScreenshotEx('',6,344,514,474);
TerminateScript;
end;

But it seems that anything created via paintsmart.simba will not display in that bitmap. It's a shame too, because it works perfectly except that it doesn't include what I want to be printed :(, any ideas?