Esempio n. 1
0
 private static void ScalePSMCT32PixelsToHalfAlphaRange(Color[] colors)
 {
     for (int c = 0; c < colors.Length; c++)
     {
         colors[c] = Color.FromArgb(
             PS2PixelFormatHelper.ScaleFullRangeAlphaToHalfRange(colors[c].A),
             colors[c].R,
             colors[c].G,
             colors[c].B);
     }
 }
        /// <summary>
        /// Initialize a new instanc eof <see cref="RwRasterDataStructNode"/> using a given bitmap and a PS2 <see cref="PS2.Graphics.PS2PixelFormat"/> to encode the bitmap to.
        /// </summary>
        /// <param name="bitmap">Bitmap to be encoded using the given pixel format.</param>
        /// <param name="pixelFormat">The pixel format the bitmap will be encoded to and stored in the texture data.</param>
        public RwRasterDataStructNode(Bitmap bitmap, PS2PixelFormat pixelFormat)
            : base(RwNodeId.RwStructNode)
        {
            if (PS2PixelFormatHelper.IsIndexedPixelFormat(pixelFormat))
            {
                BitmapHelper.QuantizeBitmap(bitmap, PS2PixelFormatHelper.GetIndexedColorCount(pixelFormat), out mIndices, out mPalette);
            }
            else
            {
                mPixels = BitmapHelper.GetColors(bitmap)
                          .Select(x => Color.FromArgb(PS2PixelFormatHelper.ScaleFullRangeAlphaToHalfRange(x.A), x.R, x.G, x.B))
                          .ToArray();
            }

            mMipMapData = new byte[0];
        }