1 #!/usr/bin/env dub 2 /+ 3 dub.sdl: 4 name "snippet_jpeg_image" 5 dependency "dwt" path="../../../../../../" 6 stringImportPaths "../../../../../res" 7 libs \ 8 "atk-1.0" \ 9 "cairo" \ 10 "dl" \ 11 "fontconfig" \ 12 "gdk-x11-2.0" \ 13 "gdk_pixbuf-2.0" \ 14 "glib-2.0" \ 15 "gmodule-2.0" \ 16 "gnomeui-2" \ 17 "gnomevfs-2" \ 18 "gobject-2.0" \ 19 "gthread-2.0" \ 20 "gtk-x11-2.0" \ 21 "pango-1.0" \ 22 "pangocairo-1.0" \ 23 "X11" \ 24 "Xcomposite" \ 25 "Xcursor" \ 26 "Xdamage" \ 27 "Xext" \ 28 "Xfixes" \ 29 "Xi" \ 30 "Xinerama" \ 31 "Xrandr" \ 32 "Xrender" \ 33 "Xtst" \ 34 platform="linux" 35 +/ 36 37 /** 38 * Author: kntroh 39 * License: CC0(http://creativecommons.org/publicdomain/zero/1.0/) 40 */ 41 module org.eclipse.swt.snippets.SnippetJPEGImage; 42 43 /** 44 * This program snippet is the test of displaying a JPEG image. 45 */ 46 import org.eclipse.swt.all; 47 import java.io.ByteArrayInputStream; 48 49 void main() { 50 auto d = new Display; 51 auto s = new Shell(d); 52 s.setText("JPEG Image"); 53 s.setLayout(new GridLayout(1, false)); 54 55 auto l = new Label(s, SWT.NONE); 56 auto bin = new ByteArrayInputStream(cast(byte[])import("jpegimage.jpg")); 57 auto img = new Image(d, new ImageData(bin)); 58 l.setImage(img); 59 60 s.pack(); 61 s.open(); 62 63 while (!s.isDisposed()) 64 if (!d.readAndDispatch()) 65 d.sleep(); 66 67 img.dispose(); 68 d.dispose(); 69 }