/// <summary> /// 这个可能放弃使用 /// </summary> /// <param name="basePic"></param> /// <param name="diffPic"></param> /// <param name="merger_scheme"></param> /// <param name="offset_x"></param> /// <param name="offset_y"></param> /// <returns></returns> public static ImageOpen Merger(ImageOpen basePic, ImageOpen diffPic, int merger_scheme, int offset_x, int offset_y) { ImageOpen outPic; switch (merger_scheme) { case 1: outPic = PicMergerCore.Alpha(basePic, diffPic, offset_x, offset_y); break; case 2: outPic = PicMergerCore.Color(basePic, diffPic, offset_x, offset_y); break; case 3: outPic = PicMergerCore.Override(basePic, diffPic, offset_x, offset_y); break; default: outPic = null; break; } return(outPic); }
/// <summary> /// 边缘扫描,类似原本DM的O模式,但并非相似度而是完全一致匹配。 /// </summary> /// <param name="Base"></param> /// <param name="Diff"></param> /// <returns></returns> public static ImageOpen EgdeDetect(ImageOpen Base, ImageOpen Diff) { //首先要扫描diff图片的最外圈,24位图就边缘,32位图就得非透明的边缘。 //半透明如何处理我得想想。 var getEgdeList = RGBA_G2L(Diff.Pic); var getXY = BaseXY(Base.Pic, Diff.Pic, getEgdeList); var outputPic = Alpha(Base, Diff, getXY[0], getXY[1]); return(outputPic); }
/// <summary> /// alpha合成图像,返回的图像继承Base的坐标,并将文件名以连接符连接。 /// </summary> /// <param name="Base">基本图片</param> /// <param name="Diff">差分图片</param> /// <param name="offset_x">X轴偏移</param> /// <param name="offset_y">Y轴偏移</param> /// <returns>输出的ImageOpen类图片</returns> public static ImageOpen Alpha(ImageOpen Base, ImageOpen Diff, int offset_x, int offset_y) { var out_pic = Base.CopyPic(); out_pic.Composite(Diff.Pic, offset_x, offset_y, CompositeOperator.Over); var out_name = Path.Combine(Scheme.OutputDir, Path.GetFileNameWithoutExtension(Base.FileName)); out_name += Scheme.JoinScheme + Path.GetFileName(Diff.FileName); return(new ImageOpen(out_pic, Base.OffsetXY, out_name)); }
/// <summary> /// 输入两张图片,得到的是合成后的图片。 /// 返回图片由clone生成,不影响源图。 /// </summary> /// <param name="basePic"></param> /// <param name="diffPic"></param> /// <param name="merger_scheme"></param> /// <returns></returns> public static ImageOpen Merger(ImageOpen basePic, ImageOpen diffPic, int merger_scheme, bool needPA = false) { ImageOpen outPic; var offset_x = diffPic.OffsetXY[0] - basePic.OffsetXY[0]; var offset_y = diffPic.OffsetXY[1] - basePic.OffsetXY[1]; //PA处理 if (needPA) { if (!basePic.PremultipliedAlphaSign) { PremultipliedAlpha(basePic.m_pic); basePic.PremultipliedAlphaSign = true; } if (!diffPic.PremultipliedAlphaSign) { PremultipliedAlpha(diffPic.m_pic); diffPic.PremultipliedAlphaSign = true; } } switch (merger_scheme) { case 1: outPic = PicMergerCore.Alpha(basePic, diffPic, offset_x, offset_y); break; case 2: outPic = PicMergerCore.Color(basePic, diffPic, offset_x, offset_y); break; case 3: outPic = PicMergerCore.Override(basePic, diffPic, offset_x, offset_y); break; case 4: outPic = PicMergerCore.EgdeDetect(basePic, diffPic); break; default: outPic = null; break; } outPic.MergedCount = basePic.MergedCount + 1; return(outPic); }
/// <summary> /// Transparent Blitting /// </summary> /// <param name="Base"></param> /// <param name="Diff"></param> /// <returns></returns> public static ImageOpen Color(ImageOpen Base, ImageOpen Diff, int offset_x, int offset_y) { var ColorKey = Scheme.ColorKey; var out_pic = Base.CopyPic(); MagickColor CK = new MagickColor(ColorKey); //因为会影响Diff原图,所以复制 var Diff_byAlpha = Diff.CopyPic(); //还有个ColorAlpha不知道怎么用,无效的感觉。 Diff_byAlpha.Transparent(CK); out_pic.Composite(Diff_byAlpha, offset_x, offset_y, CompositeOperator.Over); Diff_byAlpha.Dispose(); var out_name = Path.Combine(Scheme.OutputDir, Path.GetFileNameWithoutExtension(Base.FileName)); out_name += Scheme.JoinScheme + Path.GetFileName(Diff.FileName); return(new ImageOpen(out_pic, Base.OffsetXY, out_name)); }
public static ImageOpen MergerOfStrings(string[] merge_list) { var basePic = new ImageOpen(merge_list[0]); bool FirstSW = true; foreach (var i in merge_list) { //跳过第一张 if (FirstSW) { FirstSW = false; continue; } var diffPic = new ImageOpen(i); basePic = PicMerger.Merger(basePic, diffPic, MergerStyle.Alpha, diffPic.OffsetXY[0] - basePic.OffsetXY[0], diffPic.OffsetXY[1] - basePic.OffsetXY[1]); diffPic.Close(); } return(basePic); }
public ImageOpen Clone() { var returnIO = new ImageOpen(this.CopyPic(), this.OffsetXY, this.m_filename); return(returnIO); }