示例#1
0
 public static Color[,] GetColorMatriu(this Bitmap bmp)
 {
     Color[,] matriz = new Color[bmp.Width, bmp.Height];
     unsafe
     {
         bmp.TrataBytes(((MetodoTratarUnmanagedTypePointer <byte>)((ptrBytesBmp) =>
         {
             Gabriel.Cat.S.Utilitats.V2.Color *ptrColoresBmp = (Gabriel.Cat.S.Utilitats.V2.Color *)ptrBytesBmp;
             for (int y = 0, yFinal = bmp.Width, xFinal = bmp.Height; y < yFinal; y++)
             {
                 for (int x = 0; x < xFinal; x++)
                 {
                     matriz[x, y] = *ptrColoresBmp;
                     ptrColoresBmp++;
                 }
             }
         })));
     }
     return(matriz);
 }
示例#2
0
        public static Bitmap GetBitmap(this Color[,] array)
        {
            Bitmap bmp = new Bitmap(array.GetLength(DimensionMatriz.X), array.GetLength(DimensionMatriz.Y));

            unsafe
            {
                bmp.TrataBytes(((MetodoTratarUnmanagedTypePointer <byte>)((ptrBytesBmp) =>
                {
                    Gabriel.Cat.S.Utilitats.V2.Color *ptrColoresBmp = (Gabriel.Cat.S.Utilitats.V2.Color *)ptrBytesBmp;
                    for (int y = 0, yFinal = array.GetLength((int)DimensionMatriz.Y), xFinal = array.GetLength((int)DimensionMatriz.X); y < yFinal; y++)
                    {
                        for (int x = 0; x < xFinal; x++)
                        {
                            *ptrColoresBmp = array[x, y];
                            ptrColoresBmp++;
                        }
                    }
                })));
            }
            return(bmp);
        }