/// <summary>
        /// Gets pixel color of a specified texture, returning default if otherwise failed. Slow.
        /// </summary>
        /// <param name="texture">Texture.</param>
        /// <param name="x">X.</param>
        /// <param name="y">Y.</param>
        /// <param name="defaultColor">Color to return on failure.</param>
        /// <returns>Pixel color.</returns>
        public override Color PixelColor(Texture texture, uint x, uint y, Color defaultColor)
        {
            Texture2D tex = texture.RendererData as Texture2D;

            if (tex != null)
            {
                if (PrivateRendererContext.Application.ManagedThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId)
                {
                    FreezingArcher.Math.Color4 col = tex.GetPixelColor((int)x, (int)y);

                    return Color.FromArgb((int)(col.A), (int)(col.R), (int)(col.G), (int)(col.B));
                }
                else
                {

                    RendererCore.RCActionGetPixelColor getpix = new RendererCore.RCActionGetPixelColor(tex, (int)x, (int)y);

                    PrivateRendererContext.AddRCActionJob(getpix);

                    while (!getpix.OutputReady);

                    FreezingArcher.Math.Color4 col = getpix.OutputColor;

                    return Color.FromArgb((int)(col.A), (int)(col.R), (int)(col.G), (int)(col.B));
                }
            }

            return defaultColor;
        }
Exemple #2
0
 public TextureAttachment(Texture t, AttachmentUsage a)
 {
     tex = t;
     au = a;
 }
 public override Color PixelColor(Texture texture, uint x, uint y)
 {
     return PixelColor(texture, x, y, Color.Yellow);
 }