Changeset 494 for GraphicTest/Packages/bgrabitmap/blendpixelinline.inc
- Timestamp:
- Dec 22, 2016, 8:49:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/bgrabitmap/blendpixelinline.inc
r472 r494 914 914 begin 915 915 result := ((not a)*b shr 7 + a)*a div 255; 916 { SVG specification would be :917 918 if b <= 128 then919 result := a - (((256 - b-b)*a shr 8)*(not a) shr 8)920 else if a <= 64 then921 result := a + ((b+b - 256)*((((a shl 2)*(a shl 2 + 256) shr 8)*integer(a - 256) shr 8) + a*7) shr 8)922 else923 result := a + ((b+b - 255)*(ByteSqrt(a)-a) shr 8);}924 916 end; 925 917 … … 946 938 c.green * (not destalpha)) shr 8; 947 939 dest^.blue := (ByteSoftLightInline(dest^.blue, c.blue) * destalpha + 940 c.blue * (not destalpha)) shr 8; 941 dest^.alpha := c.alpha; 942 end; 943 end; 944 945 function ByteSvgSoftLightInline(a,b: byte): byte; inline; 946 begin 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; 957 end; 958 959 procedure SvgSoftLightPixelInline(dest: PBGRAPixel; c: TBGRAPixel); inline; 960 var 961 destalpha: byte; 962 begin 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 + 948 981 c.blue * (not destalpha)) shr 8; 949 982 dest^.alpha := c.alpha;
Note:
See TracChangeset
for help on using the changeset viewer.