/// <summary> /// アプリ側で保持しているカーブ情報を使用して疑似着色をおこなう /// カーブ情報にnullが設定されている場合は、デフォルトのカーブ情報を使用する /// </summary> /// <param name="srcBmp">加工元の画像</param> /// <param name="curve">カーブ情報</param> /// <returns>加工後の画像</returns> public static WriteableBitmap Effect(WriteableBitmap srcBmp, Curve curve) { Curve applyCurve = null; if (curve != null) { applyCurve = curve; } else { var curAssembly = Assembly.GetExecutingAssembly(); var strm = curAssembly.GetManifestResourceStream("GenericVideoFilter.default_hosei.cur"); applyCurve = new Curve(strm, CurveTypes.Gimp); } var filter = new GiCoCu(applyCurve); return filter.Process(srcBmp); }
private static Curve GetGimpCurve(Stream strm) { var curves = new Curve(); int[,] index = new int[5, 17]; int[,] value = new int[5, 17]; var reader = new StreamReader(strm); // ヘッダーがGIMP形式になっているかチェック var header = reader.ReadLine(); if ("# GIMP Curves File" != header) { throw new IOException("not gimp curves file"); } for (int i = 0; i < 5; i++) { string line = reader.ReadLine(); var values = line.Split(' '); for (int j = 0, k = 0; j < 17; j++) { index[i, j] = int.Parse(values[k]); k++; value[i, j] = int.Parse(values[k]); k++; Debug.WriteLine("index: {0}, value: {0}", index[i, j], value[i, j]); } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 17; j++) { curves.Points[i, j, 0] = index[i, j]; curves.Points[i, j, 1] = value[i, j]; } } // make LUTs for (int i = 0; i < 5; i++) { curves.Calculate(i); } return curves; }
public GiCoCu(Curve curve) { _curve = curve; }