Example #1
0
 public unsafe void ReadPixels(Color4[] colors)
 {
     fixed (Color4* ptr = colors)
     {
         renderTargetCom.ReadPixels(ptr, colors.Length * 4);
     }
 }
Example #2
0
 public static void ToVector4(ref Color4 color, out Vector4 vector)
 {
     vector.X = color.R / 255f;
     vector.Y = color.G / 255f;
     vector.Z = color.B / 255f;
     vector.W = color.A / 255f;
 }
Example #3
0
        public bool ReadPixel(Point2 position, out Color4 color)
        {
            if (position.X < 0 || position.X >= Size.Width || position.Y < 0 || position.Y >= Size.Height)
            {
                color = new Color4();
                return false;
            }

            color = new Color4(renderTargetCom.ReadPixel(position.X, position.Y, Size.Height));
            return true;
        }
Example #4
0
        public bool ReadPixel(Point2 position, out Color4 color)
        {
            // make sure position is within the texture bounds
            if (position.X < 0 || position.X >= Size.Width || position.Y < 0 || position.Y >= Size.Height)
            {
                color = new Color4();
                return false;
            }

            // TODO: make sure i'm the active render target

            // read data
            byte[] data = new byte[4];
            video.context.ReadPixels(data, Sce.PlayStation.Core.Graphics.PixelFormat.Rgba, position.X, position.Y, 1, 1);
            color = new Color4(data[0], data[1], data[2], data[3]);
            return true;
        }
Example #5
0
        public unsafe bool ReadPixel(Point2 position, out Color4 color)
        {
            // make sure position is within the texture bounds
            if (position.X < 0 || position.X >= Size.Width || position.Y < 0 || position.Y >= Size.Height)
            {
                color = new Color4();
                return false;
            }

            // TODO: make sure i'm the active render target

            // read data
            int data;
            GL.ReadPixels(position.X, position.Y, 1, 1, GL.RGBA, GL.UNSIGNED_BYTE, &data);
            color = new Color4(data);
            return true;
        }
Example #6
0
 public void ReadPixels(Color4[] colors)
 {
     throw new NotImplementedException();
 }
Example #7
0
 public bool ReadPixel(Point2 position, out Color4 color)
 {
     throw new NotImplementedException();
 }
        private void bs_ImageOpened(object sender, RoutedEventArgs args)
        {
            try
            {
                var image = (BitmapImage)sender;
                var bitmap = new WriteableBitmap(image);

                int width = bitmap.PixelWidth;
                int height = bitmap.PixelHeight;
                Mipmaps = new Mipmap[1];
                Size = new Size2(bitmap.PixelWidth, bitmap.PixelHeight);

                var dataPixels = bitmap.Pixels;
                var data = new byte[dataPixels.Length * 4];
                int i2 = 0;
                for (int i = 0; i != dataPixels.Length; ++i)
                {
                    var color = new Color4(dataPixels[i]);
                    data[i2] = color.R;
                    data[i2+1] = color.G;
                    data[i2+2] = color.B;
                    data[i2+3] = color.A;

                    i2 += 4;
                }

                // Flip RB Color bits
                for (i2 = 0; i2 != data.Length; i2 += 4)
                {
                    byte c = data[i2];
                    data[i2] = data[i2+2];
                    data[i2+2] = c;
                }

                Mipmaps[0] = new Mipmap(data, width, height, 1, 4);
                if (flip) Mipmaps[0].FlipVertical();
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                if (loadedCallback != null) loadedCallback(this, false);
                loadedCallback = null;
                return;
            }

            Loaded = true;
            if (loadedCallback != null) loadedCallback(this, true);
            loadedCallback = null;
        }
Example #9
0
 public static void ToColor4(ref Vector4 vector, out Color4 color)
 {
     color.R = (byte)(vector.X * 255);
     color.G = (byte)(vector.Y * 255);
     color.B = (byte)(vector.Z * 255);
     color.A = (byte)(vector.W * 255);
 }