Пример #1
0
   protected LeveledColor(
 ColorSpace colorSpace,
 PdfDirectObject baseObject
 )
       : base(colorSpace, baseObject)
   {
   }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderTarget" /> class.
        /// </summary>
        /// <param name="buffers">The render target buffers.</param>
        /// <param name="colorSpace">The render target color space.</param>
        /// <param name="sampling">The render target buffer sampling options.</param>
        public RenderTarget(TargetBuffers buffers = TargetBuffers.Color0, ColorSpace colorSpace = ColorSpace.Linear, Sampling sampling = Sampling.None)
        {
            if (buffers == TargetBuffers.None)
            {
                throw new ArgumentException("Render target must have at least one buffer.", nameof(buffers));
            }

            if ((buffers & TargetBuffers.Color0) == TargetBuffers.Color0)
            {
                this.Color0 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.Color1) == TargetBuffers.Color1)
            {
                this.Color1 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.Color2) == TargetBuffers.Color2)
            {
                this.Color2 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.Color3) == TargetBuffers.Color3)
            {
                this.Color3 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.DepthStencil) == TargetBuffers.DepthStencil)
            {
                this.DepthStencil = new Texture2D(null, ColorSpace.sRGB, sampling & ~Sampling.Mipmap);
            }
        }
Пример #3
0
		/// <summary>
		/// Converts the colorspace of an image (in-place)
		/// </summary>
		/// <param name="cs">Colorspace to convert into</param>
		/// <returns>Self</returns>
		public Image ChangeColorSpace(ColorSpace cs) {
			// Colorspace is already correct
			if (_cm.colorspace == cs) return this;

			byte[] ycbcr = new byte[3];
			byte[] rgb = new byte[3];

			if (_cm.colorspace == ColorSpace.RGB && cs == ColorSpace.YCbCr) {
				/*
				 *  Y' =       + 0.299    * R'd + 0.587    * G'd + 0.114    * B'd
					Cb = 128   - 0.168736 * R'd - 0.331264 * G'd + 0.5      * B'd
					Cr = 128   + 0.5      * R'd - 0.418688 * G'd - 0.081312 * B'd
				 * 
				 */

				for (int x = 0; x < width; x++)
					for (int y = 0; y < height; y++) {
						YCbCr.fromRGB(ref _raster[0][x, y], ref _raster[1][x, y], ref _raster[2][x, y]);
					}

				_cm.colorspace = ColorSpace.YCbCr;


			} else if (_cm.colorspace == ColorSpace.YCbCr && cs == ColorSpace.RGB) {

				for (int x = 0; x < width; x++)
					for (int y = 0; y < height; y++) {
						// 0 is LUMA
						// 1 is BLUE
						// 2 is RED

						YCbCr.toRGB(ref _raster[0][x, y], ref _raster[1][x, y], ref _raster[2][x, y]);
					}

				_cm.colorspace = ColorSpace.RGB;
			} else if (_cm.colorspace == ColorSpace.Gray && cs == ColorSpace.YCbCr) {
				// To convert to YCbCr, we just add two 128-filled chroma channels

				byte[,] Cb = new byte[width, height];
				byte[,] Cr = new byte[width, height];

				for (int x = 0; x < width; x++)
					for (int y = 0; y < height; y++) {
						Cb[x, y] = 128; Cr[x, y] = 128;
					}

				_raster = new byte[][,] { _raster[0], Cb, Cr };

				_cm.colorspace = ColorSpace.YCbCr;
			} else if (_cm.colorspace == ColorSpace.Gray && cs == ColorSpace.RGB) {
				ChangeColorSpace(ColorSpace.YCbCr);
				ChangeColorSpace(ColorSpace.RGB);
			} else {
				throw new Exception("Colorspace conversion not supported.");
			}

			return this;
		}
Пример #4
0
        internal static ColorRecord Load(ColorBookReader reader, ColorSpace colorSpace)
        {
            ColorRecord color = new ColorRecord();

            color.Name = StringUtil.ReadValue(reader.ReadString());
            color.Code = Encoding.ASCII.GetString(reader.ReadBytes(6));
            color.Components = BaseColorComponent.LoadComponents(reader, colorSpace);

            return color;
        }
Пример #5
0
        /// <summary>
        /// Converts the color from a particualr color space to the specified <see cref="ColorSpace"/>.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <param name="sourceColorSpace">The color space of this instance.</param>
        /// <param name="colorSpace">The color space.</param>
        /// <returns>The color converted to the specified color space.</returns>
        public static Color3 ToColorSpace(this Color3 color, ColorSpace sourceColorSpace, ColorSpace colorSpace)
        {
            // Nothing to do?
            if (sourceColorSpace == colorSpace)
            {
                return color;
            }

            return sourceColorSpace == ColorSpace.Gamma ? color.ToLinear() : color.ToSRgb();
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PortableDocumentImage" /> class.
 /// </summary>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="bitsPerComponent">The number of bits per component.</param>
 /// <param name="bits">The bits.</param>
 /// <param name="maskBits">The bits of the mask.</param>
 /// <param name="interpolate">Interpolate if set to <c>true</c>.</param>
 /// <param name="colorSpace">The color space.</param>
 public PortableDocumentImage(int width, int height, int bitsPerComponent, byte[] bits, byte[] maskBits = null, bool interpolate = true, ColorSpace colorSpace = ColorSpace.DeviceRGB)
 {
     this.Width = width;
     this.Height = height;
     this.BitsPerComponent = bitsPerComponent;
     this.ColorSpace = colorSpace;
     this.Bits = bits;
     this.MaskBits = maskBits;
     this.Interpolate = interpolate;
     this.ColorSpace = ColorSpace.DeviceRGB;
 }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Texture2D" /> class.
        /// </summary>
        /// <param name="path">The source file path.</param>
        /// <param name="colorSpace">The source image color space.</param>
        /// <param name="sampling">The sampling options.</param>
        public Texture2D(string path, ColorSpace colorSpace, Sampling sampling = Sampling.None) : base(GL.TEXTURE_2D, colorSpace, sampling)
        {
            this.Image = new TextureImage(this, GL.TEXTURE_2D);

            if (path != null)
            {
                this.Ready = this.Load(path);
            }
            else
            {
                this.Ready = Task.CompletedTask;
            }
        }
 internal static IColorComponents LoadComponents(ColorBookReader reader, ColorSpace colorSpace)
 {
     switch (colorSpace) {
         case ColorSpace.RGB:
             return ComponentRGB.Load(reader);
         case ColorSpace.CMYK:
             return ComponentCMYK.Load(reader);
         case ColorSpace.Lab:
             return ComponentLab.Load(reader);
         default:
             throw new NotSupportedException();
     }
 }
Пример #9
0
 public static ColorSpace ToColorSpace(this TextureColorSpace textureColorSpace, ColorSpace colorSpaceReference, TextureHint textureHint)
 {
     var colorSpace = colorSpaceReference;
     if (textureHint == TextureHint.Color)
     {
         if (textureColorSpace == TextureColorSpace.Linear)
         {
             colorSpace = ColorSpace.Linear;
         }
         else if (textureColorSpace == TextureColorSpace.Gamma)
         {
             colorSpace = ColorSpace.Gamma;
         }
     }
     return colorSpace;
 }
Пример #10
0
   public TextStyle(
 Font font,
 double fontSize,
 TextRenderModeEnum renderMode,
 Color strokeColor,
 ColorSpace strokeColorSpace,
 Color fillColor,
 ColorSpace fillColorSpace
 )
   {
       this.font = font;
         this.fontSize = fontSize;
         this.renderMode = renderMode;
         this.strokeColor = strokeColor;
         this.strokeColorSpace = strokeColorSpace;
         this.fillColor = fillColor;
         this.fillColorSpace = fillColorSpace;
   }
Пример #11
0
        public ColorLocation(byte r, byte g, byte b, ColorSpace cs)
        {
            R = r;
            G = g;
            B = b;

            switch (cs) {
                case ColorSpace.RGB:
                    setLocationAsRGB();
                    break;
                case ColorSpace.HSL:
                    setLocationAsHSL();
                    break;
                case ColorSpace.HSV:
                    setLocationAsHSV();
                    break;
            }
        }
Пример #12
0
        public override RenderFrame GetRenderFrame(RenderContext context)
        {
            // Get the relative frame
            var relativeFrame = context.Tags.Get(RelativeSizeSource == RenderFrameRelativeMode.Current ? RenderFrame.Current : SceneGraphicsLayer.Master);

            // Check if we need to resize it
            if (currentFrame != null && (currentFrame.Descriptor != Descriptor || currentFrame.CheckIfResizeRequired(relativeFrame) || Descriptor.Format == RenderFrameFormat.LDR && colorSpace != context.GraphicsDevice.ColorSpace))
            {
                Dispose();
            }

            // Store the colorSpace
            colorSpace = context.GraphicsDevice.ColorSpace;

            // Allocate the render frame if necessary
            // TODO: Should we use allocated shared textures from RenderContext?
            return currentFrame ?? (currentFrame = RenderFrame.New(context.GraphicsDevice, Descriptor, relativeFrame));
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextureCube" /> class.
        /// </summary>
        /// <param name="path">The asset file path.</param>
        /// <param name="colorSpace">The source image color space.</param>
        /// <param name="sampling">The sampling options.</param>
        public TextureCube(string path, ColorSpace colorSpace, Sampling sampling = Sampling.None) : base(GL.TEXTURE_CUBE_MAP, colorSpace, sampling)
        {
            this.PositiveX = new TextureImage(this, GL.TEXTURE_CUBE_MAP_POSITIVE_X);
            this.PositiveY = new TextureImage(this, GL.TEXTURE_CUBE_MAP_POSITIVE_Y);
            this.PositiveZ = new TextureImage(this, GL.TEXTURE_CUBE_MAP_POSITIVE_Z);
            this.NegativeX = new TextureImage(this, GL.TEXTURE_CUBE_MAP_NEGATIVE_X);
            this.NegativeY = new TextureImage(this, GL.TEXTURE_CUBE_MAP_NEGATIVE_Y);
            this.NegativeZ = new TextureImage(this, GL.TEXTURE_CUBE_MAP_NEGATIVE_Z);

            if (path != null)
            {
                this.Ready = this.Load(path);
            }
            else
            {
                this.Ready = Task.CompletedTask;
            }
        }
Пример #14
0
        public ColorLocation(byte r, byte g, byte b, ColorSpace cs)
        {
            R = r;
            G = g;
            B = b;

            switch (cs)
            {
            case ColorSpace.RGB:
                setLocationAsRGB();
                break;

            case ColorSpace.HSL:
                setLocationAsHSL();
                break;

            case ColorSpace.HSV:
                setLocationAsHSV();
                break;
            }
        }
Пример #15
0
 public void SetColorSpace(ColorSpace value)
 {
     #if PLATFORM_AnyCPU
     if (OperatingSystem.IsArm64)
     #endif
     #if PLATFORM_arm64 || PLATFORM_AnyCPU
     NativeMethods.ARM64.QuantizeSettings_SetColorSpace(Instance, (UIntPtr)value);
     #endif
     #if PLATFORM_AnyCPU
     else if (OperatingSystem.Is64Bit)
     #endif
     #if PLATFORM_x64 || PLATFORM_AnyCPU
     NativeMethods.X64.QuantizeSettings_SetColorSpace(Instance, (UIntPtr)value);
     #endif
     #if PLATFORM_AnyCPU
     else
     #endif
     #if PLATFORM_x86 || PLATFORM_AnyCPU
     NativeMethods.X86.QuantizeSettings_SetColorSpace(Instance, (UIntPtr)value);
     #endif
 }
        public PreviewRenderUtility()
        {
            m_PreviewScene = new PreviewScene("Preview Scene");

            var l0 = CreateLight();

            previewScene.AddGameObject(l0);
            Light0 = l0.GetComponent <Light>();

            var l1 = CreateLight();

            previewScene.AddGameObject(l1);
            Light1 = l1.GetComponent <Light>();

            Light0.color = SceneView.kSceneViewFrontLight;
            Light1.transform.rotation = Quaternion.Euler(340, 218, 177);
            Light1.color = new Color(.4f, .4f, .45f, 0f) * .7f;

            m_PixelPerfect = false;

            // Set a default background color
            defaultBackgroundColor = new Color(49.0f / 255.0f, 49.0f / 255.0f, 49.0f / 255.0f, 1.0f);
            colorSpace             = QualitySettings.activeColorSpace;
            camera.backgroundColor = colorSpace == ColorSpace.Gamma ? defaultBackgroundColor : defaultBackgroundColor.linear;

            if (Unsupported.IsDeveloperMode())
            {
                var stackTrace = new StackTrace();
                for (int i = 0; i < stackTrace.FrameCount; i++)
                {
                    var frame = stackTrace.GetFrame(i);
                    var type  = frame.GetMethod().DeclaringType;
                    if (type != null && (type.IsSubclassOf(typeof(Editor)) || type.IsSubclassOf(typeof(EditorWindow))))
                    {
                        m_Type = type.Name;
                        break;
                    }
                }
            }
        }
Пример #17
0
        public static Dictionary <string, string> CollectReferenceImagePathsFor(ColorSpace colorSpace, RuntimePlatform runtimePlatform,
                                                                                GraphicsDeviceType graphicsApi)
        {
            var result = new Dictionary <string, string>();

            if (!Directory.Exists(ReferenceImagesRoot))
            {
                return(result);
            }

            var fullPathPrefix = string.Format("{0}/{1}/{2}/{3}/", ReferenceImagesRoot, colorSpace, runtimePlatform, graphicsApi);

            foreach (var assetPath in AssetDatabase.GetAllAssetPaths()
                     .Where(p => p.StartsWith(ReferenceImagesRoot, StringComparison.OrdinalIgnoreCase))
                     .Where(p => fullPathPrefix.StartsWith(Path.GetDirectoryName(p)))
                     .OrderBy(p => p.Count(ch => ch == '/')))
            {
                // Skip directories
                if (!File.Exists(assetPath))
                {
                    continue;
                }

                var fileName = Path.GetFileNameWithoutExtension(assetPath);
                if (fileName == null)
                {
                    continue;
                }

                var texture = AssetDatabase.LoadAssetAtPath <Texture2D>(assetPath);
                if (!texture)
                {
                    continue;
                }

                result[fileName] = assetPath;
            }

            return(result);
        }
Пример #18
0
        public void PDFColorConstructor_Test()
        {
            ColorSpace cs     = ColorSpace.RGB;
            Color      c      = Color.Red;
            PDFColor   target = new PDFColor(cs, c);

            Assert.AreEqual(c, target.Color);
            Assert.AreEqual(cs, target.ColorSpace);
            Assert.AreEqual(1.0, Math.Round(target.Red.Value, 2));
            Assert.AreEqual(0.0, Math.Round(target.Green.Value, 2));
            Assert.AreEqual(0.0, Math.Round(target.Blue.Value, 2));


            cs = ColorSpace.G;
            c  = Color.Gray;

            target = new PDFColor(cs, c);
            Assert.AreEqual(cs, target.ColorSpace);
            Assert.AreEqual(c, target.Color);

            try
            {
                target = new PDFColor(ColorSpace.LAB, c);
                Assert.Fail("LAB colour space is not supported");
            }
            catch (ArgumentException)
            {
                TestContext.WriteLine("Successfully caught the exception for the HSL Color space");
            }

            try
            {
                target = new PDFColor(ColorSpace.Custom, c);
                Assert.Fail("Custom colour space is not supported");
            }
            catch (ArgumentException)
            {
                TestContext.WriteLine("Successfully caught the exception for the HSL Color space");
            }
        }
Пример #19
0
        private void ConfigureTargetTexture(int width, int height)
        {
            bool flag = false;

            if (this.m_TargetTexture && this.m_CurrentColorSpace != QualitySettings.activeColorSpace)
            {
                UnityEngine.Object.DestroyImmediate(this.m_TargetTexture);
            }
            if (!this.m_TargetTexture)
            {
                this.m_CurrentColorSpace        = QualitySettings.activeColorSpace;
                this.m_TargetTexture            = new RenderTexture(0, 0, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
                this.m_TargetTexture.name       = "GameView RT";
                this.m_TargetTexture.filterMode = FilterMode.Point;
                this.m_TargetTexture.hideFlags  = HideFlags.HideAndDontSave;
            }
            int num = Mathf.Max(1, QualitySettings.antiAliasing);

            if (this.m_TargetTexture.width != width || this.m_TargetTexture.height != height || this.m_TargetTexture.antiAliasing != num)
            {
                this.m_TargetTexture.Release();
                this.m_TargetTexture.width        = width;
                this.m_TargetTexture.height       = height;
                this.m_TargetTexture.antiAliasing = num;
                flag = true;
                if (this.m_TargetClamped)
                {
                    Debug.LogWarningFormat("GameView reduced to a reasonable size for this system ({0}x{1})", new object[]
                    {
                        width,
                        height
                    });
                }
            }
            this.m_TargetTexture.Create();
            if (flag)
            {
                this.ClearTargetTexture();
            }
        }
Пример #20
0
        internal static ImageColorSpace ToImageColorSpace(this ColorSpace colorSpace)
        {
            ValidationUtil.ValidateEnum(typeof(ColorSpace), colorSpace, nameof(colorSpace));

            switch (colorSpace)
            {
            case ColorSpace.YV12: return(ImageColorSpace.YV12);

            case ColorSpace.Uyvy: return(ImageColorSpace.Uyvy);

            case ColorSpace.Yuyv: return(ImageColorSpace.Yuyv);

            case ColorSpace.Yuv422: return(ImageColorSpace.Yuv422);

            case ColorSpace.I420: return(ImageColorSpace.I420);

            case ColorSpace.Rgb565: return(ImageColorSpace.Rgb565);

            case ColorSpace.Rgb888: return(ImageColorSpace.Rgb888);

            case ColorSpace.Argb8888: return(ImageColorSpace.Argb8888);

            case ColorSpace.Bgra8888: return(ImageColorSpace.Bgra8888);

            case ColorSpace.Rgba8888: return(ImageColorSpace.Rgba8888);

            case ColorSpace.Bgrx8888: return(ImageColorSpace.Bgrx8888);

            case ColorSpace.NV12: return(ImageColorSpace.NV12);

            case ColorSpace.NV16: return(ImageColorSpace.NV16);

            case ColorSpace.NV21: return(ImageColorSpace.NV21);

            case ColorSpace.NV61: return(ImageColorSpace.NV61);
            }

            throw new NotSupportedException($"The ColorSpace.{colorSpace.ToString()} is not supported.");
        }
Пример #21
0
        private void ConfigureTargetTexture(int width, int height)
        {
            var clearTexture = false;

            // Changing color space requires destroying the entire RT object and recreating it
            if (m_TargetTexture && m_CurrentColorSpace != QualitySettings.activeColorSpace)
            {
                DestroyImmediate(m_TargetTexture);
            }
            if (!m_TargetTexture)
            {
                m_CurrentColorSpace        = QualitySettings.activeColorSpace;
                m_TargetTexture            = new RenderTexture(0, 0, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
                m_TargetTexture.name       = "GameView RT";
                m_TargetTexture.filterMode = FilterMode.Point;
                m_TargetTexture.hideFlags  = HideFlags.HideAndDontSave;
            }

            // Changes to these attributes require a release of the texture
            if (m_TargetTexture.width != width || m_TargetTexture.height != height)
            {
                m_TargetTexture.Release();
                m_TargetTexture.width        = width;
                m_TargetTexture.height       = height;
                m_TargetTexture.antiAliasing = 1;
                clearTexture = true;
                if (m_TargetClamped)
                {
                    Debug.LogWarningFormat("GameView reduced to a reasonable size for this system ({0}x{1})", width, height);
                }
            }

            m_TargetTexture.Create();

            if (clearTexture)
            {
                ClearTargetTexture();
            }
        }
Пример #22
0
        public void SetColorSpace(ColorSpace colorSpace)
        {
            if (handle == Types.INVALID_HANDLE)
            {
                return;
            }

            int val = 0;

            switch (colorSpace)
            {
            case ColorSpace.Gamma:
                val = HvrPlayerInterfaceAPI.COLOUR_SPACE_GAMMA;
                break;

            case ColorSpace.Linear:
                val = HvrPlayerInterfaceAPI.COLOUR_SPACE_LINEAR;
                break;
            }

            HvrPlayerInterfaceAPI.Viewport_SetColourSpace(handle, val);
        }
Пример #23
0
        public void Reset()
        {
            bool disposed = this.disposed;

            if (disposed)
            {
                UIRAtlasManager.LogDisposeError();
            }
            else
            {
                UIRAtlasManager.s_MarkerReset.Begin();
                this.m_Blitter.Reset();
                this.m_UVs.Clear();
                this.m_Allocator      = new UIRAtlasAllocator(this.m_InitialSize, 4096, this.m_1SidePadding);
                this.m_ForceReblitAll = false;
                this.m_ColorSpace     = QualitySettings.activeColorSpace;
                UIRUtility.Destroy(this.atlas);
                this.atlas = null;
                UIRAtlasManager.s_MarkerReset.End();
                this.m_ResetVersion = UIRAtlasManager.s_GlobalResetVersion;
            }
        }
Пример #24
0
        public static ColorProfile GetProfile(ColorManagement colorManagement, ColorSpace colorSpace, bool isPreview = false)
        {
            if (colorManagement == null)
            {
                return(null);
            }

            switch (colorSpace)
            {
            case ColorSpace.Cmyk:
                return(colorManagement.CmykColorProfile);

            case ColorSpace.Grayscale:
                return(colorManagement.GrayscaleColorProfile);

            case ColorSpace.Rgb:
                return(isPreview ? GetSrgbProfile() : colorManagement.RgbColorProfile);

            default:
                return(null);
            }
        }
        public CWatcher(
            CWatchImage[] cWatchImages,
            string name,
            WatcherType watcherType,
            ColorSpace colorSpace,
            int channel,
            bool equalize,
            ErrorMetric errorMetric
            )
        {
            Name         = name;
            WatcherType  = watcherType;
            ColorSpace   = colorSpace;
            Channel      = channel;
            Equalize     = equalize;
            ErrorMetric  = errorMetric;
            CWatchImages = cWatchImages;

            IsStandardCheck       = WatcherType.Equals(WatcherType.Standard);
            IsDuplicateFrameCheck = WatcherType.Equals(WatcherType.DuplicateFrame);
            IsBestMatchCheck      = WatcherType.Equals(WatcherType.BestMatch);
        }
        public static void CreatePageImageBasedOnPhysicalSize(Page pg, string filename, ImageType imgtype,
                                                              ColorSpace cspace)
        {
            // Get the dimensions, in pixels, of an image that is
            // half the physical size of the page at a resolution of 96 DPI.
            // The dimensions will be stored in the PixelWidth and
            // PixelHeight fields of the PageImageParams object.
            double          scalefactor = 0.5;
            double          resolution  = 96.0;
            PageImageParams pip         = ScalePage(pg, scalefactor, resolution);

            pip.PageDrawFlags   = DrawFlags.UseAnnotFaces;
            pip.ImageColorSpace = cspace;

            // Create the image and save it to a file.
            // We want to create an image of the entire page, so we'll use the
            // page's CropBox as the exportRect.
            Image img = pg.GetImage(pg.CropBox, pip);

            img.Save(filename, imgtype);
            Console.WriteLine("Created " + filename + "...");
        }
Пример #27
0
        public bool Reload()
        {
            var result = false;

            try
            {
                if (ValidOriginal)
                {
                    if (ValidCurrent)
                    {
                        Current.Dispose(); Current = null;
                    }
                    ResetTransform();
                    Current           = new MagickImage(Original);
                    Modified          = true;
                    _last_colorspace_ = Current.ColorSpace;
                    result            = true;
                }
            }
            catch (Exception ex) { ex.ShowMessage(); }
            return(result);
        }
Пример #28
0
        private async void GameSettingsChanged(object sender, GameSettingsChangedEventArgs e)
        {
            // Remark: we assume that GameStudioDatabase has already updated the compiler game settings,
            // which is the case because this service is registered before the creation of this EditorContentLoader
            if (e.GameSettings.GetOrCreate <RenderingSettings>().ColorSpace != currentColorSpace || e.GameSettings.GetOrCreate <EditorSettings>().RenderingMode != currentRenderingMode)
            {
                currentRenderingMode = e.GameSettings.GetOrCreate <EditorSettings>().RenderingMode;
                currentColorSpace    = e.GameSettings.GetOrCreate <RenderingSettings>().ColorSpace;

                await BuildAndReloadAssets(Asset.Dependencies.ReferencedAssets.Select(x => x.AssetItem));
            }

            // Update navigation meshes that are previewed inside the current scene when the game settings's group settings for navigation meshes change
            var navigationGroupsHash = e.GameSettings.GetOrCreate <NavigationSettings>().ComputeGroupsHash();

            if (navigationGroupsHash != currentNavigationGroupsHash)
            {
                currentNavigationGroupsHash = navigationGroupsHash;

                await BuildAndReloadAssets(Session.AllAssets.Where(x => x.AssetType == typeof(NavigationMeshAsset)).Select(x => x.AssetItem));
            }
        }
Пример #29
0
 public TextStyle(
     Font font,
     double fontSize,
     TextRenderModeEnum renderMode,
     Color strokeColor,
     ColorSpace strokeColorSpace,
     Color fillColor,
     ColorSpace fillColorSpace,
     double scaleX,
     double scaleY
     )
 {
     this.font             = font;
     this.fontSize         = fontSize;
     this.renderMode       = renderMode;
     this.strokeColor      = strokeColor;
     this.strokeColorSpace = strokeColorSpace;
     this.fillColor        = fillColor;
     this.fillColorSpace   = fillColorSpace;
     this.scaleX           = scaleX;
     this.scaleY           = scaleY;
 }
Пример #30
0
        public static bool IsTextureSetupProblematic(Material material, ColorSpace colorSpace,
                                                     bool sRGBTexture, bool mipmapEnabled, bool alphaIsTransparency,
                                                     string texturePath, string materialPath,
                                                     ref string errorMessage)
        {
            if (material == null || !UsesSpineShader(material))
            {
                return(false);
            }

            bool isProblematic = false;

            if (IsPMAMaterial(material))
            {
                // 'sRGBTexture = true' generates incorrectly weighted mipmaps at PMA textures,
                // causing white borders due to undesired custom weighting.
                if (sRGBTexture && mipmapEnabled && colorSpace == ColorSpace.Gamma)
                {
                    errorMessage += string.Format("`{0}` : Problematic Texture Settings found: When enabling `Generate Mip Maps` in Gamma color space, it is recommended to disable `sRGB (Color Texture)` on `Premultiply alpha` textures. Otherwise you will receive white border artifacts on an atlas exported with default `Premultiply alpha` settings.\n(You can disable this warning in `Edit - Preferences - Spine`)\n", texturePath);
                    isProblematic = true;
                }
                if (alphaIsTransparency)
                {
                    string materialName = System.IO.Path.GetFileName(materialPath);
                    errorMessage += string.Format("`{0}` and material `{1}` : Problematic Texture / Material Settings found: It is recommended to disable `Alpha Is Transparency` on `Premultiply alpha` textures.\nAssuming `Premultiply alpha` texture because `Straight Alpha Texture` is disabled at material). (You can disable this warning in `Edit - Preferences - Spine`)\n", texturePath, materialName);
                    isProblematic = true;
                }
            }
            else               // straight alpha texture
            {
                if (!alphaIsTransparency)
                {
                    string materialName = System.IO.Path.GetFileName(materialPath);
                    errorMessage += string.Format("`{0}` and material `{1}` : Incorrect Texture / Material Settings found: It is strongly recommended to enable `Alpha Is Transparency` on `Straight alpha` textures.\nAssuming `Straight alpha` texture because `Straight Alpha Texture` is enabled at material). (You can disable this warning in `Edit - Preferences - Spine`)\n", texturePath, materialName);
                    isProblematic = true;
                }
            }
            return(isProblematic);
        }
        /// <summary>
        /// Try to convert from YCbCr to RGB colors
        /// </summary>
        /// <param name="sourceColorspace">The colorspace of the luma and chroma</param>
        /// <param name="luma">The luma plane</param>
        /// <param name="blueDifferential">The blue differential (Cb) plane</param>
        /// <param name="redDifferential">The red differential (Cr) plane</param>
        /// <param name="width">The width of the frame</param>
        /// <param name="height">The height of the frame</param>
        /// <returns>An RGB plane if this function succeeds. None otherwise</returns>
        /// <remarks>
        /// FFMPEG outputs 420mpeg2 (where the chroma samples are aligned horizontally, but 
        /// shifted a half-pixel down).
        /// https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx
        /// </remarks>
        public static Maybe<Color[][]> TryConvertFrameToRGB(
            ColorSpace sourceColorspace,
            byte[][] luma,
            byte[][] blueDifferential,
            byte[][] redDifferential,
            int width,
            int height
        )
        {
            var inFrames = new YCrCbFrame
            {
                ColorSpace = sourceColorspace,
                Luma = luma,
                Cb = blueDifferential,
                Cr = redDifferential,
                Width = width,
                Height = height,
            };
            if (Equals(sourceColorspace, ColorSpace.FourFourFour))
            {
                return TryConvertYCbCr444ToRGB(inFrames);
            }

            if (Equals(sourceColorspace, ColorSpace.FourTwoTwo))
            {
                return from horizontalUpconvert in TryConvert422To444(inFrames)
                       select TryConvertYCbCr444ToRGB(horizontalUpconvert);
            }

            if (Equals(sourceColorspace, ColorSpace.FourTwoZeroMpeg2))
            {
                return from verticalUpconvert in TryConvert420To422(inFrames)
                       from horizontalUpconvert in TryConvert422To444(verticalUpconvert)
                       select TryConvertYCbCr444ToRGB(horizontalUpconvert);
            }

            return Maybe<Color[][]>.Nothing;
        }
Пример #32
0
        /// <summary>
        /// Updates this instance( <see cref="Position"/>, <see cref="Direction"/>, <see cref="HasBoundingBox"/>, <see cref="BoundingBox"/>, <see cref="BoundingBoxExt"/>
        /// </summary>
        /// <param name="colorSpace"></param>
        public bool Update(ColorSpace colorSpace)
        {
            if (Type == null || !Enabled || !Type.Update(this))
            {
                return(false);
            }

            // Compute light direction and position
            Vector3 lightDirection;
            var     lightDir = DefaultDirection;

            Vector3.TransformNormal(ref lightDir, ref Entity.Transform.WorldMatrix, out lightDirection);
            lightDirection.Normalize();

            Position  = Entity.Transform.WorldMatrix.TranslationVector;
            Direction = lightDirection;

            // Color
            var colorLight = Type as IColorLight;

            Color = (colorLight != null) ? colorLight.ComputeColor(colorSpace, Intensity) : new Color3();

            // Compute bounding boxes
            HasBoundingBox = false;
            BoundingBox    = new BoundingBox();
            BoundingBoxExt = new BoundingBoxExt();

            var directLight = Type as IDirectLight;

            if (directLight != null && directLight.HasBoundingBox)
            {
                // Computes the bounding boxes
                BoundingBox    = directLight.ComputeBounds(Position, Direction);
                BoundingBoxExt = new BoundingBoxExt(BoundingBox);
            }

            return(true);
        }
Пример #33
0
        /// <summary>
        /// Texture をオリジナルのテクスチャアセット(png/jpg)ファイルのバイト列そのまま出力してよいかどうか判断する。
        /// 具体的な条件は以下
        ///
        /// * TextureAsset が存在する
        /// * TextureImporter の maxSize が画像の縦横サイズ以上
        /// * TextureImporter の色空間設定が exportColorSpace と一致する
        /// * 各 Texture Type ごとの判定
        ///
        /// Unity の Texture2D のデータは、その参照元であるテクスチャアセットファイルのデータと一致することはむしろ稀。
        /// </summary>
        public bool CanExportAsEditorAssetFile(Texture texture, ColorSpace exportColorSpace)
        {
            // Exists as UnityEditor Texture2D Assets ?
            if (!EditorTextureUtility.TryGetAsEditorTexture2DAsset(texture, out var texture2D, out var textureImporter))
            {
                return(false);
            }

            // Maintain original width/height ?
            if (!IsTextureSizeMaintained(textureImporter))
            {
                return(false);
            }

            // Equals color space ?
            if (!IsFileColorSpaceSameWithExportColorSpace(textureImporter, exportColorSpace))
            {
                return(false);
            }

            // Each Texture Importer Type Validation
            switch (textureImporter.textureType)
            {
            case TextureImporterType.Default:
                break;

            case TextureImporterType.NormalMap:
                // A texture has "Normal map" TextureType is ALWAYS converted into normalized normal pixel by Unity.
                // So we must copy it.
                return(false);

            default:
                // Not Supported TextureImporterType
                throw new ArgumentOutOfRangeException();
            }

            return(true);
        }
Пример #34
0
		public void SetColorSpace(ColorSpace colorSpace, bool isCombined = false)
		{
			ColorSpace oldval = ColorSpace;
			ColorSpace newval = colorSpace;
			
			if (oldval == newval) return;
			
			var cmd = new Command.DelegateCommand(
				() =>
				{
					_colorSpace = newval;
					CallChangedColorSpace(false, ChangedValueType.Execute);
				},
				() =>
				{
					_colorSpace = oldval;
					CallChangedColorSpace(false, ChangedValueType.Unexecute);
				},
				this,
				isCombined);

			Command.CommandManager.Execute(cmd);
		}
Пример #35
0
        private static double Convert(double c, ColorSpace sourceSpace, ColorSpace targetSpace)
        {
            // Convert source space --> sRGB --> target space.
            switch (sourceSpace)
            {
                case ColorSpace.SRgb:
                    break;
                case ColorSpace.Linear:
                    c = ColorHelper.ToSRgb(c);
                    break;
            }

            switch (targetSpace)
            {
                case ColorSpace.SRgb:
                    break;
                case ColorSpace.Linear:
                    c = ColorHelper.ToLinear(c);
                    break;
            }

            return c;
        }
    public void IssueRenderThread()
    {
        if (canConnecttoActivity && !isInitrenderThread)
        {
            ColorSpace colorSpace = QualitySettings.activeColorSpace;
            if (colorSpace == ColorSpace.Gamma)
            {
                Pvr_UnitySDKAPI.Render.UPvr_SetColorspaceType(0);
            }
            else if (colorSpace == ColorSpace.Linear)
            {
                Pvr_UnitySDKAPI.Render.UPvr_SetColorspaceType(1);
            }

            Pvr_UnitySDKPluginEvent.Issue(RenderEventType.InitRenderThread);
            isInitrenderThread = true;
            Debug.Log("IssueRenderThread end");
        }
        else
        {
            Debug.Log("IssueRenderThread  canConnecttoActivity = " + canConnecttoActivity);
        }
    }
Пример #37
0
 public static int fromColor(ColorSpace color)
 {
     if (color == ColorSpace.MONO)
     {
         return(0);
     }
     else if (color == ColorSpace.YUV420)
     {
         return(1);
     }
     else if (color == ColorSpace.YUV422)
     {
         return(2);
     }
     else if (color == ColorSpace.YUV444)
     {
         return(3);
     }
     else
     {
         throw new Exception("Colorspace not supported");
     }
 }
Пример #38
0
        private int ExtractComponents(IntPtr colorID, ColorSpace colorSpace, ref byte c0, ref byte c1, ref byte c2, ref byte c3, ref byte gamutFlag)
        {
            if (!IsValidColorSpace(colorSpace))
            {
                return(PSError.kSPBadParameterError);
            }

            Color item = colors[colorID];

            c0 = item.Component0;
            c1 = item.Component1;
            c2 = item.Component2;
            c3 = item.Component3;

            int error = PSError.kSPNoError;

            if (item.ColorSpace != colorSpace)
            {
                error = ColorServicesConvert.Convert(item.ColorSpace, colorSpace, ref c0, ref c1, ref c2, ref c3);
            }

            return(error);
        }
Пример #39
0
 /// <summary>
 /// Converts the color to a floating point representation in the target color space.
 /// </summary>
 /// <param name="color">The color.</param>
 /// <param name="colorSpace">The target color space.</param>
 /// <returns>The floating point representation.</returns>
 public static Vector4 ToVector4(this Color color, ColorSpace colorSpace = ColorSpace.sRGB)
 {
     if (colorSpace == ColorSpace.sRGB)
     {
         return new Vector4
         {
             X = color.R / 255f,
             Y = color.G / 255f,
             Z = color.B / 255f,
             W = color.A / 255f,
         };
     }
     else
     {
         return new Vector4
         {
             X = ToLinear(color.R),
             Y = ToLinear(color.G),
             Z = ToLinear(color.B),
             W = color.A / 255f,
         };
     }
 }
Пример #40
0
        public static int CalculateBufferSize(Size resolution, ColorSpace colorSpace)
        {
            if (resolution.Width <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(resolution), resolution.Width,
                                                      "width can't be less than or equal to zero.");
            }
            if (resolution.Height <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(resolution), resolution.Height,
                                                      "height can't be less than or equal to zero.");
            }

            ValidationUtil.ValidateEnum(typeof(ColorSpace), colorSpace, nameof(colorSpace));

            uint bufferSize;

            global::Interop.ImageUtil.CalculateBufferSize(resolution.Width, resolution.Height,
                                                          colorSpace.ToImageColorSpace(), out bufferSize)
            .ThrowIfFailed("Failed to calculate buffer size for given parameter");

            return((int)bufferSize);
        }
Пример #41
0
        public UGCanvasRenderTarget(UGSize canvasSize, float scale)
        {
            Size  = canvasSize;
            Scale = scale;

            var    width  = (int)(scale * Width + .5F);
            var    height = (int)(scale * Height + .5F);
            Bitmap native;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                using (var colorSpace = ColorSpace.Get(ColorSpace.Named.Srgb))
                {
                    native = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888, true, colorSpace);
                }
            }
            else
            {
                native = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
            }
            native.Density = (int)(160F * Scale + .5F);
            _native        = native;
        }
Пример #42
0
        private unsafe int ExtractComponents(ColorID colorID, ColorSpace colorSpace, byte *c0, byte *c1, byte *c2, byte *c3, byte *gamutFlag)
        {
            if (!IsValidColorSpace(colorSpace) || c0 == null || c1 == null || c2 == null || c3 == null)
            {
                return(PSError.kSPBadParameterError);
            }

            Color item = colors[colorID];

            *c0 = item.Component0;
            *c1 = item.Component1;
            *c2 = item.Component2;
            *c3 = item.Component3;

            int error = PSError.kSPNoError;

            if (item.ColorSpace != colorSpace)
            {
                error = ColorServicesConvert.Convert(item.ColorSpace, colorSpace, ref *c0, ref *c1, ref *c2, ref *c3);
            }

            return(error);
        }
Пример #43
0
 public ExtraVideoInfo(VideoInfo info)
 {
     Width       = info.width;
     Height      = info.height;
     Size        = new Size(Width, Height);
     Area        = Width * Height;
     AspectRatio = (double)Width / Height;
     ColorSpace  = info.pixel_type;
     FrameCount  = info.num_frames;
     Info        = info;
     if (ColorSpace.IsRealPlanar())
     {
         var vi = info;
         vi.width      = Width / ColorSpace.GetWidthSubsample();
         vi.height     = Height / ColorSpace.GetHeightSubsample();
         vi.pixel_type = ColorSpaces.CS_Y8;
         Chroma        = vi;
     }
     else
     {
         Chroma = this;
     }
 }
        private void CheckBoxRandom_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (CheckBoxRandom.IsChecked == true)
            {
                _isRandomMode = true;
                RectangleRandomColor1.SetBinding(Shape.FillProperty, _randomColorBinding);
                RectangleRandomColor2.SetBinding(Shape.FillProperty, _randomColorBinding);
            }
            else
            {
                _isRandomMode = false;
                CheckBoxIncrement.IsChecked = false;
                SliderA2.Value = SliderA1.Value;
                SliderB2.Value = SliderB1.Value;
                SliderC2.Value = SliderC1.Value;
                SliderD2.Value = SliderD1.Value;
                RandomColor    = ColorSpace.OpaqueBlack;
                RectangleRandomColor1.SetBinding(Shape.FillProperty, _currentColor1Binding);
                RectangleRandomColor2.SetBinding(Shape.FillProperty, _currentColor2Binding);
            }

            e.Handled = true;
        }
Пример #45
0
        public byte[] Compress(Color[] colors)
        {
            Debug.Assert(colors.Length == BlockFormat.TexelCount);

            var colorSpace = new ColorSpace(colors);
            var colorTable = BC1ColorTable.Create(colorSpace.MaxColor, colorSpace.MinColor);

            var block = new BC2BlockData();

            block.Color0 = colorTable[0];
            block.Color1 = colorTable[1];

            for (int i = 0; i < colors.Length; ++i)
            {
                var color32 = colors[i];
                var color16 = ColorUtility.To16Bit(color32);

                block.ColorIndexes[i] = ColorUtility.GetIndexOfClosestColor(colorTable, color16);
                block.ColorAlphas[i]  = color32.A >> 4; // Convert 8-bit alpha to 4-bit
            }

            return(block.ToBytes());
        }
Пример #46
0
        /// <summary>
        ///     Constructs a new FonetImage using the supplied bitmap.
        /// </summary>
        /// <remarks>
        ///     Does not hold a reference to the passed bitmap.  Instead the
        ///     image data is extracted from <b>bitmap</b> on construction.
        /// </remarks>
        /// <param name="href">The location of <i>bitmap</i></param>
        /// <param name="imageData">The image data</param>
        public FonetImage(string href,
                          int width,
                          int height,
                          int bitPlans,
                          byte[] imageData)
        {
            this.m_href    = href;
            this.m_bitmaps = imageData;
            this.width     = width;
            this.height    = height;



            //if (bitmap.RawFormat.Equals(ImageFormat.Jpeg))
            //    //{
            //    //    JpegParser parser = new JpegParser(m_bitmaps);
            //    //    JpegInfo info = parser.Parse();

            //    //    m_bitsPerPixel = info.BitsPerSample;
            //    //    m_colorSpace = new ColorSpace(info.ColourSpace);
            //    //    width = info.Width;
            //    //    height = info.Height;

            //    //    // A "no-op" filter since the JPEG data is already compressed
            //    //    filter = new DctFilter();
            //    //}
            //    //else
            //    //{
            //    //    ExtractOtherImageBits(bitmap);

            //    //    // Performs zip compression
            //    //    filter = new FlateFilter();
            //    //}
            //---------------------------------------------------
            m_colorSpace   = new ColorSpace(ColorSpace.DeviceRgb); //***
            m_bitsPerPixel = bitPlans;                             // DEFAULT_BITPLANES; // 8
        }
Пример #47
0
        private bool TIFFjpeg_set_colorspace(ColorSpace colorspace)
        {
            try
            {
                m_compression.jpeg_set_colorspace(colorspace);
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Пример #48
0
 public static extern unsafe int* sws_getCoefficients(ColorSpace colorspace);
Пример #49
0
	//Nav mesh settings can't be accessed via script :(

	//Lightmapping is VERY version-specific. You may have to modify the settings that are compared
	public void CaptureSettings() {
#if UNITY_5
#else
		aoAmount = LightmapEditorSettings.aoAmount;
		aoContrast = LightmapEditorSettings.aoContrast;
		bounceBoost = LightmapEditorSettings.bounceBoost;	 
		bounceIntensity = LightmapEditorSettings.bounceIntensity;
		bounces = LightmapEditorSettings.bounces;
		
		quality = LightmapEditorSettings.quality;
		skyLightColor = LightmapEditorSettings.skyLightColor;
		skyLightIntensity = LightmapEditorSettings.skyLightIntensity;

		finalGatherContrastThreshold = LightmapEditorSettings.finalGatherContrastThreshold;
		finalGatherGradientThreshold = LightmapEditorSettings.finalGatherGradientThreshold;
		finalGatherInterpolationPoints = LightmapEditorSettings.finalGatherInterpolationPoints;
		finalGatherRays = LightmapEditorSettings.finalGatherRays;
		lastUsedResolution = LightmapEditorSettings.lastUsedResolution;
		lockAtlas = LightmapEditorSettings.lockAtlas;
#if !(UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5)
		bakedColorSpace = LightmapSettings.bakedColorSpace;
#endif
#endif
		ambientLight = RenderSettings.ambientLight;
#if UNITY_4_3 || UNITY_4_5 || UNITY_5 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3
		flareFadeSpeed = RenderSettings.flareFadeSpeed;
#endif
#if UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
#else
		lightProbes = LightmapSettings.lightProbes;
		padding = LightmapEditorSettings.padding;
#endif
		flareStrength = RenderSettings.flareStrength;
		fog = RenderSettings.fog;
		fogColor = RenderSettings.fogColor;
		fogDensity = RenderSettings.fogDensity;
		fogEndDistance = RenderSettings.fogEndDistance;
		fogMode = RenderSettings.fogMode;
		fogStartDistance = RenderSettings.fogStartDistance;
		haloStrength = RenderSettings.haloStrength;
		skybox = RenderSettings.skybox;

		lightmaps = LightmapSettings.lightmaps;
		lightmapsMode = LightmapSettings.lightmapsMode;

		aoMaxDistance = LightmapEditorSettings.aoMaxDistance;
		maxAtlasHeight = LightmapEditorSettings.maxAtlasHeight;
		maxAtlasWidth = LightmapEditorSettings.maxAtlasWidth;
		resolution = LightmapEditorSettings.resolution;
		textureCompression = LightmapEditorSettings.textureCompression;
	}
Пример #50
0
        public static PlanarImage FromBitmap(Bitmap source, PixelAlignmentType format, ColorSpace colorspace = ColorSpace.DEFAULT)
        {
            IntPtr context = SwScale.sws_getContext(source.Width, source.Height, m_rgbMapper[source.PixelFormat],
                                             source.Width, source.Height, m_pixelTypeMapper[format],
                                             SwScale.ConvertionFlags.SWS_BICUBIC, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

            int* pCoef = SwScale.sws_getCoefficients(colorspace);
            int* inv_table;
            int* table;
            int srcRange, dstRange, brightness, contrast, saturation;

            int result = SwScale.sws_getColorspaceDetails(context, out inv_table, out srcRange, out table, out dstRange, out brightness, out contrast, out saturation);
            if (result != -1)
            {
                result = SwScale.sws_setColorspaceDetails(context, pCoef, srcRange, table, dstRange, brightness, contrast, saturation);
            }

            PlanarImage yuv = new PlanarImage(source.Width, source.Height, format);
            BitmapData data = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadOnly, source.PixelFormat);

            unsafe
            {
                pInput[0] = (byte*)data.Scan0.ToPointer();
                result = SwScale.sws_scale(context, pInput, new int[] { data.Stride, 0, 0, 0 }, 0, source.Height, yuv.PixelDataPointer, yuv.Pitches);
                if (result != yuv.Height)
                {
                    throw new InvalidOperationException();
                }
            }

            source.UnlockBits(data);
            SwScale.sws_freeContext(context);
            return yuv;
        }
Пример #51
0
 public extern void ReadTextureImportInstructions(BuildTarget target, out TextureFormat desiredFormat, out ColorSpace colorSpace, out int compressionQuality);
Пример #52
0
 /// <summary>
 /// ��ColorSpace�Ƿ���ɫ������ģʽ��
 /// </summary>
 /// <param name="cs"><seealso cref="ColorSpace"/>������</param>
 /// <returns>����ColorSpace��ɫ������ģʽʱ������true�������Ƿ�ɫ������ģʽ������false��</returns>
 public static bool isColor(ColorSpace cs)
 {
     return (cs < ColorSpace.Vector);
 }
Пример #53
0
 private static KeyValuePair<ColorSpace, ColorSpaceName> newKVPName(ColorSpace colorSpace, string name, string nameShort, string nameC0, string nameC1, string nameC2, string nameC3, string description)
 {
     return KeyValuePairs.newKVP(colorSpace, new ColorSpaceName(colorSpace, name, nameShort, nameC0, nameC1, nameC2, nameC3, description));
 }
Пример #54
0
 /// <summary>
 /// ��ָ���IJ�����ʼ�� ColorSpaceName �����ʵ��������������
 /// </summary>
 /// <param name="colorSpace">ɫ�ʿռ䡣</param>
 /// <param name="name">ɫ�ʿռ�����ơ����硰CIEXYZ����</param>
 /// <param name="nameShort">ɫ�ʿռ�Ķ����ƣ�����ͨ������д�����硰XYZ����</param>
 /// <param name="nameC0">ͨ��0�����ơ�</param>
 /// <param name="nameC1">ͨ��1�����ơ�</param>
 /// <param name="nameC2">ͨ��2�����ơ�</param>
 /// <param name="nameC3">ͨ��3�����ơ�</param>
 public ColorSpaceName(ColorSpace colorSpace, string name, string nameShort, string nameC0, string nameC1, string nameC2, string nameC3)
     : this(colorSpace, name, nameShort, nameC0, nameC1, nameC2, nameC3, string.Empty)
 {
 }
Пример #55
0
 /// <summary>
 /// ���� <seealso cref="ColorSpace"/> ��������Ϣ��
 /// </summary>
 /// <param name="cs">ɫ�ʿռ� <seealso cref="ColorSpace"/>������</param>
 /// <returns>����������Ϣ��</returns>
 public static ColorSpaceName findName(ColorSpace cs)
 {
     return KeyValuePairs.find(Names, cs);
 }
Пример #56
0
 /// <summary>
 /// ��ָ���IJ�����ʼ�� ColorSpaceName �����ʵ���� 
 /// </summary>
 /// <param name="colorSpace">ɫ�ʿռ䡣</param>
 /// <param name="name">ɫ�ʿռ�����ơ����硰CIEXYZ����</param>
 /// <param name="nameShort">ɫ�ʿռ�Ķ����ƣ�����ͨ������д�����硰XYZ����</param>
 /// <param name="nameC0">ͨ��0�����ơ�</param>
 /// <param name="nameC1">ͨ��1�����ơ�</param>
 /// <param name="nameC2">ͨ��2�����ơ�</param>
 /// <param name="nameC3">ͨ��3�����ơ�</param>
 /// <param name="description">������Ϣ��</param>
 public ColorSpaceName(ColorSpace colorSpace, string name, string nameShort, string nameC0, string nameC1, string nameC2, string nameC3, string description)
 {
     this.colorSpace = colorSpace;
     this.name = name;
     this.nameShort = nameShort;
     this.description = description;
     this.nameChannels = new string[4] { nameC0, nameC1, nameC2, nameC3 };
 }
Пример #57
0
 public void SetColorSpace(ColorSpace value)
 {
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   NativeMethods.X64.QuantizeSettings_SetColorSpace(Instance, (UIntPtr)value);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   NativeMethods.X86.QuantizeSettings_SetColorSpace(Instance, (UIntPtr)value);
   #endif
 }
Пример #58
0
 public override bool VirtuallyEquals(ColorSpace other)
 {
     var otherColor = other as Cmyk;
     if (otherColor != null)
     {
         return C.ApproximatelyEquals(otherColor.C) &&
                M.ApproximatelyEquals(otherColor.M) &&
                Y.ApproximatelyEquals(otherColor.Y) &&
                K.ApproximatelyEquals(otherColor.K);
     }
     return false;
 }
Пример #59
0
 public override bool Equals(ColorSpace other)
 {
     var otherColor = other as Cmyk;
     if (otherColor != null)
         return C.Equals(otherColor.C) && M.Equals(otherColor.M) && Y.Equals(otherColor.Y) && K.Equals(otherColor.K);
     return false;
 }
Пример #60
0
        public static Bitmap ToBitmap(PlanarImage source, PixelFormat format, ColorSpace colorspace = ColorSpace.DEFAULT)
        {
            IntPtr context = SwScale.sws_getContext(source.Width, source.Height, m_pixelTypeMapper[source.PixelType],
                                             source.Width, source.Height, m_rgbMapper[format],
                                             SwScale.ConvertionFlags.SWS_BICUBIC, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

            int* pCoef = SwScale.sws_getCoefficients(colorspace);
            int* inv_table;
            int* table;
            int srcRange, dstRange, brightness, contrast, saturation;

            int result = SwScale.sws_getColorspaceDetails(context, out inv_table, out srcRange, out table, out dstRange, out brightness, out contrast, out saturation);
            if (result != -1)
            {
                result = SwScale.sws_setColorspaceDetails(context, pCoef, srcRange, pCoef, dstRange, brightness, contrast, saturation);
            }

            Bitmap bmp = new Bitmap(source.Width, source.Height, format);
            BitmapData data = bmp.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadWrite, format);

            unsafe
            {
                pInput[0] = (byte*)data.Scan0.ToPointer();

                result = SwScale.sws_scale(context, source.PixelDataPointer, source.Pitches, 0, source.Height, pInput, new int[] { data.Stride, 0, 0, 0 });
                if (result != source.Height)
                {
                    throw new InvalidOperationException();
                }
            }

            bmp.UnlockBits(data);
            if (bmp.Palette != null && bmp.Palette.Entries != null && bmp.Palette.Entries.Length > 0)
            {
                ColorPalette cp = bmp.Palette;
                for (int i = 0; i < cp.Entries.Length; i++)
                {
                    cp.Entries[i] = Color.FromArgb(i, i, i);
                }
                bmp.Palette = cp;
            }

            SwScale.sws_freeContext(context);
            return bmp;
        }