/// <summary> /// Convert a rendering mode number to an enum value /// </summary> public static FontRenderingMode GetRenderingMode(CObject number) { var mode = (int)PdfUtilities.GetDouble(number); FontRenderingMode fontRenderingMode = FontRenderingMode.Unknown; switch (mode) { case 0: fontRenderingMode = FontRenderingMode.Fill; break; case 1: fontRenderingMode = FontRenderingMode.Stroke; break; case 2: fontRenderingMode = FontRenderingMode.FillAndStroke; break; default: fontRenderingMode = FontRenderingMode.Fill; break; } return(fontRenderingMode); }
/// <summary> /// Get a brush descriptor /// </summary> public IBrushDescriptor GetBrushDescriptor(CSequence operands, Matrix matrix, double alpha) { var gray = (byte)(int)Math.Round(PdfUtilities.GetDouble(operands[0]) * 255.0); var color = Color.FromArgb((byte)(alpha * 255), gray, gray, gray); return(new GrayBrushDescriptor(color)); }
/// <summary> /// Get a matrix out of a sequence fof operands /// </summary> public static Matrix GetMatrix(CSequence operands) { var matrix = new Matrix(PdfUtilities.GetDouble(operands[0]), PdfUtilities.GetDouble(operands[1]), PdfUtilities.GetDouble(operands[2]), PdfUtilities.GetDouble(operands[3]), PdfUtilities.GetDouble(operands[4]), PdfUtilities.GetDouble(operands[5])); return(matrix); }
/// <summary> /// Get a brush descriptor /// </summary> public IBrushDescriptor GetBrushDescriptor(CSequence operands, Matrix matrix, double alpha) { float[] colorValues = new float[numberColorComponents]; for (int i = 0; i < numberColorComponents; i++) { colorValues[i] = (float)PdfUtilities.GetDouble(operands[i]); } Color color = Color.FromAValues((float)alpha, colorValues, GetProfileUri()); return(new ICCBasedBrushDescriptor(color)); }
/// <summary> /// Get a brush descriptor /// </summary> public IBrushDescriptor GetBrushDescriptor(CSequence operands, Matrix matrix, double alpha) { IBrushDescriptor altColorSpaceDescriptor = null; var values = PdfUtilities.CreateDoubleArray(operands); var altColorSpaceValues = function.Calculate(values); if (altColorSpaceValues != null) { var altColorOperands = new CSequence(); foreach (var val in altColorSpaceValues) { var real = new CReal(); real.Value = val; altColorOperands.Add(real); } altColorSpaceDescriptor = alternateColorSpace.GetBrushDescriptor(altColorOperands, matrix, alpha); } return(new DeviceNBrushDescriptor(altColorSpaceDescriptor)); }
/// <summary> /// Get a brush descriptor /// </summary> public IBrushDescriptor GetBrushDescriptor(CSequence operands, Matrix matrix, double alpha) { var values = PdfUtilities.CreateDoubleArray(operands); return(new CMYKDeviceBrushDescriptor(GetColor(values, alpha))); }