Jump to content
Turbine1991

FindBitmap & FindDeformedBitmap not taking into consideration transparency

Recommended Posts

The last time I used the finding image functionality in an older version of SCAR there was a function solely to this.

 

I'm only guessing, but I assume the FindBitmap functions will now use any transparency in a PNG image or consider a particular colour in an image denoted to transparency.

 

Should something like this work? It's not considering the transparency at all.

procedure Example();
var
 image: TSCARBitmap;
 x, y: integer;
begin
  image := TSCARBitmap.Create('')
  image.TranspColor := RGBToColor(255, 255, 255);
  image.LoadFromBmp(ScriptPath + 'example.bmp');

  if FindBitmap(x, y, image, 0, 0, 800, 600) then
  begin
     WriteLn('Found.');
  end;
end;

 

It's just comparing the portion of the screen with this image which maintains the white areas staying white.

Edited by Turbine1991
Link to comment
Share on other sites

That's not correct no, PNg transparency is not used by FindBitmapX as it allows for semi transparency. It only works with the color set in the TranspColor property. It looks like you're doing it right though. Though it doesn't really matter, I would recommend setting the transparent color after loading the bitmap.

Link to comment
Share on other sites

The bitmap will hold the entire loaded alpha channel, and as long as TSCARBitmap.AlphaBlend is False, the alpha channel won't be reset when you assign to TranspColor. But this alpha channel is only used for alpha blended drawing. When searching for a bitmap, it'll only skip pixels of the color you've set in TranspColor, regardless of their alpha value.

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...