// Compute a fixed color from a source and a target alpha public static Color Blend(this IRecieveBlenderByte blender, Color start, Color blend) { var result = new byte[] { start.blue, start.green, start.red, start.alpha }; blender.BlendPixel(result, 0, blend); return(new Color(result[2], result[1], result[0], result[3])); }
public void blend_hline(int x1, int y, int x2, RGBA_Bytes sourceColor, byte cover) { if (sourceColor.alpha != 0) { int len = x2 - x1 + 1; int bufferOffset; byte[] buffer = GetPixelPointerXY(x1, y, out bufferOffset); int alpha = (((int)(sourceColor.alpha) * (cover + 1)) >> 8); if (alpha == base_mask) { recieveBlender.CopyPixels(buffer, bufferOffset, sourceColor, len); } else { do { recieveBlender.BlendPixel(buffer, bufferOffset, new RGBA_Bytes(sourceColor.red, sourceColor.green, sourceColor.blue, alpha)); bufferOffset += m_DistanceInBytesBetweenPixelsInclusive; }while (--len != 0); } } }
public static void BasedOnAlpha(IRecieveBlenderByte recieveBlender, byte[] destBuffer, int bufferOffset, RGBA_Bytes sourceColor) { //if (sourceColor.m_A != 0) { #if false // we blend regardless of the alpha so that we can get Light Opacity working (used this way we have addative and faster blending in one blender) LBB if (sourceColor.m_A == base_mask) { Blender.CopyPixel(pDestBuffer, sourceColor); } else #endif { recieveBlender.BlendPixel(destBuffer, bufferOffset, sourceColor); } } }
public static void BasedOnAlphaAndCover(IRecieveBlenderByte recieveBlender, byte[] destBuffer, int bufferOffset, RGBA_Bytes sourceColor, int cover) { if (cover == 255) { BasedOnAlpha(recieveBlender, destBuffer, bufferOffset, sourceColor); } else { //if (sourceColor.m_A != 0) { sourceColor.alpha = (byte)((sourceColor.alpha * (cover + 1)) >> 8); #if false // we blend regardless of the alpha so that we can get Light Opacity working (used this way we have additive and faster blending in one blender) LBB if (sourceColor.m_A == base_mask) { Blender.CopyPixel(pDestBuffer, sourceColor); } else #endif { recieveBlender.BlendPixel(destBuffer, bufferOffset, sourceColor); } } } }