Ignore:
Timestamp:
Dec 22, 2016, 8:49:19 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Updated BGRABitmap package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/bgrabitmap/blendpixelinline.inc

    r472 r494  
    914914begin
    915915  result := ((not a)*b shr 7 + a)*a div 255;
    916 { SVG specification would be :
    917 
    918   if b <= 128 then
    919     result := a - (((256 - b-b)*a shr 8)*(not a) shr 8)
    920   else if a <= 64 then
    921     result := a + ((b+b - 256)*((((a shl 2)*(a shl 2 + 256) shr 8)*integer(a - 256) shr 8) + a*7) shr 8)
    922   else
    923     result := a + ((b+b - 255)*(ByteSqrt(a)-a) shr 8);}
    924916end;
    925917
     
    946938      c.green * (not destalpha)) shr 8;
    947939    dest^.blue  := (ByteSoftLightInline(dest^.blue, c.blue) * destalpha +
     940      c.blue * (not destalpha)) shr 8;
     941    dest^.alpha := c.alpha;
     942  end;
     943end;
     944
     945function ByteSvgSoftLightInline(a,b: byte): byte; inline;
     946begin
     947  if b <= 128 then
     948    result := a - (((256 - b-b)*a shr 8)*(not a) shr 8)
     949  else
     950  begin
     951    dec(b, 128);
     952    if a <= 64 then
     953      result := a + ((b+b)   * NativeUInt(a*7 - ((a shl 2)*(a shl 2 + 256)*NativeUInt(256 - a) shr 16)) shr 8)
     954    else
     955      result := a + ((b+b+1) * NativeUInt(ByteSqrt(a)-a) shr 8);
     956  end;
     957end;
     958
     959procedure SvgSoftLightPixelInline(dest: PBGRAPixel; c: TBGRAPixel); inline;
     960var
     961  destalpha: byte;
     962begin
     963  destalpha   := dest^.alpha;
     964  if destalpha = 0 then
     965  begin
     966    dest^ := c
     967  end else
     968  if destalpha = 255 then
     969  begin
     970    dest^.red := ByteSvgSoftLightInline(dest^.red, c.red);
     971    dest^.green := ByteSvgSoftLightInline(dest^.green, c.green);
     972    dest^.blue  := ByteSvgSoftLightInline(dest^.blue, c.blue);
     973    dest^.alpha := c.alpha;
     974  end else
     975  begin
     976    dest^.red   := (ByteSvgSoftLightInline(dest^.red, c.red) * destalpha +
     977      c.red * (not destalpha)) shr 8;
     978    dest^.green := (ByteSvgSoftLightInline(dest^.green, c.green) * destalpha +
     979      c.green * (not destalpha)) shr 8;
     980    dest^.blue  := (ByteSvgSoftLightInline(dest^.blue, c.blue) * destalpha +
    948981      c.blue * (not destalpha)) shr 8;
    949982    dest^.alpha := c.alpha;
Note: See TracChangeset for help on using the changeset viewer.