Wanted Posted October 8, 2014 Share Posted October 8, 2014 It used to be CopyClientToBitmap SetTargetDC(GetBitmapDC(Bitmap)); In older SCARs but now in newer SCARs we have FindBitmapColor etc. Problem is I need to do OCR on a bitmap I'm guessing I do SetClient.Capture/Ex to get the bitmap but for the TargetDC I can't seem to find anything that will work for my purpose. Granted I gave up after about 30 minutes. I need this because OldSchoolRunescape HP colors change and in order to use it with GetTextAtEx properly I have to know the exact color it is. Which isn't usually a problem unless the client changes during this process so the color I grab from tolerance+GetColor changes because it's at a different location (extremely rare, I think). -1 color input for GetText will work but then it gives me extra digits at the end which make results inaccurate. Another note. I noticed GetUpTextAt etc. was removed SCAR... I understand that RS3 doesn't have it anymore but RS07 clearly does. Would be nice to use SCAR 3.40 for scripts that need UpText/ChooseOption for RS07.. Wondering what I'm doing back? I'm posting another thread soon... stay tuned Quote Link to comment Share on other sites More sharing options...
Neron Posted October 8, 2014 Share Posted October 8, 2014 (edited) It used to be CopyClientToBitmap SetTargetDC(GetBitmapDC(Bitmap)); In older SCARs but now in newer SCARs we have FindBitmapColor etc. Problem is I need to do OCR on a bitmap I'm guessing I do SetClient.Capture/Ex to get the bitmap but for the TargetDC I can't seem to find anything that will work for my purpose. Granted I gave up after about 30 minutes. I need this because OldSchoolRunescape HP colors change and in order to use it with GetTextAtEx properly I have to know the exact color it is. Which isn't usually a problem unless the client changes during this process so the color I grab from tolerance+GetColor changes because it's at a different location (extremely rare, I think). -1 color input for GetText will work but then it gives me extra digits at the end which make results inaccurate. Another note. I noticed GetUpTextAt etc. was removed SCAR... I understand that RS3 doesn't have it anymore but RS07 clearly does. Would be nice to use SCAR 3.40 for scripts that need UpText/ChooseOption for RS07.. Wondering what I'm doing back? I'm posting another thread soon... stay tuned hi! i make this var DesktopClient : TscarWindowClient; bmpClient : tscarbitmapclient; DesktopClient := TSCARWindowClient.Create(GetDesktopWindow); procedure CopyClientToBitmap(var Bmp:TSCARBitmap;x1,y1,x2,y2 : integer); begin Bmp.Free; bmp := nil; bmp := GetClient.CaptureEx(x1,y1,x2,y2); end; procedure settargetbitmap(var bmp:Tscarbitmap); begin bmpClient := tscarbitmapclient.Create(bmp); SetClient(bmpClient); end; and back with: SetClient(DesktopClient); Edited October 8, 2014 by Neron Quote Link to comment Share on other sites More sharing options...
Wanted Posted October 8, 2014 Author Share Posted October 8, 2014 Ah yea perfect. Just came across this {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function FindBitmapColorIn(var P: TPoint; Color: LongInt; bmp: TSCARBitmap; B: TBox): Boolean; Contributors: Wanted, Janilabo. Description: Finds color on bitmap inside area. Date Created: March 7th, 2013. By Wanted Last Modified: March 7th, 2013. By Wanted =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} function FindBitmapColorIn(var P: TPoint; Color: LongInt; bmp: TSCARBitmap; B: TBox): Boolean; var Client: TSCARClient; begin Result := False; Client := SetClient(TSCARBitmapClient.Create(bmp)); try Result := FindColorP(P, Color, B); except finally SetClient(Client).Free; end; end; And others like it in Bitmap.scar aswell Forgot I helped make those a while back... Thanks for the help everyone - - - Updated - - - Update: https://github.com/OSI1/OfficialSCARInclude/commit/f89811ec583e42c3d00c6396285be930053e19a6 {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function GetMMLevel(Skill: Integer): Integer; Contributors: Wanted Description: Returns the number from the skill level on the minimap. Date Created: November 3rd, 2011. By Wanted. RS2 Build 674. Last Modified: October 8th, 2014. By Wanted. RS2 Build ???. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} function GetMMLevel(Skill: Integer): Integer; var Client: TSCARClient; bmp: TSCARBitmap; TPA: TPointArray; C: LongInt; P: TPoint; B: TBox; begin Result := -1; case Skill of Skill_Hitpoints: B := Box(522, 54, 541, 70); Skill_Prayer: B := Box(523, 100, 541, 115); Skill_Run: B := Box(544, 134, 567, 150); else Exit; end; bmp := GetClient.CaptureEx(B.X1, B.Y1, B.X2, B.Y2); Client := SetClient(TSCARBitmapClient.Create(bmp)); try if ((FindColor(P.X, P.Y, clBlack, 0, 0, Bmp.Width - 1, Bmp.Height - 1)) and (P.X > 0) and (P.Y > 0)) then C := GetColor(P.X - 1, P.Y - 1); FindColorExP(TPA, C, Box(0, 0, Bmp.Width - 1, Bmp.Height - 1)); B := TPABounds(TPA); Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1, B.Y1 - 1, 0, StatChars, False, False, 0, 2, C, 3, False, tr_Digits)), -1); except finally SetClient(Client).Free; try bmp.Free; except end; end; end; Works. Pretty sure I did it right. Quote Link to comment Share on other sites More sharing options...