!7 module WebCamPixelated > DynImageSurface { int width = 16; transient BufferedImage lastImage; start { doEvery(1000, rstUpdate()); } void enhanceFrame(Container f) { super.enhanceFrame(f); dm_intFieldMenuItem(f, 'width, onSet := r { setField(lastImage := null) }, formTitle := "Set Pixelated Image Width"); } visualize { JComponent c = super.visualize(); imageSurface.noAlpha = true; imageSurface.interpolationMode = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR; ret c; } void update { if (imageSurface == null) ret; final BufferedImage img = dm_webCamImage(); temp tempAfterwards(r { lastImage = img }); if (img == null || img == lastImage) ret; setZoom(doubleRatio(img.getWidth(), width)); setImage(resizeImage(img, width)); } }