public byte[] ToRGB(byte[] src, ColorSpaces color, int width, int height) { byte[] dst = new byte[123]; return(dst); }
public static int GetHeightSubsample(this ColorSpaces colorSpace) { if (!colorSpace.IsRealPlanar()) { return(1); } return(colorSpace.HasFlag(ColorSpaces.CS_Sub_Height_1) ? 1 : (colorSpace.HasFlag(ColorSpaces.CS_Sub_Height_4) ? 4 : 2)); }
public static YUVPlanes[] GetPlanes(ColorSpaces colorSpace) { if (colorSpace.HasFlag(ColorSpaces.CS_INTERLEAVED)) { return new[] { default(YUVPlanes) } } ; return(new[] { YUVPlanes.PLANAR_Y, YUVPlanes.PLANAR_U, YUVPlanes.PLANAR_V }); }
public static dynamic GetConvertFunction(ColorSpaces colorSpace) { return(colorSpace switch { ColorSpaces.CS_BGR24 => "ConvertToRGB24", ColorSpaces.CS_BGR48 => "ConvertToRGB48", var p when p.HasFlag(ColorSpaces.CS_GENERIC_YUV420) => "ConvertToYUV420", var p when p.HasFlag(ColorSpaces.CS_GENERIC_YUV422) => "ConvertToYUV422", var p when p.HasFlag(ColorSpaces.CS_GENERIC_YUV444) => "ConvertToYUV444", _ => throw new ArgumentException("Unsupported color space with specified matrix") });
/// <summary> /// Check whether a resource name is already used in the context of this resource dictionary. /// PDF4NET uses GUIDs as resource names, but I think this weapon is to heavy. /// </summary> internal bool ExistsResourceNames(string name) { // TODO: more precise: is this page imported and is PageOptions != Replace // BUG: //if (!Owner.IsImported) // return false; // Collect all resouce names of all imported resources. if (_importedResourceNames == null) { _importedResourceNames = new Dictionary <string, object>(); if (Elements[Keys.Font] != null) { Fonts.CollectResourceNames(_importedResourceNames); } if (Elements[Keys.XObject] != null) { XObjects.CollectResourceNames(_importedResourceNames); } if (Elements[Keys.ExtGState] != null) { ExtGStates.CollectResourceNames(_importedResourceNames); } if (Elements[Keys.ColorSpace] != null) { ColorSpaces.CollectResourceNames(_importedResourceNames); } if (Elements[Keys.Pattern] != null) { Patterns.CollectResourceNames(_importedResourceNames); } if (Elements[Keys.Shading] != null) { Shadings.CollectResourceNames(_importedResourceNames); } if (Elements[Keys.Properties] != null) { Properties.CollectResourceNames(_importedResourceNames); } } return(_importedResourceNames.ContainsKey(name)); // This is superfluous because PDFsharp resource names cannot be double. // importedResourceNames.Add(name, null); }
private int[] GetHistogram(IEnumerable <VideoFrame> frames, VideoFrame maskFrame, int pixelSize, int channel, YUVPlanes plane, ColorSpaces pixelType, int bits, bool limitedRange) { var hist = new int[1 << bits]; var chroma = plane == YUVPlanes.PLANAR_U || plane == YUVPlanes.PLANAR_V; var widthMult = chroma ? pixelType.GetWidthSubsample() : 1; var heightMult = chroma ? pixelType.GetHeightSubsample() : 1; var maskPitch = maskFrame?.GetPitch() * heightMult ?? 0; var maskPtr = maskFrame?.GetReadPtr() + channel ?? IntPtr.Zero; foreach (var frame in frames) { NativeUtils.FillHistogram(hist, frame.GetRowSize(plane), frame.GetHeight(plane), channel, frame.GetReadPtr(plane), frame.GetPitch(plane), pixelSize, maskPtr, maskPitch, widthMult); } if (limitedRange) { var min = GetLowColor(bits); for (var color = 0; color < min; color++) { hist[min] += hist[color]; hist[color] = 0; } var max = GetHighColor(bits, plane); for (var color = max + 1; color < 1 << bits; color++) { hist[max] += hist[color]; hist[color] = 0; } } return(GetUniHistogram(hist)); }
public static ColorSpaces ChangeBitDepth(this ColorSpaces colorSpace, int depth) { var en = bitDepths.First(p => p.Value == depth).Key; return((colorSpace & ~ColorSpaces.CS_Sample_Bits_Mask) | en); }
public static int GetBitDepth(this ColorSpaces colorSpace) { return(bitDepths.First(p => colorSpace.HasFlag(p.Key)).Value); }
public static int GetHeightSubsample(this ColorSpaces colorSpace) { return(colorSpace.HasFlag(ColorSpaces.CS_Sub_Height_1) ? 1 : (colorSpace.HasFlag(ColorSpaces.CS_Sub_Height_4) ? 4 : 2)); }
public static int GetWidthSubsample(this ColorSpaces colorSpace) { return(colorSpace.HasFlag(ColorSpaces.CS_Sub_Width_1) ? 1 : (colorSpace.HasFlag(ColorSpaces.CS_Sub_Width_4) ? 4 : 2)); }
public static bool WithoutSubSample(this ColorSpaces colorSpace) { return(colorSpace.GetSubSample() == NO_SUB_SAMPLE); }
public static Size GetSubSample(this ColorSpaces colorSpace) { return(new Size(colorSpace.GetWidthSubsample(), colorSpace.GetHeightSubsample())); }
public static bool IsRealPlanar(this ColorSpaces pixelType) { return(pixelType.HasFlag(ColorSpaces.CS_PLANAR) && !pixelType.HasFlag(ColorSpaces.CS_INTERLEAVED)); //Y8 is interleaved }
public static Color ToColor(double x, double y, double z, ColorSpaces colorSpace) { switch (colorSpace) { case ColorSpaces.HSV: return HsvToRgb(x,y,z); case ColorSpaces.HSL: return HslToRgb(x,y,z); case ColorSpaces.XYZ: return XyzToRgb(x,y,z); case ColorSpaces.Lab: return LabToRgb(z,x/360.0,y); default: return System.Drawing.Color.White; } }