Java Code Examples for org.eclipse.swt.graphics.ImageLoader#load()

The following examples show how to use org.eclipse.swt.graphics.ImageLoader#load() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: URLImageLabel.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void processLoad ( final String stringUrl ) throws Exception
{
    final ImageLoader loader = new ImageLoader ();

    final URL url = new URL ( stringUrl );

    final ImageData[] data;
    try ( InputStream is = url.openStream () )
    {
        data = loader.load ( is );
    }

    logger.debug ( "Image loaded" );

    Display.getDefault ().asyncExec ( new Runnable () {
        @Override
        public void run ()
        {
            showImage ( stringUrl, data );
        }
    } );
}
 
Example 2
Source File: ComponentStatusLabel.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the GIF
 *
 * @param inputStream
 */
public void setGIF(InputStream inputStream) {
    checkWidget();
    if (thread != null) {
        thread.stop();
        this.getDisplay().timerExec(-1, thread);
    }

    ImageLoader loader = new ImageLoader();

    try {
        loader.load(inputStream);
    } catch (Exception e) {
        this.image = null;
        return;
    }

    if (loader.data[0] != null) this.image = new Image(this.getDisplay(), loader.data[0]);

    if (loader.data.length > 1) {
        thread = new ComponentStatusLabelGIFHandler(this, loader);
        thread.run();
    }

    redraw();
}
 
Example 3
Source File: MImageSWTImpl.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the {@link BufferedImage} from the given {@link MImage}.
 * 
 * @param image
 *            the {@link MImage}
 * @return the {@link BufferedImage} from the given {@link MImage}
 * @throws IOException
 *             if the image can't be read
 */
public static ImageData getImage(MImage image) throws IOException {
    final ImageData res;

    final ImageLoader imageLoader = new ImageLoader();
    if (image instanceof MImageSWTImpl) {
        res = ((MImageSWTImpl) image).image;
    } else {
        try (InputStream input = image.getInputStream()) {
            res = imageLoader.load(input)[0];
        }
    }

    return res;
}
 
Example 4
Source File: Animator.java    From http4e with Apache License 2.0 5 votes vote down vote up
void start(){
   if(gifRunner != null) gifRunner.stop();
   try {
      ImageLoader imageLoader = new ImageLoader();
      imageLoader.load( ResourceUtils.getBundleResourceStream(CoreConstants.PLUGIN_CORE, CoreImages.LOADING_ON));
      gifRunner = new AnimatedGIFRunner(parent, imageLoader, backgroundImage);
   } catch (Exception e) {
      throw CoreException.getInstance(CoreException.GENERAL, e);
   }
   final Thread animeThread = new Thread(gifRunner);
   animeThread.setDaemon(true);
   animeThread.start();
}
 
Example 5
Source File: ChartLivePreviewThread.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
PreviewTimerTask( String taskName, Shell parentShell ) throws IOException
{
	this.taskName = taskName;
	this.parentShell = parentShell;
	if ( imageDatas == null )
	{
		loader = new ImageLoader();
		imageDatas = loader.load( UIHelper.getURL( "icons/obj16/progress_animation.gif" ).openStream( ) ); //$NON-NLS-1$
	}
}
 
Example 6
Source File: UiDBImage.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public UiDBImage(String prefix, final String name, final InputStream source){
	this.dbImage = new DBImage(prefix, name);
	try {
		ImageLoader iml = new ImageLoader();
		iml.load(source);
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		iml.save(baos, SWT.IMAGE_PNG);
		dbImage.setBinary(DBImage.FLD_IMAGE, baos.toByteArray());
	} catch (IllegalArgumentException | SWTException e) {
		log.error("Error setting image object on DBImage " + dbImage.getLabel(), e);
	}
}
 
Example 7
Source File: CloudioUiBundle.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
private void loadImage(ImageLoader il, String fileName) throws IOException {
	InputStream stream = getBundle().getResource("icons/" + fileName).openStream();
	ImageData[] data = il.load(stream);
	Image image = new Image(Display.getDefault(), data[0]);
	getImageRegistry().put(fileName, image);
}