PDA

View Full Version : rs_TakeScreenShot



Olly
01-20-2013, 05:08 AM
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:
http://i.imgur.com/J1k26PT.png

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
01-20-2013, 05:10 AM
Very nice Olly

DannyRS
01-20-2013, 05:55 AM
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!
01-20-2013, 06:43 AM
Very nice. Will use.

Olly
01-20-2013, 03:33 PM
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
02-03-2013, 05:13 AM
Updated the function, now its a lot cleaner :p

footballjds
01-21-2014, 06:16 PM
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
01-21-2014, 06:20 PM
This is oldddd :p

Kevin
01-21-2014, 06:30 PM
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
01-21-2014, 07:08 PM
It'll need a RS3 update, I believe :p

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

Olly
01-21-2014, 09:11 PM
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;

http://i.imgur.com/Ar9HkSv.png

Hoodz
01-21-2014, 11:09 PM
What about osr :(

Kyle
01-23-2014, 02:39 AM
What about osr :(

SaveScreenshot('filename')

Saves to Simba/