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); }
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); }