public static ImageSource ToImageSource(this Bytearray grayImg) { Bitmap bitmap = ImgRoutine.NarrayToRgbBitmap(grayImg); var bi = new BitmapImage(); using (var ms = new MemoryStream()) { bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); ms.Position = 0; bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.UriSource = null; bi.StreamSource = ms; bi.EndInit(); } return(bi); }
public static Bitmap ConvertCharsegToBitmapRecolor(Intarray charseg, string trans = "") { Intarray cseg = new Intarray(); cseg.Copy(charseg); Narray <Rect> bboxes = new Narray <Rect>(); //SegmRoutine.make_line_segmentation_black(cseg); ImgLabels.bounding_boxes(ref bboxes, cseg); SegmRoutine.make_line_segmentation_white(cseg); ImgLabels.simple_recolor(cseg); return(DrawSegmentTranscript( DrawSegmentNumbers( ImgRoutine.NarrayToRgbBitmap(cseg), bboxes), bboxes, trans)); }
private void ProcessDeleteSegment(object sender, RoutedEventArgs e) { int start = numUpDnStart.Value ?? 1; start = Math.Min(start, CurrSegmentsCount); Bytearray outgray = new Bytearray(); SegmRoutine.rseg_to_cseg_remove( currBookLine.CharsegIntarray, currBookLine.CharsegIntarray, outgray, currBookLine.ImageBytearray, start, start); // пересчитаем число сегментов CurrSegmentsCount = NarrayUtil.Max(currBookLine.CharsegIntarray); // Show segmented image ShowCharsegImage(currBookLine.CharsegIntarray, (currBookLine.HaveTranscript && CurrSegmentsCount == currBookLine.Transcript.Length) ? currBookLine.Transcript : ""); currBookLine.ImageBytearray = outgray; currBookLine.Image = ImgRoutine.NarrayToRgbBitmap(outgray); isCurrDeletedSegment = true; }