Jump to content
seafight17

Ckeck colour of mask(biramap mask) is pocible?

Recommended Posts

Hallo and merry christmas :)

I wonder if it pocible in scar divi after finding a "mask" in the specific cordinates to check the colour if it is yellow or red or enother colour(there are specific colour so i no need the tolerance)..ex>

 

[scar]

procedure maskcolour;

begin

If FindBitmapMaskTolerance(Mask1, x, y, skx1, sky1, skx2, sky2, masktol, maskisetol) then begin //mask in the specific search area

// and here any action that can deteck the colour the the mask

end;

end;

[/scar]

 

thank you :)

Edited by seafight17
Link to comment
Share on other sites

ok .I have a mask (bitmap) ..the sustem detect it (everything is fine till here) but then i want a reaction in case the colour of the mask(maskcolour) is ex red>153

a picture of the mask (first one the pattern//mask second and third is the 2 colour that the mask can take) .So i want to check the colour of the mask (if it is pocible).>>kkkbdf.jpg

 

Uploaded with ImageShack.us

Link to comment
Share on other sites

Wrote couple functions that will help you out with this. :)

 

function GetWhiteTPAFromMask(Mask: TSCARBitmap): TPointArray;

-Returns the white* points/pixels from Mask, as TPointArray [TPA]

* = (clWhite - 16777215)

function GetWhiteTPAFromMask(Mask: TSCARBitmap): TPointArray;
var
 client: TSCARClient;
begin
 client := SetClient(TSCARBitmapClient.Create(Mask));
 try
   FindColorEx(Result, clWhite, 0, 0, (Mask.Width - 1), (Mask.Height - 1));
 finally
   SetClient(client).Free;
 end;
end;

 

..and...

 

function FindBitmapMaskToleranceEx(Mask: TSCARBitmap; var x, y: Integer; var matchedColors: TIntArray; XS, YS, XE, YE, Tolerance, ContourTolerance: Integer): Boolean;

-Extended version of FindBitmapMaskTolerance, this version stores all the matched colors to matchedColors, as TIntArray (array of Integer).

Matched colors are the ones that are found with your masks white pixels. :)

function FindBitmapMaskToleranceEx(Mask: TSCARBitmap; var x, y: Integer; var matchedColors: TIntArray; XS, YS, XE, YE, Tolerance, ContourTolerance: Integer): Boolean;
var
 white: TPointArray;
 area: TBox;
 client: TSCARClient;
 bitmap: TSCARBitmap;
begin
 SetLength(matchedColors, 0);
 if ((XS > XE) or (YS > YE)) then
   Exit;
 area := Box(XS, YS, XE, YE);
 OffsetBox(area, -XS, -YS);
 white := GetWhiteTPAFromMask(Mask);
 bitmap := GetClient.CaptureEx(XS, YS, XE, YE);
 try
   client := SetClient(TSCARBitmapClient.Create(bitmap));
   try
     Result := FindBitmapMaskTolerance(Mask, x, y, area.X1, area.Y1, area.X2, area.Y2, Tolerance, ContourTolerance);
     if Result then
     begin         
       OffsetTPA(white, x, y);
       matchedColors := GetColors(white);
       x := (XS + x);
       y := (YS + y);
     end;       
   finally
     SetClient(client).Free;
   end;
 finally
   bitmap.Free;
 end; 
 SetLength(white, 0);        
end;

 

Included example in zip. That shows how it works. :)

Although, I included loads of unneeded data (for debugging purposes), that you wont need in your script really.

 

Hope it helps you out,

-Jani

Mask Color Matching.zip

Edited by Janilabo
Link to comment
Share on other sites

Also, seafight.. If you need more help, just ask. :P

 

If you want me to help you out a LOT more, then please upload the bitmap mask (Mask 1) here and also upload some screenshot(s) (BMP or PNG!) from in-game to webpage that doesn't convert to JPEG (like ImageShack automatically does!)

The thing is, your image lost quality because of the JPG. Colors are messed up in it now.

 

But I can tell you, I believe we can get this working for you, just the way you need it to work. :)

 

Regards,

-Jani

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...