Exemplo n.º 1
0
 /// <summary>
 /// Get the depth type of the image
 /// </summary>
 /// <param name="image">The image to apply reflection on</param>
 /// <returns>The depth type of the image</returns>
 public static Type GetTypeOfDepth(IImage image)
 {
    return 
       Toolbox
       .GetBaseType(image.GetType(), "Image`2")
       .GetGenericArguments()[1];
 }
Exemplo n.º 2
0
 public void Save(IImage image, IFile file)
 {
     var actual = ((ImageAdapter)image).Image;
     using (var stream = file.Open(FileLockMode.ReadWrite, FileOpenMode.Recreate)) {
         actual.Save(stream, this.codec, this.parameters);
     }
 }
Exemplo n.º 3
0
        public IImage Handle(IImage src)
        {
            m_cacheResults.Clear();
            if (src == null) return null;

            if (Enable == true)
            {
                try
                {
                    this.m_inputImage = src;
                    this.m_cacheResults.Add(this.CreateInput(this.m_inputImage));
                    this.m_outputImage = this.HandleCore(src);
                    if (this.m_outputImage != null)
                    {
                        this.m_cacheResults.Add(this.CreateOutput(this.m_outputImage));
                    }
                    return this.m_outputImage;
                }
                catch (Exception ex)
                {
                    this.m_cacheResults.Add(this.CreateExceptionResult(ex));
                    return this.m_outputImage;
                }
                finally
                {
                }
            }
            else return src;
        }
Exemplo n.º 4
0
 protected override IImage HandleCore(IImage src)
 {
     // Bitmap dst = src.Clone(new Rectangle(0,0,src.Width,src.Height), src.PixelFormat) as Bitmap;
     //			m_filter.ApplyInPlace(dst);
     // return dst;
     throw new NotImplementedException();
 }
        public static unsafe void ConvertByteToDouble(IImage src, IImage dest)
        {
            int nChannels = src.ColorInfo.NumberOfChannels;
            int elemWidth = src.Width * nChannels;
            int height = src.Height;

            int srcStride = src.Stride;
            int destStride = dest.Stride;

            for (int channel = 0; channel < src.ColorInfo.NumberOfChannels; channel++)
            {
                byte* srcPtr = (byte*)src.ImageData + channel;
                double* destPtr = (double*)dest.ImageData + channel;

                for (int r = 0; r < height; r++)
                {
                    for (int c = 0; c < elemWidth; c += nChannels)
                    {
                        destPtr[c] = srcPtr[c];
                    }

                    srcPtr += srcStride / sizeof(byte);
                    destPtr += destStride / sizeof(double);
                }
            }
        }
Exemplo n.º 6
0
 public int Recognize(IImage image)
 {
     var discretizedImage = discretizer.Discretize(image);
     var activeNeuron = classifier.Classify(discretizedImage);
     var cluster = mapper.Map(activeNeuron);
     return cluster;
 }
		private static ISprite getDefaultSprite(IImage image, IGraphicsFactory factory)
		{
			ISprite sprite = factory.GetSprite();
			sprite.Image = image;
			sprite.Location = AGSLocation.Empty();
			return sprite;
		}
Exemplo n.º 8
0
 public static ProcessorResult CreateOutput(IProcessor pro, IImage output)
 {
     ProcessorResult r = new ProcessorResult();
     r.Result = output == null ? null : output.ToBitmap();
     r.Name = "输出图像";
     return r;
 }
Exemplo n.º 9
0
 public EventButton(string text, int count, EventType eventType, IImage icon)
 {
     Count = count;
     Text = text;
     Event = eventType;
     Icon = icon;
 }
        /// <summary>
        /// see: http://stackoverflow.com/questions/3018313/algorithm-to-convert-rgb-to-hsv-and-hsv-to-rgb
        /// and: http://www.cbusforums.com/forums/showthread.php?t=8657
        /// range for  HSV is H:[0-180], S:[0-255], V:[0-255]
        /// </summary>
        public static unsafe void ConvertHsvToBgr_Byte(IImage src, IImage dest)
        {
            Hsv8* srcPtr = (Hsv8*)src.ImageData;
            Bgr8* dstPtr = (Bgr8*)dest.ImageData;

            int width = src.Width;
            int height = src.Height;

            int srcShift = src.Stride - width * sizeof(Hsv8); //DO NOT divide with sizeof(Bgr8) as reminder may not be 0!!!
            int dstShift = dest.Stride - width * sizeof(Bgr8);

            for (int row = 0; row < height; row++)
            {
                for (int col = 0; col < width; col++)
                {
                    Hsv8.ConvertHsvToBgr(srcPtr, dstPtr);

                    srcPtr++;
                    dstPtr++;
                }

                srcPtr = (Hsv8*)((byte*)srcPtr + srcShift);
                dstPtr = (Bgr8*)((byte*)dstPtr + dstShift);
            }
        }
        public void HandleFindResults(IImage image, IEnumerable<IFindResult> results)
        {
            foreach (var selectedArea in results)
            {
                if (selectedArea.Points.Count >= 2)
                {
                    var rand = new Random();
                    var pixel = _pixels[rand.Next(_pixels.Length - 1)];
                    DrawLineAlgorithm.PlotFunction plotFunction = (x, y) =>
                    {

                        if (x < image.Width && y < image.Height && x >= 0 && y >= 0)
                        {
                            image.SetPixel(x, y, pixel);
                        }
                        return true;
                    };
                    var firstPoint = selectedArea.Points[0];
                    var previousPoint = firstPoint;
                    for (int i = 1; i < selectedArea.Points.Count; i++)
                    {
                        var currentPoint = selectedArea.Points[i];
                        DrawLineAlgorithm.Line(previousPoint.X, previousPoint.Y, currentPoint.X, currentPoint.Y, plotFunction);
                        previousPoint = currentPoint;
                    }
                    if (selectedArea.Points.Count > 2)
                    {
                        var lastPoint = selectedArea.Points[selectedArea.Points.Count - 1];
                        DrawLineAlgorithm.Line(lastPoint.X, lastPoint.Y, firstPoint.X, firstPoint.Y, plotFunction);
                    }
                }
            }
        }
Exemplo n.º 12
0
		public static TColourFormat GetFormat(IImage image)
		{
			Image<Gray, byte> ImageL8 = image as Image<Gray, byte>;
			if (ImageL8 != null)
				return TColourFormat.L8;

			Image<Gray, ushort> ImageL16 = image as Image<Gray, ushort>;
			if (ImageL16 != null)
				return TColourFormat.L16;
			
			Image<Rgb, byte> ImageRGB8 = image as Image<Rgb, byte>;
			if (ImageRGB8 != null)
				return TColourFormat.RGB8;
			//camera captures seem to arrive as bgr even though rgb
			//may need to revisit this later on
			Image<Bgr, byte> ImageBGR8 = image as Image<Bgr, byte>;
			if (ImageBGR8 != null)
				return TColourFormat.RGB8;

			Image<Rgb, float> ImageRGB32F = image as Image<Rgb, float>;
			if (ImageRGB32F != null)
				return TColourFormat.RGB32F;

			Image<Rgba, byte> ImageRGBA8 = image as Image<Rgba, byte>;
			if (ImageRGBA8 != null)
				return TColourFormat.RGBA8;

			return TColourFormat.UnInitialised;
		}
        public Task<IProcessServiceResult> ProcessImageAsync(string processorName, IImage image)
        {
            var result = new ImageProcessServiceResult();
            var processor = _processors.FirstOrDefault(p => p.Name == processorName);
            if (processor != null)
            {
                try
                {
                    var imageForProcessing = image.Clone();
                    processor.ProcessImage(imageForProcessing);
                    result.ProcessedImage = imageForProcessing;
                    result.Successful = true;
                }
                catch (Exception e)
                {
                    result.Successful = false;
                    result.ErrorMessage = e.Message;
                }
            }
            else
            {
                result.Successful = false;
                result.ErrorMessage = $"Can't find processor with name {processorName}";
            }

            return Task.FromResult((IProcessServiceResult)result);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Display the histograms of the specific image
 /// </summary>
 /// <param name="image">The image to retrieve hostigram from</param>
 /// <param name="numberOfBins">The numebr of bins in the histogram</param>
 public static void Show(IImage image, int numberOfBins)
 {
     HistogramViewer viewer = new HistogramViewer();
      viewer.HistogramCtrl.GenerateHistograms(image, numberOfBins);
      viewer.HistogramCtrl.Refresh();
      viewer.Show();
 }
        public IEnumerable<Region2D> GetResult(IImage source, FacePartParameter parameter)
        {
            if (source is Image<Gray, byte> == false)
            {
                return null;
            }

            Size size = parameter == null
                ? Size.Empty
                : new Size(parameter.MinWidth, parameter.MinHeight);

            IEnumerable<Region2D> ret;

            if (parameter.Region == null)
            {
                ret = Detect((Image<Gray, byte>)source, size).Select(item => item.rect.ToRegion()).ToList();
            }
            else
            {
                using (var sourceCrop = ((Image<Gray, byte>)source).GetSubRect(parameter.Region.ToRectangle()))
                {
                    ret = Detect(sourceCrop, size).Select(item => item.rect.ToRegion()).ToList();
                }
            }

            return ret;
        }
        public static unsafe void ConvertIntToFloat(IImage src, IImage dest)
        {
            int nChannels = src.ColorInfo.NumberOfChannels;
            int elemWidth = src.Width * nChannels;
            int height = src.Height;

            int srcStride = src.Stride;
            int destStride = dest.Stride;

            for (int channel = 0; channel < src.ColorInfo.NumberOfChannels; channel++)
            {
                int* srcPtr = (int*)src.ImageData + channel;
                float* destPtr = (float*)dest.ImageData + channel;

                for (int r = 0; r < height; r++)
                {
                    for (int c = 0; c < elemWidth; c += nChannels)
                    {
                        destPtr[c] = srcPtr[c];
                    }

                    srcPtr += srcStride / sizeof(int);
                    destPtr += destStride / sizeof(float);
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="image"></param>
        public override void ApplyToImage(IImage image)
        {
            if (image.Width <= this.Width || image.Height <= this.Height)
                return;

            base.ApplyToImage(image);
        }
Exemplo n.º 18
0
        public void SetImage(IImage image)
        {
            #region display the size of the image
             Size size = image.Size;
             widthTextbox.Text = size.Width.ToString();
             heightTextBox.Text = size.Height.ToString();
             #endregion

             #region display the color type of the image
             Type colorType = Reflection.ReflectIImage.GetTypeOfColor(image);
             Object[] colorAttributes = colorType.GetCustomAttributes(typeof(ColorInfoAttribute), true);
             if (colorAttributes.Length > 0)
             {
            ColorInfoAttribute info = (ColorInfoAttribute)colorAttributes[0];
            typeOfColorTexbox.Text = info.ConversionCodename;
             }
             else
             {
            typeOfColorTexbox.Text = Properties.StringTable.Unknown;
             }

             Type colorDepth = Reflection.ReflectIImage.GetTypeOfDepth(image);
             typeOfDepthTextBox.Text = colorDepth.Name;
             #endregion

             UpdateHistogram();
             UpdateZoomScale();
        }
Exemplo n.º 19
0
        public IImageCacheEntry GetImage(IImage image, int decodeWidth = 300, int decodeHeight = 300)
        {
            string cacheKey = "ImageCacheService_" + image.ID + "_" + decodeWidth + "x" + decodeHeight;
            var entry = _cache.Get(cacheKey) as IImageCacheEntry;

            if (entry == null)
            {
                string filePath;

                if (TryGetFilePath(image.ID, out filePath))
                {
                    entry = new DiskImageCacheEntry(
                        image.ID,
                        filePath,
                        decodeWidth,
                        decodeHeight);

                    _cache.Add(cacheKey, entry, new CacheItemPolicy { SlidingExpiration = TimeSpan.FromSeconds(30) });
                }
                else
                {
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        entry = new FirstTimeImageCacheEntry(image, filePath, decodeWidth, decodeHeight);
                    }
                }
            }

            return entry;
        }
Exemplo n.º 20
0
		public SavedTreeNode(IImage image, string fullname, string text)
			: base(null)
		{
			base.IconImage = image;
			FullName = fullname;
			Text = text;
		}
Exemplo n.º 21
0
 public IntHistogram(IImage image, string title, int capacity)
 {
     this.capacity = capacity;
     this.image = image;
     Max = 0;
     Title = title;
 }
        protected override IImage HandleCore(IImage src)
        {
            throw new NotImplementedException();
            //IImage dst = null;
            //if (src.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
            //{
            //    m_filter = new HoughLineTransformation();

            //    if (StepsPerDegree > 10) StepsPerDegree = 10;
            //    else if (StepsPerDegree < 1) StepsPerDegree = 1;

            //    if (LocalPeakRadius > 10) LocalPeakRadius = 10;
            //    else if (LocalPeakRadius < 1) LocalPeakRadius = 1;

            //    m_filter.StepsPerDegree = this.StepsPerDegree;
            //    m_filter.LocalPeakRadius = this.LocalPeakRadius;

            //    m_filter.ProcessImage(src);
            //    WriteHoughLine();
            //    dst = m_filter.ToBitmap();
            //}
            //else
            //{
            //    dst = src.Clone() as Bitmap;
            //}
            //IImage dst;
        }
Exemplo n.º 23
0
 /// <summary>
 /// Adds the frame to the animation.
 /// </summary>
 /// <param name="frame">Frame.</param>
 /// <param name="duration">Duration.</param>
 public void AddFrame(IImage frame, int duration)
 {
     lock (this) {
         frames.Add (new AnimFrame(frame, duration));
         totalDuration += duration;
     }
 }
Exemplo n.º 24
0
		public override void Start()
		{
			base.Start();

			IStack stack = Platform.Current.Create<IStack>();

			ILabel lblLabel = Platform.Current.Create<ILabel>();
			lblLabel.Text = "View an image from Url";
			lblLabel.Height = 30;
			stack.Children.Add(lblLabel);

			IImageButton imgbtn = Platform.Current.Create<IImageButton>();
			imgbtn.LoadFromUrl(new Uri("http://okhosting.com/wp-content/uploads/2016/02/okhosting-150x150.png"));
			imgbtn.Height = 100;
			imgbtn.Width = 100;
			imgbtn.Click += CmdViewImage_Click;
			stack.Children.Add(imgbtn);

			imgPicture = Platform.Current.Create<IImage>();
			imgPicture.LoadFromUrl(new Uri("http://www.patycantu.com/wp-content/uploads/2014/07/91.jpg"));
			imgPicture.Height = 250;
			imgPicture.Width = 600;
			imgPicture.Visible = false;
			stack.Children.Add(imgPicture);

			IButton cmdClose = Platform.Current.Create<IButton>();
			cmdClose.Text = "Close";
			cmdClose.Click += CmdClose_Click;
			stack.Children.Add(cmdClose);

			Platform.Current.Page.Title = "Test label";
			Platform.Current.Page.Content = stack;
		}
Exemplo n.º 25
0
        private unsafe static void phase_Double(IImage imageX, IImage imageY, IImage magnitudeImage)
        {
            int width = imageX.Width;
            int height = imageX.Height;
            int srcAOffset = imageX.Stride - width * sizeof(double);
            int srcBOffset = imageY.Stride - width * sizeof(double);
            int dstOffset = magnitudeImage.Stride - width * sizeof(double);

            double* srcXPtr = (double*)imageX.ImageData;
            double* srcYPtr = (double*)imageY.ImageData;
            double* dstPtr = (double*)magnitudeImage.ImageData;

            for (int row = 0; row < height; row++)
            {
                for (int col = 0; col < width; col++)
                {
                    *dstPtr = (double)System.Math.Atan2(*srcYPtr, *srcXPtr);

                    srcXPtr++;
                    srcYPtr++;
                    dstPtr++;
                }

                srcXPtr = (double*)((byte*)srcXPtr + srcAOffset);
                srcYPtr = (double*)((byte*)srcYPtr + srcBOffset);
                dstPtr = (double*)((byte*)dstPtr + dstOffset);
            }
        }
Exemplo n.º 26
0
		public void DrawImage (IImage image, Rect frame, double alpha = 1.0)
		{
			var ch = GetChild (ChildType.Image);
			var s = (Shapes.Rectangle)ch.Shape;
			s.Width = frame.Width;
			s.Height = frame.Height;
		}
Exemplo n.º 27
0
        private unsafe static void findNonZero_Float(IImage img, out List<Point> locations, out IList values)
        {
            locations = new List<Point>();
            var _values = new List<float>();

            float* ptr = (float*)img.ImageData;
            int stride = img.Stride;

            int width = img.Width;
            int height = img.Height;

            for (int row = 0; row < height; row++)
            {
                for (int col = 0; col < width; col++)
                {
                    var val = ptr[col];
                    
                    if (val != 0)
                    {
                        locations.Add(new Point(col, row));
                        _values.Add(val);
                    }
                }

                ptr = (float*)((byte*)ptr + stride);
            }

            values = _values;
        }
Exemplo n.º 28
0
 /// <summary>
 /// Predict the label of the image
 /// </summary>
 /// <param name="image">The image where prediction will be based on</param>
 /// <returns>The prediction label</returns>
 public PredictionResult Predict(IImage image)
 {
    int label = -1;
    double distance = -1;
    CvInvoke.CvFaceRecognizerPredict(_ptr, image.Ptr, ref label, ref distance);
    return new PredictionResult() { Label = label, Distance = distance };
 }
        public IEnumerable<IFindResult> Find(IImage image)
        {
            var histogram = CalculateLineHistogram(image);
            int threashold = (int)(0.95 * histogram.Max());

            int startX = 0, endX = 0;
            bool inSegment = false;
            for (int x = 0; x < histogram.Length; x++)
            {
                if (histogram[x] < threashold && !inSegment)
                {
                    inSegment = true;
                    startX = x;
                }
                if (histogram[x] >= threashold && inSegment)
                {
                    endX = x - 1;
                    inSegment = false;
                    if (endX - startX > 3)
                    {
                        yield return new FindResult(startX, 0, image.Height - 1, endX - startX);
                    }
                }
            }
        }
Exemplo n.º 30
0
 public static ProcessorResult CreateInput(IProcessor pro, IImage src)
 {
     ProcessorResult r = new ProcessorResult();
     r.Result = src == null ? null : src.ToBitmap();
     r.Name = "输入图像";
     return r;
 }
Exemplo n.º 31
0
        public void Analyze(System.Drawing.Bitmap bitmap, ColorConfig currentConfig, bool useMorphologic = true, bool detectBox = false)
        {
            System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
            bitmaps.UpdateImages(bitmap);
            using (Image <Bgr, byte> img = new Image <Bgr, byte>(bitmaps.Bitmap))
            {
                IImage uimage = createMat();
                CvInvoke.CvtColor(img.Clone(), uimage, ColorConversion.Bgr2Hsv, 3);

                double cannyThreshold        = 180.0;
                double cannyThresholdLinking = 10.0;
                IImage cannyEdges            = createMat();
                CvInvoke.Canny(img.Clone(), cannyEdges, cannyThreshold, cannyThresholdLinking);

                if (detectBox)
                {
                    var boxList = BoxDetection(cannyEdges);
                    foreach (var box in boxList)
                    {
                        for (int i = 0; i < box.Item1.Length; i++)
                        {
                            var pointA = box.Item1[i];
                            var pointB = box.Item1[(i + 1) % box.Item1.Length];
                            CvInvoke.Line(img, pointA, pointB, new Bgr(Color.DarkOrange).MCvScalar, 2);
                        }
                    }
                }


                //use image pyr to remove noise
                IImage pyrDown = createMat();
                CvInvoke.PyrDown(uimage, pyrDown);
                CvInvoke.PyrUp(pyrDown, uimage);

                IImage    imgThresholded = createMat();
                MCvScalar lower          = new MCvScalar(currentConfig.LowH, currentConfig.LowS, currentConfig.LowV);
                MCvScalar upper          = new MCvScalar(currentConfig.HighH, currentConfig.HighS, currentConfig.HighV);

                CvInvoke.InRange(uimage, new ScalarArray(lower), new ScalarArray(upper), imgThresholded);

                if (useMorphologic)
                {
                    morphOps(imgThresholded);
                }

                var contours   = ContourDetection(imgThresholded);
                var maxContour = contours.OrderByDescending(t => t.Item2).FirstOrDefault();
                foreach (var box in contours)
                {
                    MCvScalar contourColor;
                    if (box == maxContour)
                    {
                        contourColor = new Bgr(Color.DarkOrange).MCvScalar;
                        var vertices = box.Item4.GetVertices();
                        for (int i = 0; i < 4; i++)
                        {
                            CvInvoke.Line(img, new Point((int)vertices[i].X, (int)vertices[i].Y),
                                          new Point((int)vertices[(i + 1) % 4].X, (int)vertices[(i + 1) % 4].Y), contourColor);
                        }
                    }
                    else
                    {
                        contourColor = new Bgr(Color.Green).MCvScalar;
                    }
                    for (int i = 0; i < box.Item1.Length; i++)
                    {
                        var pointA = box.Item1[i];
                        var pointB = box.Item1[(i + 1) % box.Item1.Length];
                        CvInvoke.Line(img, pointA, pointB, contourColor, 4);
                    }
                    CvInvoke.Circle(img, box.Item3, 5, contourColor, 2);
                }
                //Add Hour
                CvInvoke.PutText(img, DateTime.Now.ToString(), new Point(5, 30), FontFace.HersheySimplex, 0.8, new Bgr(Color.LightBlue).MCvScalar);

                bitmaps.Calculations = sw.ElapsedMilliseconds;
                sw.Restart();
                bitmaps.UpdateImages(null, img.ToBitmap(),
                                     cannyEdges.Bitmap,
                                     imgThresholded.Bitmap);

                bitmaps.ImageSet = sw.ElapsedMilliseconds;
                bitmaps.FPS      = bitmaps.Calculations + bitmaps.ImageSet;

                if (this.analyzerOutput != null)
                {
                    analyzerOutput.FovSize = bitmaps.Bitmap.Size;
                    if (maxContour != null)
                    {
                        analyzerOutput.Detected = true;
                        analyzerOutput.Center   = maxContour.Item3;
                        analyzerOutput.Width    = (int)maxContour.Item4.Size.Width;
                        analyzerOutput.Height   = (int)maxContour.Item4.Size.Height;
                    }
                    else
                    {
                        analyzerOutput.Detected = false;
                        analyzerOutput.Center   = Point.Empty;
                        analyzerOutput.Distance = 0;
                    }
                }
            }
        }
Exemplo n.º 32
0
        private void ExposePerson(GDMIndividualRecord iRec, string iName)
        {
            fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0, true);
            fWriter.AddParagraphChunkAnchor(iName, fBoldFont, iRec.XRef);
            fWriter.AddParagraphChunk(GKUtils.GetPedigreeLifeStr(iRec, PedigreeFormat.Compact), fTextFont);
            fWriter.EndParagraph();

            IImage image = fBase.Context.GetPrimaryBitmap(iRec, 0, 0, false);

            fWriter.AddImage(image);

            GDMIndividualRecord father, mother;

            fBase.Context.Tree.GetParents(iRec, out father, out mother);

            if (father != null)
            {
                fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0);
                fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Father) + ": ", fTextFont);
                fWriter.AddParagraphChunkLink(GKUtils.GetNameString(father, true, false), fLinkFont, father.XRef);
                fWriter.EndParagraph();
            }

            if (mother != null)
            {
                fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0);
                fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Mother) + ": ", fTextFont);
                fWriter.AddParagraphChunkLink(GKUtils.GetNameString(mother, true, false), fLinkFont, mother.XRef);
                fWriter.EndParagraph();
            }

            if (IncludeEvents && iRec.Events.Count != 0)
            {
                int num = iRec.Events.Count;
                for (int i = 0; i < num; i++)
                {
                    GDMCustomEvent evt     = iRec.Events[i];
                    var            evtType = evt.GetTagType();
                    if (evtType == GEDCOMTagType.BIRT || evtType == GEDCOMTagType.DEAT)
                    {
                        continue;
                    }

                    string evtName = GKUtils.GetEventName(evt);
                    string evtVal  = evt.StringValue;
                    string evtDesc = GKUtils.GetEventDesc(fBase.Context.Tree, evt, false);

                    string tmp = evtName + ": " + evtVal;
                    if (evtVal != "")
                    {
                        tmp += ", ";
                    }
                    tmp += evtDesc;

                    fWriter.AddParagraph(tmp, fTextFont);
                }
            }

            if (IncludeNotes && iRec.Notes.Count != 0)
            {
                int num = iRec.Notes.Count;
                for (int i = 0; i < num; i++)
                {
                    GDMLines noteLines = fTree.GetNoteLines(iRec.Notes[i]);
                    fWriter.AddParagraph(GKUtils.MergeStrings(noteLines), fTextFont);
                }
            }
        }
 public void DrawBackground(IImage image)
 {
     ((IRendererExtended)Renderer).DrawBackground(image);
 }
 public void DrawImage(IImage image, float x, float y, float width, float height)
 {
     ((IRendererExtended)Renderer).DrawImage(image, x, y, width, height);
 }
 public void DrawImage(IImage image, float x, float y)
 {
     ((IRendererExtended)Renderer).DrawImage(image, x, y);
 }
Exemplo n.º 36
0
 public static void DrawImage(this ICanvas canvas, IImage image, double x, double y, double width, double height, double alpha = 1.0)
 {
     canvas.DrawImage(image, new Rect(x, y, width, height), alpha);
 }
Exemplo n.º 37
0
 public IImageView GetImageView(IImage image)
 {
     return(figmaDelegate.GetImageView(image));
 }
Exemplo n.º 38
0
 public static void MapImageSource(IButtonHandler handler, IImage image)
 {
 }
Exemplo n.º 39
0
        public void BuildBy(GDMIndividualRecord iRec)
        {
            try {
                fRec = iRec;

                if (iRec != null)
                {
                    if (fModel.PreparedIndividuals.IndexOf(iRec.XRef) < 0)
                    {
                        fModel.PreparedIndividuals.Add(iRec.XRef);
                    }

                    var parts = GKUtils.GetNameParts(iRec);
                    fSurname    = parts.Surname;
                    fName       = parts.Name;
                    fPatronymic = parts.Patronymic;
                    fNick       = GKUtils.GetNickString(iRec);
                    fSex        = iRec.Sex;

                    TreeChartOptions options = fModel.Options;

                    var        lifeDates  = iRec.GetLifeDates();
                    DateFormat dateFormat = (options.OnlyYears) ? DateFormat.dfYYYY : DateFormat.dfDD_MM_YYYY;

                    IsDead     = (lifeDates.DeathEvent != null);
                    fBirthDate = GKUtils.GEDCOMEventToDateStr(lifeDates.BirthEvent, dateFormat, false);
                    fDeathDate = GKUtils.GEDCOMEventToDateStr(lifeDates.DeathEvent, dateFormat, false);

                    if (!options.OnlyYears)
                    {
                        if (options.ShowPlaces)
                        {
                            string birthPlace = GKUtils.GetPlaceStr(lifeDates.BirthEvent, false);
                            if (!string.IsNullOrEmpty(birthPlace))
                            {
                                if (!string.IsNullOrEmpty(fBirthDate))
                                {
                                    fBirthDate += ", ";
                                }
                                fBirthDate += birthPlace;
                            }

                            string deathPlace = GKUtils.GetPlaceStr(lifeDates.DeathEvent, false);
                            if (!string.IsNullOrEmpty(deathPlace))
                            {
                                if (!string.IsNullOrEmpty(fDeathDate))
                                {
                                    fDeathDate += ", ";
                                }
                                fDeathDate += deathPlace;
                            }
                        }

                        if (!string.IsNullOrEmpty(fBirthDate))
                        {
                            fBirthDate = ImportUtils.STD_BIRTH_SIGN + " " + fBirthDate;
                        }
                        if (!string.IsNullOrEmpty(fDeathDate))
                        {
                            fDeathDate = ImportUtils.STD_DEATH_SIGN + " " + fDeathDate;
                        }
                    }

                    if (options.SignsVisible)
                    {
                        EnumSet <SpecialUserRef> signs = EnumSet <SpecialUserRef> .Create();

                        int num = fRec.UserReferences.Count;
                        for (int i = 0; i < num; i++)
                        {
                            string rs = fRec.UserReferences[i].StringValue;

                            for (var cps = SpecialUserRef.urRI_StGeorgeCross; cps <= SpecialUserRef.urLast; cps++)
                            {
                                string sur = LangMan.LS(GKData.SpecialUserRefs[(int)cps].Title);
                                if (rs == sur)
                                {
                                    signs.Include(cps);
                                }
                            }
                        }

                        fSigns = signs;
                    }
                    else
                    {
                        fSigns = EnumSet <SpecialUserRef> .Create();
                    }

                    if (options.PortraitsVisible)
                    {
                        try {
                            fPortrait = PortraitsCache.Instance.GetImage(fModel.Base.Context, iRec);

                            if (fPortrait == null && options.DefaultPortraits)
                            {
                                string resName = (fSex == GDMSex.svFemale) ? "pi_female_140.png" : "pi_male_140.png";
                                fPortrait = AppHost.GfxProvider.LoadResourceImage(resName, false);
                            }
                        } catch (MediaFileNotFoundException) {
                            if (!fModel.HasMediaFail)
                            {
                                AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_ArcNotFound));
                                fModel.HasMediaFail = true;
                            }
                        }
                    }

                    CertaintyAssessment = iRec.GetCertaintyAssessment();
                }
                else
                {
                    fSurname    = "";
                    fName       = "< ? >";
                    fPatronymic = "";
                    fNick       = "";
                    fBirthDate  = "";
                    fDeathDate  = "";
                    IsDead      = false;
                    fSex        = GDMSex.svUnknown;
                    fSigns      = EnumSet <SpecialUserRef> .Create();

                    CertaintyAssessment = 0.0f;
                }
            } catch (Exception ex) {
                Logger.LogWrite("TreeChartPerson.BuildBy(): " + ex.Message);
                throw;
            }
        }
Exemplo n.º 40
0
 public ImageColumn(IImage <T> image, int column)
 {
     this.Parent = image;
     this.column = column;
 }
Exemplo n.º 41
0
        private void listenEvents()
        {
            socket.On(Socket.EVENT_CONNECT, () =>
            {
                connected = true;
            });

            socket.On(Socket.EVENT_DISCONNECT, () =>
            {
                disconnect();
            });

            socket.On("stop streaming", (data) =>
            {
                var map  = Utils.GetMapFromData(data);
                var stop = Convert.ToBoolean(map["stop"]);
                if (stop)
                {
                    btnLive.BackColor = Color.Gray;
                }
            });

            socket.On("login", (data) =>
            {
                var map        = Utils.GetMapFromData(data);
                lblNumber.Text = Convert.ToInt32(map["numUsers"]).ToString() + " players";
                var message    = map["message"].ToString();
                if (message == "success")
                {
                    lbNotifications.Items.Add("You joined <3");
                    var reciever    = new SocketIoAudioReceiver(socket);
                    player          = new NetworkAudioPlayer(codec, reciever);
                    btnConnect.Text = "Disconnect";
                    enterName.Close();
                    btnChat.Enabled = true;
                    lblName.Text    = "Player: " + user.Name;
                }
                else
                {
                    lbNotifications.Items.Add(message);
                }
            });

            socket.On("mc connected", (data) =>
            {
                var map = Utils.GetMapFromData(data);
                game    = Game.FromJson(map["game"].ToString());
                lbNotifications.Items.Add(String.Format("😁 MC {0} joined", game.User.Name));
                lblAward.Text = String.Format("$ {0}", game.Award);
            });

            socket.On("mc disconnected", (data) =>
            {
                var map = Utils.GetMapFromData(data);
                var mc  = User.FromJson(map["user"].ToString());
                lbNotifications.Items.Add(String.Format("😂 MC {0} left", mc.Name));
            });

            socket.On("next question", (data) =>
            {
                lbNumberCorrectWrong.Text = "";
                var map           = Utils.GetMapFromData(data);
                Question question = Question.FromJson(map["question"].ToString());
                // speakQuestion(question);
                loadQuestions(question);
                int.TryParse(map["countDown"].ToString(), out seconds);
                int numberQuestion;
                int.TryParse(map["index"].ToString(), out numberQuestion);
                numberQuestion++;
                lblNumberQuestion.Text = "Question " + numberQuestion.ToString() + " ";
                timerCountDown         = new Thread(countDowner);
                timerCountDown.Start();
                showQuestion();
                resetColorButtons();
                enableButtons();
            });

            socket.On("continue players", (data) =>
            {
                var map = Utils.GetMapFromData(data);
                int continuePlayers;
                int stopsPlayers;
                int.TryParse(map["continue"].ToString(), out continuePlayers);
                int.TryParse(map["stop"].ToString(), out stopsPlayers);
                lbNotifications.Items.Add(String.Format("Number of players continued: {0}", continuePlayers));
                lbNotifications.Items.Add(String.Format("Number of players stopped: {0}", stopsPlayers));
            });

            socket.On("new game", (data) =>
            {
                lbCountDown.Text          = "";
                lblCorrect.Text           = "";
                lblNumberQuestion.Text    = "";
                lblQuestion.Text          = "";
                lbNumberCorrectWrong.Text = "";
                user.NumberCorrect        = 0;
                hideQuestion();
            });

            socket.On("user joined", (data) =>
            {
                var map        = Utils.GetMapFromData(data);
                lblNumber.Text = Convert.ToInt32(map["numUsers"]).ToString() + " players";
                var user       = User.FromJson(map["user"].ToString());
                lbNotifications.Items.Add(user.Name + " Joined");
            });

            socket.On("user left", (data) =>
            {
                var map        = Utils.GetMapFromData(data);
                lblNumber.Text = Convert.ToInt32(map["numUsers"]).ToString() + " players";
                var user       = User.FromJson(map["user"].ToString());
                lbNotifications.Items.Add(user.Name + " left");
            });

            socket.On("correct answer", (data) =>
            {
                var map           = Utils.GetMapFromData(data);
                var correctAnswer = map["answer"].ToString();
                disableButtons();
                showCorrectAnswer(correctAnswer);
                if (correctAnswer == answer.Id)
                {
                    lblQuestion.Text = lblQuestion.Text + "\n👌 Yes! Right answer";
                }
                else
                {
                    lblQuestion.Text = lblQuestion.Text + "\n😥 Nope! Wrong answer";
                }
            });


            socket.On("new message", (data) =>
            {
                var map     = Utils.GetMapFromData(data);
                var message = MyMessage.FromJson(map["message"].ToString());
                lbNotifications.Items.Add(message.UserName + ": " + message.Content);
            });

            socket.On("live video", (data) =>
            {
                var map   = Utils.GetMapFromData(data);
                imageLive = ImageLive.FromJson(map["image"].ToString());

                if (imageLive != null && imageLive.Img1D != null)
                {
                    btnLive.BackColor = Color.Red;
                    pLive.Refresh();
                    pLive.Image = IImage.ImageFromStream(imageLive.Img1D);
                }
            });


            socket.On("tops", (data) =>
            {
                var map           = Utils.GetMapFromData(data);
                var tops          = JsonConvert.DeserializeObject <List <User> >(map["tops"].ToString());
                var question      = Question.FromJson(map["question"].ToString());
                int i             = 1;
                int numCorrectAll = 1;
                int numWrongAll   = 1;
                int.TryParse(map["numberCorrect"].ToString(), out numCorrectAll);
                int.TryParse(map["numberWrong"].ToString(), out numWrongAll);
                lbNumberCorrectWrong.Text = String.Format("\nNumber correct: {0}\nNumber wrong: {1}", numCorrectAll, numWrongAll);

                tops.ForEach((value) =>
                {
                    var str = String.Format("Top {0}: {1} Correct {2}", i++, value.Name, value.NumberCorrect);
                    lbNotifications.Items.Add(str);
                    if (value.Name == user.Name)
                    {
                        user            = value;
                        lblCorrect.Text = String.Format("Correct: {0}", user.NumberCorrect);
                    }
                });
            });

            socket.On("congratulations", (data) =>
            {
                var map      = Utils.GetMapFromData(data);
                double bonus = 0;
                double.TryParse(map["bonus"].ToString(), out bonus);

                frmCongrats frmCongrats   = new frmCongrats(user.Name, user.NumberCorrect, bonus);
                frmCongrats.StartPosition = FormStartPosition.CenterParent;
                frmCongrats.ShowDialog();
            });
        }
Exemplo n.º 42
0
        /// <summary>
        /// Инициализация картинок для рамки сообщения
        /// </summary>
        /// <param name="bb">Нижняя полоса</param>
        /// <param name="lb">Левый нижний угол</param>
        /// <param name="ll">Левая полоса</param>
        /// <param name="lt">Левый верхний угол</param>
        /// <param name="rb">Правый нижний угол</param>
        /// <param name="rr">Правая полоса</param>
        /// <param name="rt">Правый верхний угол</param>
        /// <param name="tt">Верхняя полоса</param>
        /// <param name="button">Кнопка</param>
        /// <param name="buttonPressed">Кнопка в нажатом состоянии</param>
        public static void InitImages(IImage bb, IImage lb, IImage ll, IImage lt, IImage rb, IImage rr, IImage rt, IImage tt,
                                      IImage button, IImage buttonPressed)
        {
            if (bb == null || lb == null || ll == null || lt == null || rb == null || rr == null || rt == null || tt == null ||
                button == null || buttonPressed == null)
            {
                throw new ApplicationException("Message dialog images not initialized.");
            }

            dlg_BB            = bb;
            dlg_LB            = lb;
            dlg_LL            = ll;
            dlg_LT            = lt;
            dlg_RB            = rb;
            dlg_RR            = rr;
            dlg_RT            = rt;
            dlg_TT            = tt;
            dlg_button        = button;
            dlg_buttonPressed = buttonPressed;
        }
Exemplo n.º 43
0
 /// <summary>
 /// Convenience method to access WinForms <see cref="IImage"/> instance as WinForms <see cref="Bitmap"/>.
 /// The returned <see cref="Bitmap"/> will be disposed when the <see cref="IImage"/> is disposed.
 /// </summary>
 /// <param name="image"><see cref="IImage"/> object.</param>
 /// <returns><see cref="Bitmap"/> contents of <paramref name="image"/>.</returns>
 public static Bitmap AsBitmap(this IImage image)
 {
     return(image.As <Bitmap>());
 }
Exemplo n.º 44
0
 /// <summary>
 /// Adds an image to an event.
 /// </summary>
 /// <param name="image">The list of images to add.</param>
 /// <returns></returns>
 public Task <IImage> CreateImageAsync(IImage image)
 {
     image.Id = Guid.NewGuid();
     return(Repository.CreateImageAsync(image));
 }
Exemplo n.º 45
0
 /// <summary>
 /// Display the histograms of the specific image
 /// </summary>
 /// <param name="image">The image to retrieve histogram from</param>
 public static void Show(IImage image)
 {
     Show(image, 256);
 }
Exemplo n.º 46
0
 public GalleryController(IImage imageService)
 {
     _imageService = imageService;
 }
Exemplo n.º 47
0
 internal void SetIcon(IImage pImage)
 {
     this.engine.DeleteImage(ref this.image);
     this.image = pImage;
 }
Exemplo n.º 48
0
 public void SetMessage(string message, bool highlighted, IImage icon)
 {
     statusBar.SetMessage(StringParser.Parse(message), highlighted);
 }
Exemplo n.º 49
0
 public void SetTexture(IImage image)
 {
     Texture = image;
 }
Exemplo n.º 50
0
 partial void beforeInitComponents(Resolver resolver, IImage image);
Exemplo n.º 51
0
 partial void afterInitComponents(Resolver resolver, IImage image);
Exemplo n.º 52
0
 public GaussianBlurEffectResource(IImage sourceImage)
     : base(sourceImage)
 {
     this.StandardDeviation = 1f;
 }
Exemplo n.º 53
0
        /// <summary>
        /// Draws an image.
        /// </summary>
        /// <param name="source">The image.</param>
        /// <param name="sourceRect">The rect in the image to draw.</param>
        /// <param name="destRect">The rect in the output to draw to.</param>
        /// <param name="bitmapInterpolationMode">The bitmap interpolation mode.</param>
        public void DrawImage(IImage source, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode = default)
        {
            Contract.Requires <ArgumentNullException>(source != null);

            source.Draw(this, sourceRect, destRect, bitmapInterpolationMode);
        }
Exemplo n.º 54
0
        /// <summary>
        /// Draws an image.
        /// </summary>
        /// <param name="source">The image.</param>
        /// <param name="sourceRect">The rect in the image to draw.</param>
        /// <param name="destRect">The rect in the output to draw to.</param>
        /// <param name="bitmapInterpolationMode">The bitmap interpolation mode.</param>
        public void DrawImage(IImage source, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode = default)
        {
            _ = source ?? throw new ArgumentNullException(nameof(source));

            source.Draw(this, sourceRect, destRect, bitmapInterpolationMode);
        }
Exemplo n.º 55
0
        /// <summary>
        /// Draws an image.
        /// </summary>
        /// <param name="source">The image.</param>
        /// <param name="rect">The rect in the output to draw to.</param>
        public void DrawImage(IImage source, Rect rect)
        {
            _ = source ?? throw new ArgumentNullException(nameof(source));

            DrawImage(source, new Rect(source.Size), rect);
        }
Exemplo n.º 56
0
        /// <summary>
        /// Draws an image.
        /// </summary>
        /// <param name="source">The image.</param>
        /// <param name="rect">The rect in the output to draw to.</param>
        public void DrawImage(IImage source, Rect rect)
        {
            Contract.Requires <ArgumentNullException>(source != null);

            DrawImage(source, new Rect(source.Size), rect);
        }
        public async Task <ILink> CreateLinkForUserAsync(ILink toBeCreatedLink, IGeneralUser user)
        {
            using (_dbContext)
            {
                var   strategy = _dbContext.Database.CreateExecutionStrategy();
                ILink ILink    = default;
                await strategy.Execute(async() =>
                {
                    using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                    {
                        Link dbLink = _mapper.Map <ILink, Link>(toBeCreatedLink);
                        if (dbLink == default)
                        {
                            throw new ArgumentNullException(nameof(dbLink));
                        }

                        // Validate and save Interests
                        if (toBeCreatedLink.Interests != null)
                        {
                            foreach (IInterest iInterest in toBeCreatedLink.Interests)
                            {
                                Interest interest = _dbContext.Interests.SingleOrDefault(t => t.Id == iInterest.Id);
                                if (interest == default)
                                {
                                    throw new ArgumentException($"Interest ID: {iInterest.Id} could not be found.");
                                }

                                LinkInterest newLinkInterest = new LinkInterest
                                {
                                    InterestId = iInterest.Id
                                };
                                dbLink.LinkInterests.Add(newLinkInterest);
                            }
                        }

                        // Empty accidentally entered ImageWebUrl if uploadImageType is base64
                        if (dbLink.ImageType == UploadImageType.Base64 && dbLink.ImageWebUrl != null)
                        {
                            dbLink.ImageWebUrl = null;
                        }

                        // Set User
                        dbLink.GeneralUserId = user.Id;

                        // Prefix url
                        string[] httpPrefixes = { "http://", "https://" };
                        bool prefixMatch      = httpPrefixes.Any(prefix => dbLink.Url.StartsWith(prefix));
                        if (!prefixMatch)
                        {
                            dbLink.Url = "https://" + dbLink.Url;
                        }

                        // Save
                        _dbContext.Links.Add(dbLink);
                        await _dbContext.SaveChangesAsync();
                        ILink = _mapper.Map <Link, ILink>(dbLink);

                        // save Image to AWS S3
                        if (toBeCreatedLink.ImageType == UploadImageType.Base64 && toBeCreatedLink.Image != null)
                        {
                            IImage linkImage = await _awsS3Service.UploadLinkImageAsync(toBeCreatedLink.Image, ILink);
                            ILink.Image      = linkImage;
                        }

                        // Commit transaction if all commands succeed, transaction will auto-rollback
                        // when disposed if either commands fails
                        transaction.Complete();
                    }
                });

                return(ILink);
            }
        }
Exemplo n.º 58
0
 public static void DrawImage(this ICanvas canvas, IImage image)
 {
     canvas.DrawImage(image, new Rect(image.Size));
 }
Exemplo n.º 59
0
 /// <summary>
 /// Sets each image byte to zero (using kernel function memset).
 /// </summary>
 public static void Clear(this IImage image)
 {
     SetByte(image.ImageData, image.Width * image.ColorInfo.Size, image.Height, image.Stride, 0);
 }
Exemplo n.º 60
0
 public void DrawImage(IImage image)
 {
     ((IRendererExtended)Renderer).DrawImage(image);
 }