/// <summary> /// Converts from their colorspace to RGB and combines all previously decoded channels /// </summary> /// <param name="imgInfo"></param> /// <param name="imgS"></param> /// <returns>A 2D array representing the color data from the image</returns> internal static Color2[,] MergeChannels(ImgInfo imgInfo, float[][,] imgS) { var img = new Color2[imgInfo.height, imgInfo.width]; IColorspaceConverter converter; if (imgInfo.app14MarkerFound) { switch (imgInfo.colorMode) { case Markers.App14ColorMode.Unknown: if (imgInfo.numOfComponents == 3) { converter = new Rgb(); } else { converter = new YCbCr(); } break; case Markers.App14ColorMode.YCbCr: converter = new YCbCr(); break; case Markers.App14ColorMode.YCCK: converter = new YCbCr(); break; default: converter = new Rgb(); break; } } else { converter = new Colorspaces.YCbCr(); } for (int y = 0; y < imgInfo.height; y++) { for (int x = 0; x < imgInfo.width; x++) { Info info; if (imgInfo.numOfComponents == 1) // Y { info.a = imgS[0][y, x]; info.b = 0; info.c = 0; } else // YCbCr { info.a = imgS[0][y, x]; info.b = imgS[1][y, x]; info.c = imgS[2][y, x]; } img[y, x] = converter.ConvertToRgb(info); } } return(img); }
/// <summary> /// Converts from their colorspace to RGB and combines all previously decoded channels /// </summary> /// <param name="imgInfo"></param> /// <param name="imgS"></param> /// <returns>A 2D array representing the color data from the image</returns> internal static Color2[,] MergeChannels(ImgInfo imgInfo, float[][,] imgS) { Color2[,] img = new Color2[imgInfo.height, imgInfo.width]; IColorspaceConverter converter; if (imgInfo.app14MarkerFound) { switch (imgInfo.colorMode) { case Markers.App14ColorMode.Unknown: if (imgInfo.numOfComponents == 3) { converter = new Rgb(); } else { converter = new YCbCr(); } break; case Markers.App14ColorMode.YCbCr: converter = new YCbCr(); break; case Markers.App14ColorMode.YCCK: converter = new YCbCr(); break; default: converter = new Rgb(); break; } } else { converter = new Colorspaces.YCbCr(); } for (int y = 0; y < imgInfo.height; y++) { for (int x = 0; x < imgInfo.width; x++) { Info info; if (imgInfo.numOfComponents == 1) // Y { info.a = imgS[0][y, x]; info.b = 0; info.c = 0; } else // YCbCr { info.a = imgS[0][y, x]; info.b = imgS[1][y, x]; info.c = imgS[2][y, x]; } img[y, x] = converter.ConvertToRgb(info); } } return img; }