anchor.diff:    {$IFDEF FPC}
     po: TBGRABitmap;
     {$ENDIF}
  -  FileNameA: string;
  +  MaskFile: array [TMaskType] of string;
  +  MaskTyp: TMaskType;
     Transparent: Byte;
   begin
     Assert(SameText(ExtractFileExt(aFilename), '.png'));
  
positive.code:       if fRXData.HasMask[ID] and (fRXData.Mask[ID, I*SizeX + K] > 0) then
        begin
          M := fRXData.Mask[ID, I*SizeX + K];
          if fRXData.RGBA[ID, I*SizeX + K] = FLAG_COLOR_DARK then
            Png.Pixels[K,I] := M
          else
            Png.Pixels[K,I] := $FF + (255 - M) * $010100;
        end
        else
  
negative.code:       {$IFDEF WDC}
        for K := 0 to po.Height - 1 do
        for I := 0 to po.Width - 1 do
        case MaskTyp of
          mtPlain:  begin
                      //For now process just red (assume pic is greyscale)
                      fRXData.Mask[aIndex, K*po.Width+I] := po.Pixels[I,K] and $FF;
                    end;
          mtSmart:  begin
                      if Cardinal(po.Pixels[I,K] and $FFFFFF) <> 0 then
                      begin
                        Tr := fRXData.RGBA[aIndex, K*po.Width+I] and $FF;
                        Tg := fRXData.RGBA[aIndex, K*po.Width+I] shr 8 and $FF;
                        Tb := fRXData.RGBA[aIndex, K*po.Width+I] shr 16 and $FF;
  
                        //Determine color brightness
                        ConvertRGB2HSB(Tr, Tg, Tb, Thue, Tsat, Tbri);
  
                        //Make background RGBA black or white for more saturated colors
                        if Tbri < 0.5 then
                          fRXData.RGBA[aIndex, K*po.Width+I] := FLAG_COLOR_DARK
                        else
                          fRXData.RGBA[aIndex, K*po.Width+I] := FLAG_COLOR_LITE;
  
                        //Map brightness from 0..1 to 0..255..0
                        T := Trunc((0.5 - Abs(Tbri - 0.5)) * 510);
                        fRXData.Mask[aIndex, K*po.Width+I] := T;
                      end;
                   end;
          end;
        {$ENDIF}
        {$IFDEF FPC}
        for K := 0 to po.Height - 1 do
        for I := 0 to po.Width - 1 do
        case MaskTyp of
          mtPlain:  begin
                      //For now process just red (assume pic is greyscale)
                      fRXData.Mask[aIndex, K*po.Width+I] := po.GetPixel(I,K).red;
                    end;
          mtSmart:  begin
                      if Cardinal(po.GetPixel(I,K) and $FFFFFF) <> 0 then
                      begin
                        Tr := fRXData.RGBA[aIndex, K*po.Width+I] and $FF;
                        Tg := fRXData.RGBA[aIndex, K*po.Width+I] shr 8 and $FF;
                        Tb := fRXData.RGBA[aIndex, K*po.Width+I] shr 16 and $FF;
  
                        //Determine color brightness
                        ConvertRGB2HSB(Tr, Tg, Tb, Thue, Tsat, Tbri);
  
                        //Make background RGBA black or white for more saturated colors
                        if Tbri < 0.5 then
                          fRXData.RGBA[aIndex, K*po.Width+I] := FLAG_COLOR_DARK
                        else
                          fRXData.RGBA[aIndex, K*po.Width+I] := FLAG_COLOR_LITE;
  
                        //Map brightness from 0..1 to 0..255..0
                        T := Trunc((0.5 - Abs(Tbri - 0.5)) * 510);
                        fRXData.Mask[aIndex, K*po.Width+I] := T;
                      end;
                   end;
          end;
        {$ENDIF}
      end;
      po.Free;
  