SRL Archive - SRL Snippets

rs_TakeScreenShot


Olly

2013-01-20 00:08:33

Mostly for the lazy as people don't like uploading screenshots (of scripts shutting down) because they have to remove everything. So this does it for you maybe it will encourage people to upload more.

How it saves:

Code(isn't the "cleanest" but it does the job):
function rs_TakeScreen(s: string): Integer;
var
tpa: TPointArray;
TIA, TIA2, TIA3: TIntegerArray;
w, h: integer;
atpa: T2DPointArray;
TPA2: TPointArray;
begin
result := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
setBitmapSize(result, 673, 350);
setLength(atpa, 3);

TPAFromBoxWrap(mmBox, atpa[0]);
FilterPointsDist(atpa[0], 0, 76, MMCX, MMCY);
TPAFromBoxWrap(IntToBox(MSCX - 13, MSCY - 20, MSCX + 13, MSCY + 20), ATPA[1]);
TPAFromTextWrap(s, statchars, w, h, atpa[2]);

GetColorsWrap(atpa[0], TIA);
TIA2 := ColorsFromTPA(ATPA[1], clRed);
TIA3 := ColorsFromTPA(ATPA[2], clRed);
OffsetTPA(atpa[0], Point(-35, -6));
OffsetTPA(atpa[2], Point(2, +336))
MergeATPAWrap(ATPA, TPA);

try
fastSetPixels(result, TPA, TIA+TIA2+TIA3);
except
writeln('rs_TakeScreen: Failed to set pixels, prehaps shutdown reason is too long!');
end;
end;

procedure rs_SaveScreenshot(reason, savePath: string);
var
bmp, x: Integer;
begin
if (not(loggedIn)) then
Exit;

bmp := rs_TakeScreen(reason);
if FileExists(savePath + ' [' + ToStr(x) +']' + '.png') then
while FileExists(savePath + ' [' + ToStr(x) + ']' + '.png') do
Inc(x);

try
SaveBitmap(bmp, savePath + ' [' + ToStr(x) + ']' + '.png');
except
writeln('rs_TakeScreenshot: Failed saving screenshot');
finally
FreeBitmap(bmp);
end;
end;

procedure shutdown(s: string);
var
path, name: string;
begin
path := AppPath + 'Scripts\OllysGnomeAgility\';
name := 'Shutdown - '+ TheDate(Date_Day)+ ' ';
rs_SaveScreenshot(s, Path + Name);
end;

Gucci

2013-01-20 00:10:42

Very nice Olly

DannyRS

2013-01-20 00:55:37

How does logplayerin include take one of the ip log?

Very nice snippet thanks a bunch olly, another good DeBug snippet from you to add to the list ;)

Chris!

2013-01-20 01:43:01

Very nice. Will use.

Olly

2013-01-20 10:33:35

From: DannyRS
How does logplayerin include take one of the ip log?

Very nice snippet thanks a bunch olly, another good DeBug snippet from you to add to the list ;)


There's multiple other functions to take screenshots but this one just hides everything for people who like to cover everything up haha.

Olly

2013-02-03 00:13:23

Updated the function, now its a lot cleaner :p

footballjds

2014-01-21 13:16:22

thanks olly! I'll add this to my divination script so that i can get decent bug reports. i'm going to add to the function so it gets the mouse position and paints it AND writes the coordinates.

Olly

2014-01-21 13:20:04

This is oldddd :p

Kevin

2014-01-21 13:30:24

From: footballjds
thanks olly! I'll add this to my divination script so that i can get decent bug reports. i'm going to add to the function so it gets the mouse position and paints it AND writes the coordinates.


It'll need a RS3 update, I believe :p

footballjds

2014-01-21 14:08:06

From: Kevin
It'll need a RS3 update, I believe :p


well, I'll get the snippet converted before RJJ finishes taking a screenshot!

Olly

2014-01-21 16:11:06

Heres something i put together for RS3.

procedure takeScreen(reason: string);

procedure blur(bmp, xs, ys, xe, ye: integer);
var
bmpCopy, tmp: integer;
begin
bmpCopy := copyBitmap(bmp);
cropBitmap(bmpCopy, xs, ys, xe, ye);

tmp := convoluteBitmap(bmpCopy, gaussMatrix(6, 3.00));
fastDrawTransparent(xs, ys, tmp, bmp);
freeBitmaps([bmpCopy, tmp]);
end;

var
bmpClient, w, h, i: integer;
areas: TBoxArray;
begin
getClientDimensions(w, h);
bmpClient := bitmapFromClient(0, 0, w-1, h-1);

areas := [[actionBar.x1, actionbar.y1, chatBox.x2, chatBox.y2], mainScreen.playerBox,
[tabBackpack.x1-4, tabBackpack.y2 - 40, tabBackpack.x2, tabBackpack.y2],
[mainScreen.x2 - 130, mainScreen.y1, mainScreen.x2, mainScreen.y1 + 75]];

for i := 0 to high(areas) do
blur(bmpClient, areas[i].x1, areas[i].y1, areas[i].x2, areas[i].y2);

getMufasaBitmap(bmpClient).drawClippedText('Reason: ' + reason, point(chatBox.x1 + 5, chatBox.y2 - 16), StatChars, true, clLime);

debugBitmap(bmpClient);
freeBitmap(bmpClient);
end;


Hoodz

2014-01-21 18:09:19

What about osr :(

Kyle

2014-01-22 21:39:37

From: hoodz
What about osr :(


SaveScreenshot('filename')

Saves to Simba/