static void Main(string[] args) { var badges = new Encoder.Encoder().Encode(EncodeType.Broadcast, Protocol.ASCII, @"abded"); var result = new Encoder.Encoder().Decode(badges); var map = new Map(); using (var img = new ImageProducer().ProduceImage(badges, map.MapMatrix)) img.Save(PosRetriever.DebugDir + @"output2.jpg"); var dir = @"C:\Users\qqytqqyt\source\repos\BadgeReader\BadgeReader.Tests\Resources\"; var fileInfo = new FileInfo(dir + "test16.jpg"); var posRetriever = new PosRetriever(); PosRetriever.Debug = true; using (var croppedImg = posRetriever.RetrievePanel(fileInfo.FullName)) { var dots = posRetriever.PrintDots(croppedImg, map.MapMatrix); var results = PosRetriever.ReadDots(dots); using (var img = new ImageProducer().ProduceImage(results, map.MapMatrix)) img.Save(PosRetriever.DebugDir + @"output.jpg"); File.WriteAllText(@"C:\Users\qqytqqyt\OneDrive\Documents\OneDrive\OwnProjects\Combination\freetest\" + fileInfo.Name + ".json", @JsonConvert.SerializeObject(results)); } Console.WriteLine("Hello World!"); }
/// <summary> /// This is a utility method to help in loading icon images. /// It takes the name of a resource file associated with the /// current object's class file and loads an image object /// from that file. Typically images will be GIFs. /// <para> /// </para> /// </summary> /// <param name="resourceName"> A pathname relative to the directory /// holding the class file of the current class. For example, /// "wombat.gif". </param> /// <returns> an image object. May be null if the load failed. </returns> //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: //ORIGINAL LINE: public java.awt.Image loadImage(final String resourceName) public virtual Image LoadImage(String resourceName) { try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.net.URL url = getClass().getResource(resourceName); URL url = this.GetType().getResource(resourceName); if (url != null) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.awt.image.ImageProducer ip = (java.awt.image.ImageProducer) url.getContent(); ImageProducer ip = (ImageProducer)url.Content; if (ip != null) { return(Toolkit.DefaultToolkit.CreateImage(ip)); } } } //JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not allowed in C#: //ORIGINAL LINE: catch (final Exception ignored) catch (ception) { } return(null); }
/// <summary> /// Create a PixelGrabber object to grab the (x, y, w, h) rectangular /// section of pixels from the specified image. The pixels are /// accumulated in the original ColorModel if the same ColorModel /// is used for every call to setPixels, otherwise the pixels are /// accumulated in the default RGB ColorModel. If the forceRGB /// parameter is true, then the pixels will be accumulated in the /// default RGB ColorModel anyway. A buffer is allocated by the /// PixelGrabber to hold the pixels in either case. If {@code (w < 0)} or /// {@code (h < 0)}, then they will default to the remaining width and /// height of the source data when that information is delivered. </summary> /// <param name="img"> the image to retrieve the image data from </param> /// <param name="x"> the x coordinate of the upper left corner of the rectangle /// of pixels to retrieve from the image, relative to the default /// (unscaled) size of the image </param> /// <param name="y"> the y coordinate of the upper left corner of the rectangle /// of pixels to retrieve from the image </param> /// <param name="w"> the width of the rectangle of pixels to retrieve </param> /// <param name="h"> the height of the rectangle of pixels to retrieve </param> /// <param name="forceRGB"> true if the pixels should always be converted to /// the default RGB ColorModel </param> public PixelGrabber(Image img, int x, int y, int w, int h, bool forceRGB) { Producer = img.Source; DstX = x; DstY = y; DstW = w; DstH = h; if (forceRGB) { ImageModel = ColorModel.RGBdefault; } }
/// <summary> /// Create a PixelGrabber object to grab the (x, y, w, h) rectangular /// section of pixels from the image produced by the specified /// ImageProducer into the given array. /// The pixels are stored into the array in the default RGB ColorModel. /// The RGB data for pixel (i, j) where (i, j) is inside the rectangle /// (x, y, w, h) is stored in the array at /// <tt>pix[(j - y) * scansize + (i - x) + off]</tt>. </summary> /// <param name="ip"> the <code>ImageProducer</code> that produces the /// image from which to retrieve pixels </param> /// <param name="x"> the x coordinate of the upper left corner of the rectangle /// of pixels to retrieve from the image, relative to the default /// (unscaled) size of the image </param> /// <param name="y"> the y coordinate of the upper left corner of the rectangle /// of pixels to retrieve from the image </param> /// <param name="w"> the width of the rectangle of pixels to retrieve </param> /// <param name="h"> the height of the rectangle of pixels to retrieve </param> /// <param name="pix"> the array of integers which are to be used to hold the /// RGB pixels retrieved from the image </param> /// <param name="off"> the offset into the array of where to store the first pixel </param> /// <param name="scansize"> the distance from one row of pixels to the next in /// the array </param> /// <seealso cref= ColorModel#getRGBdefault </seealso> public PixelGrabber(ImageProducer ip, int x, int y, int w, int h, int[] pix, int off, int scansize) { Producer = ip; DstX = x; DstY = y; DstW = w; DstH = h; DstOff = off; DstScan = scansize; IntPixels = pix; ImageModel = ColorModel.RGBdefault; }
public MainWindow() { InitializeComponent(); _buttonListener = new ButtonListener(ButtonPressHandler); // Setup key actions _keyActions.Add(Key.Left, NextBackgroundImage); _keyActions.Add(Key.Right, PrevBackgroundImage); _keyActions.Add(Key.Up, IncreaseDepthThreshold); _keyActions.Add(Key.Down, DecreaseDepthThreshold); _keyActions.Add(Key.Space, TakePicture); _keyActions.Add(Key.B, TakeBackgroundPicture); // Setup button actions _buttonActions.Add(0, TakePicture); // pin 2 _buttonActions.Add(1, NextBackgroundImage); // pin 3 _buttonActions.Add(2, PrevBackgroundImage); // pin 4 _buttonActions.Add(3, IncreaseDepthThreshold); // pin 5 _buttonActions.Add(4, DecreaseDepthThreshold); // pin 6 StartDialog startDialog = new StartDialog(); startDialog.ShowDialog(); _imageSavePath = startDialog.ImageSavePath; _printManager = PrintManager.GetInstance(startDialog.Name, startDialog.PrintCount); _printManager.SetPrintErrorInformer(HandlePrintError); _currentBatch = _printManager.startNewBatch(PrintTemplateType.Wide); _imageProducer = ImageProducerFactory.GetImageProducer(); _imageProducer.Start(); // Setup the background images _centerCarouselImageIndex = _carouselSize / 2; _carouselItemHeight = (double)_carouselWidth * (108.0f / 192.0f); LoadBackgroundImages(); SetBackgroundImage(); BuildCarousel(); _queue = _imageProducer.GetImageQueue(); _consumer = new Thread(new ThreadStart(Consume)); _consumer.Start(); UpdateStatus(); SetupStates(); }
public Tester() { BitmapImage backgroundImage = new BitmapImage(new Uri("pack://application:,,,/enterprise-D-bridge.bmp", UriKind.RelativeOrAbsolute)); backgroundImage.Freeze(); ImageProducerConfiguration config = ImageProducerConfiguration.Simple("backgroundImage", backgroundImage); //InitializeComponent(); _imageProducer = ImageProducerFactory.GetImageProducer(); _imageProducer.Start(); _imageProducer.SetConfiguration(config); _queue = _imageProducer.GetImageQueue(); _consumer = new Thread(new ThreadStart(Consume)); _consumer.Start(); this.Closing += Tester_Closing; }
/// <summary> /// Responds to a request for a TopDownLeftRight (TDLR) ordered resend /// of the pixel data from an <code>ImageConsumer</code>. /// When an <code>ImageConsumer</code> being fed /// by an instance of this <code>ImageFilter</code> /// requests a resend of the data in TDLR order, /// the <code>FilteredImageSource</code> /// invokes this method of the <code>ImageFilter</code>. /// /// <para> /// /// An <code>ImageFilter</code> subclass might override this method or not, /// depending on if and how it can send data in TDLR order. /// Three possibilities exist: /// /// <ul> /// <li> /// Do not override this method. /// This makes the subclass use the default implementation, /// which is to /// forward the request /// to the indicated <code>ImageProducer</code> /// using this filter as the requesting <code>ImageConsumer</code>. /// This behavior /// is appropriate if the filter can determine /// that it will forward the pixels /// in TDLR order if its upstream producer object /// sends them in TDLR order. /// /// <li> /// Override the method to simply send the data. /// This is appropriate if the filter can handle the request itself — /// for example, /// if the generated pixels have been saved in some sort of buffer. /// /// <li> /// Override the method to do nothing. /// This is appropriate /// if the filter cannot produce filtered data in TDLR order. /// </ul> /// /// </para> /// </summary> /// <seealso cref= ImageProducer#requestTopDownLeftRightResend </seealso> /// <param name="ip"> the ImageProducer that is feeding this instance of /// the filter - also the ImageProducer that the request should be /// forwarded to if necessary </param> /// <exception cref="NullPointerException"> if <code>ip</code> is null </exception> public virtual void ResendTopDownLeftRight(ImageProducer ip) { ip.RequestTopDownLeftRightResend(this); }
/// <summary> /// Creates an image from the specified image producer. /// </summary> public Image createImage(ImageProducer @producer) { return default(Image); }
/// <summary> /// Creates an image from the specified image producer. /// </summary> public Image createImage(ImageProducer @producer) { return(default(Image)); }
/// <summary> /// Constructs an ImageProducer object from an existing ImageProducer /// and a filter object. </summary> /// <param name="orig"> the specified <code>ImageProducer</code> </param> /// <param name="imgf"> the specified <code>ImageFilter</code> </param> /// <seealso cref= ImageFilter </seealso> /// <seealso cref= java.awt.Component#createImage </seealso> public FilteredImageSource(ImageProducer orig, ImageFilter imgf) { Src = orig; Filter = imgf; }