Java 类org.eclipse.swt.graphics.ImageLoader 实例源码

项目:neoscada    文件:URLImageLabel.java   
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 );
        }
    } );
}
项目:AppleCommander    文件:SwtImage.java   
/**
 * Save the image.
 */
public void save(OutputStream outputStream) throws IOException {
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageData };
    int format = SWT.IMAGE_PNG;
    if ("BMP".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP;
    } else if ("RLE".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP_RLE;
    } else if ("GIF".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_GIF;
    } else if ("ICO".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_ICO;
    } else if ("JPEG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_JPEG;
    } else if ("PNG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_PNG;
    }
    imageLoader.save(outputStream, format);
}
项目:applecommander    文件:SwtImage.java   
/**
 * Save the image.
 */
public void save(OutputStream outputStream) throws IOException {
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageData };
    int format = SWT.IMAGE_PNG;
    if ("BMP".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP;
    } else if ("RLE".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_BMP_RLE;
    } else if ("GIF".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_GIF;
    } else if ("ICO".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_ICO;
    } else if ("JPEG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_JPEG;
    } else if ("PNG".equals(getFileExtension())) { //$NON-NLS-1$
        format = SWT.IMAGE_PNG;
    }
    imageLoader.save(outputStream, format);
}
项目:workspacemechanic    文件:MechanicPopupTest.java   
public File copyWidgetToFile(Control control) throws IOException {
  File file = File.createTempFile("MechanicalPopupTest", "jpg");
  file.deleteOnExit();
  Point size = control.getSize();
  GC gc = new GC(control);
  Image image = null;
  try {
    image = new Image(control.getDisplay(), size.x, size.y);
    gc.copyArea(image, 0, 0);
    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] {image.getImageData()};
    loader.save(file.getPath(), SWT.IMAGE_JPEG);
  } finally {
    gc.dispose();
    if (image != null) {
      image.dispose();
    }
  }
  return file;
}
项目:TuxGuitar-1.3.1-fork    文件:ImageWriter.java   
public static void write(ImageFormat format, String path, List<ImageData> pages) throws TGFileFormatException {
    try {
        for(int i = 0; i < pages.size() ; i ++ ) {
            OutputStream stream = new FileOutputStream(new File(path + File.separator + "page-" + i + format.getExtension() ));

            ImageLoader loader = new ImageLoader();
            loader.data = new ImageData[] { (ImageData)pages.get(i) };
            loader.save(stream, format.getFormat() );

            stream.flush();
            stream.close();
        }
    } catch (Throwable throwable) {
        throw new TGFileFormatException("Could not write song!.",throwable);
    }
}
项目:xstreamer    文件:ImageViewSaveAsHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    ImageView imageView = (ImageView) activePart;
    SWTImageCanvas imageCanvas = imageView.imageCanvas;
    if (imageCanvas == null) {
        return null;
    }

    Shell shell = HandlerUtil.getActiveShell(event);

    FileDialog dialog = new FileDialog(shell, SWT.SAVE);
    dialog.setFilterExtensions(new String[] { "*.png", "*.*" });
    dialog.setFilterNames(new String[] { "PNG Files", "All Files" });
    String fileSelected = dialog.open();

    if (fileSelected != null) {
        ImageLoader imageLoader = new ImageLoader();
        imageLoader.data = new ImageData[] { imageCanvas.getImageData() };

        System.out.println("Selected file: " + fileSelected);
        imageLoader.save(fileSelected, SWT.IMAGE_PNG);
    }

    return null;
}
项目:xstreamer    文件:AbstractImageSelectionListener.java   
protected void saveImage(String filename, ImageView imageView, int imageType) {
    IPreferenceStore store = us.nineworlds.xstreamer.Activator.getDefault().getPreferenceStore();
    String outputDirectory = store.getString(PreferenceConstants.TEMPLATE_XSTREAMER_XWING_OUTPUT_DIRECTORY);
    if (outputDirectory == null || imageView == null) {
        return;
    }

    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageView.imageCanvas.getImageData() };
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new File(outputDirectory, filename));
        imageLoader.save(outputStream, imageType);
    } catch (FileNotFoundException e) {
        Logger.error("Unable to save image to file: " + filename, e);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}
项目:xstreamer    文件:SquadSelectionChangeListener.java   
private void saveImage(String filename, ImageView imageView) {
    IPreferenceStore store = us.nineworlds.xstreamer.Activator.getDefault().getPreferenceStore();
    String outputDirectory = store.getString(us.nineworlds.xstreamer.preferences.PreferenceConstants.TEMPLATE_XSTREAMER_XWING_OUTPUT_DIRECTORY);
    if (outputDirectory == null || imageView == null) {
        return;
    }
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageView.imageCanvas.getImageData() };        
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new File(outputDirectory, filename));
        imageLoader.save(outputStream, SWT.IMAGE_PNG);
    } catch (IOException e) {
        Logger.error("Unable to save image to file: " + filename, e);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}
项目:xstreamer    文件:AbstractImageSelectionListener.java   
protected void saveImage(String filename, ImageView imageView, int imageType) {
    IPreferenceStore store = us.nineworlds.xstreamer.ia.Activator.getDefault().getPreferenceStore();
    String outputDirectory = store.getString(PreferenceConstants.TEMPLATE_XSTREAMER_IA_OUTPUT_DIRECTORY);
    if (outputDirectory == null || imageView == null) {
        return;
    }

    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { imageView.imageCanvas.getImageData() };
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new File(outputDirectory, filename));
        imageLoader.save(outputStream, imageType);
    } catch (FileNotFoundException e) {
        Logger.error("Unable to save image to file: " + filename, e);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}
项目:mesfavoris    文件:IconImageDescriptor.java   
private ImageData loadImageData() {
    ImageData[] imageDatas;
    try {
        imageDatas = new ImageLoader().load(new ByteArrayInputStream(favIconBytes));
    } catch (SWTException e) {
        return null;
    }
    Optional<ImageData> optionalImageData = Arrays.stream(imageDatas).sorted((imageData1,
            imageData2) -> distanceFrom16x16ImageData(imageData1) - distanceFrom16x16ImageData(imageData2))
            .findFirst();
    if (!optionalImageData.isPresent()) {
        return null;
    }
    ImageData imageData = optionalImageData.get();
    if (imageData.width <= 16 && imageData.height <= 16) {
        return imageData;
    }
    return imageData.scaledTo(16, 16);
}
项目:ether    文件:GIFAccess.java   
public GIFAccess(URLVideoSource src, int numPlays) throws IOException, URISyntaxException {
    super(src, numPlays);
    ImageLoader loader = new ImageLoader();
    ImageData[] images = loader.load(src.getURL().openStream());
    for(int i = 0; i < images.length; i++) {
        width  = Math.max(width,  images[i].x + images[i].width); 
        height = Math.max(height, images[i].y + images[i].height); 
    }
    nClips = images[0].delayTime - 10;
    if (nClips > 0 && images.length > (nClips * 2 + 1))
        shotStarts = new int[nClips];
    else
        nClips = 1;
    for(int i = 0; i < images.length; i++)
        frames.add(convert(i, i == 0 ? null : frames.get(i-1), images[i]));
    if(shotStarts != null) {
        duration /= nClips * 1000.0;
        duration *= images.length;
    }
    if(shotStarts != null)
        for(int i = 1; i < shotStarts.length; i++)
            shotStarts[i] += shotStarts[i-1];
}
项目:scenarioo-example-swtbot-e4    文件:ScreenShooter.java   
/**
 * @see java.lang.Runnable#run()
 */
@Override
public byte[] run() {
    final Display display = Display.getDefault();
    Image image = new Image(display, biggestRectangle);
    GC gc = new GC(Display.getDefault());
    gc.copyArea(image, biggestRectangle.x, biggestRectangle.y);

    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { image.getImageData() };
    ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
    imageLoader.save(byteOutput, SWT.IMAGE_PNG);
    data = byteOutput.toByteArray();

    gc.dispose();
    return data;
}
项目:plan    文件:GanttView.java   
public void run() { 
    //new Rectangle(0,0,640,480)
    Image img = ganttChart.getGanttComposite().getImage();
    FileDialog fileDialog = new FileDialog(Display.getCurrent().getActiveShell(),SWT.SAVE);
    // Set the text
    fileDialog.setText("Select File");
    // Set filter on .txt files
    fileDialog.setFilterExtensions(new String[] { "*.png" });
    // Put in a readable name for the filter
    // fileDialog.setFilterNames(new String[] { "Textfiles(*.txt)" });
    // Open Dialog and save result of selection
    String selected = fileDialog.open();
    //System.out.println("SELECTED: "+selected);
    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] {img.getImageData()};
    loader.save(selected, SWT.IMAGE_PNG);

}
项目:scouter    文件:XYGraphToolbar.java   
private void addSnapshotButton() {
    Button snapShotButton = new Button(XYGraphMediaFactory.getInstance().getImage("images/camera.gif"));
    snapShotButton.setToolTip(new Label("Save Snapshot to PNG file"));
    addButton(snapShotButton);
    snapShotButton.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent event) {
             // Have valid name, so get image
               ImageLoader loader = new ImageLoader();
               Image image = xyGraph.getImage();
               loader.data = new ImageData[]{image.getImageData()};
               image.dispose();
            // Prompt for file name
            String path = SingleSourceHelper.getImageSavePath();
            if (path == null || path.length() <= 0)
                return;            
            // Assert *.png at end of file name
            if (! path.toLowerCase().endsWith(".png"))
                path = path + ".png";
            // Save
            loader.save(path, SWT.IMAGE_PNG);
        }
    });
}
项目:drinviewer    文件:DrinImageLoader.java   
public byte[] getScaled (int longestSidePx) {

    ImageData[] imageData = null;

    if (data.length > 0) {
        imageData = new ImageData[data.length];
        for (int i=0; i < data.length; i++) {

            // return the image proportionally scaled, having the longest side to longestSidePx
            if (data[i].height>=data[i].width)
                imageData[i] = data[i].scaledTo((int) ((float)data[i].width / (float)data[i].height * longestSidePx), longestSidePx);
            else
                imageData[i] = data[i].scaledTo(longestSidePx,(int) ((float)data[i].height / (float)data[i].width * longestSidePx));
        }
    }

    ImageLoader temp = new ImageLoader();
    temp.data = imageData;

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    temp.save(out, SWT.IMAGE_PNG);
    return out.toByteArray();
}
项目:developer-studio    文件:GetWizardIconDataFunction.java   
public String getImagaeData(String id) throws CoreException {
    // First see if this is a "new wizard".
    IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(id);
    // If not check if it is an "import wizard".
    if (descriptor == null) {
        descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(id);
    }
    // Or maybe an export wizard
    if (descriptor == null) {
        descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(id);
    }
    // Then if we have a wizard, open it.
    if (descriptor != null) {       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ImageLoader loader = new ImageLoader();
        loader.data = new ImageData[] { descriptor.getImageDescriptor().getImageData() };
        loader.save(out, SWT.IMAGE_PNG);
        String base64 = Base64.encodeBase64String(out.toByteArray());
        return base64;
    }
    return null;
}
项目:LIMBO    文件:PlotCanvas.java   
/**
 * Save the plot canvas' graph to an image file.
 *
 * @param path the path
 * @param width the width
 * @param height the height
 */
public void savePlotCanvasImage(String path, int width, int height) {
    Display display = this.getDisplay();
    Image image = new Image(display, width, height);
    // Font font = new Font(display, "Arial", 24, SWT.BOLD);

    paintOnDisplay(display, image, width, height);

    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] { image.getImageData() };
    loader.save(path, SWT.IMAGE_PNG);

    // font.dispose();
    image.dispose();
    // display.dispose();
}
项目:eclipsegraphviz    文件:AbstractGraphicalContentProvider.java   
/**
 * {@inheritDoc}
 * 
 * This default implementation relies on the
 * {@link #loadImage(Display, Point, Object)} method, subclasses are
 * encouraged to provide a more efficient implementation.
 */
public void saveImage(Display display, Point suggestedSize, Object input, IPath location, GraphicFileFormat fileFormat)
        throws CoreException {
    int swtFileFormat = getSWTFileFormat(fileFormat);
    Image toSave = loadImage(Display.getDefault(), new Point(0, 0), input);
    try {
        ImageLoader imageLoader = new ImageLoader();
        imageLoader.data = new ImageData[] { toSave.getImageData() };
        ByteArrayOutputStream buffer = new ByteArrayOutputStream(200 * 1024);
        imageLoader.save(buffer, swtFileFormat);
        try {
            FileUtils.writeByteArrayToFile(location.toFile(), buffer.toByteArray());
        } catch (IOException e) {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error saving image", e));
        }
    } finally {
        toSave.dispose();
    }
}
项目:geokettle-2.0    文件:ImageDataTransfer.java   
protected Object nativeToJava(TransferData transferData) {
        final Object o = super.nativeToJava(transferData);
        final byte[] bytes = (byte[]) o;

        try {
                final InputStream bis = new PrependWinBMPHeaderFilterInputStream(
                                new UncompressDibFilterInputStream(new ByteArrayInputStream(
                                                bytes)));
                final ImageData[] data = new ImageLoader().load(bis);
                if (data.length < 1) {
                        return null;
                }
                return data[0];
        } catch (IOException e) {
                return null;
        }
}
项目:read-open-source-code    文件:ImageDataTransfer.java   
protected Object nativeToJava(TransferData transferData) {
        final Object o = super.nativeToJava(transferData);
        final byte[] bytes = (byte[]) o;

        try {
                final InputStream bis = new PrependWinBMPHeaderFilterInputStream(
                                new UncompressDibFilterInputStream(new ByteArrayInputStream(
                                                bytes)));
                final ImageData[] data = new ImageLoader().load(bis);
                if (data.length < 1) {
                        return null;
                }
                return data[0];
        } catch (IOException e) {
                return null;
        }
}
项目:JustDoIt-A-Task-Manager    文件:GUI.java   
/**
 * This method generate a region from a background image
 * 
 * @param display
 *            is the display area of this region
 * @param image
 *            is the file path of the background image
 */
public static Region getBackRegionFromImage(Display display, String image) {

    ImageLoader loader = new ImageLoader();
    ImageData[] imageData = loader.load(ResourceLoader.load(image));
    Region region = new Region(display);
    ImageData data = imageData[0];
    ImageData mask = data.getTransparencyMask();
    org.eclipse.swt.graphics.Rectangle pixel = new org.eclipse.swt.graphics.Rectangle(
            0, 0, 1, 1);
    for (int y = 0; y < mask.height; y++) {
        for (int x = 0; x < mask.width; x++) {
            if (mask.getPixel(x, y) != 0) {
                pixel.x = data.x + x;
                pixel.y = data.y + y;
                region.add(pixel);
            }
        }
    }
    return region;
}
项目:kettle-4.4.0-stable    文件:ImageDataTransfer.java   
protected Object nativeToJava(TransferData transferData) {
        final Object o = super.nativeToJava(transferData);
        final byte[] bytes = (byte[]) o;

        try {
                final InputStream bis = new PrependWinBMPHeaderFilterInputStream(
                                new UncompressDibFilterInputStream(new ByteArrayInputStream(
                                                bytes)));
                final ImageData[] data = new ImageLoader().load(bis);
                if (data.length < 1) {
                        return null;
                }
                return data[0];
        } catch (IOException e) {
                return null;
        }
}
项目:kettle-trunk    文件:ImageDataTransfer.java   
protected Object nativeToJava(TransferData transferData) {
        final Object o = super.nativeToJava(transferData);
        final byte[] bytes = (byte[]) o;

        try {
                final InputStream bis = new PrependWinBMPHeaderFilterInputStream(
                                new UncompressDibFilterInputStream(new ByteArrayInputStream(
                                                bytes)));
                final ImageData[] data = new ImageLoader().load(bis);
                if (data.length < 1) {
                        return null;
                }
                return data[0];
        } catch (IOException e) {
                return null;
        }
}
项目:seg.jUCMNav    文件:ExportImageGIF.java   
/**
 * Given the IFigure, save it to a file.
 * 
 * GIFs can only be saved with an 8 bit color depth.
 * 
 * @see seg.jUCMNav.extensionpoints.IUseCaseMapExport#export(org.eclipse.draw2d.IFigure, java.io.FileOutputStream)
 */
public void export(IFigure pane, FileOutputStream fos) {
    // generate image
    Image image = new Image(Display.getCurrent(), pane.getSize().width, pane.getSize().height);

    GC gc = new GC(image);
    SWTGraphics graphics = new SWTGraphics(gc);
    // if the bounds are in the negative x/y, we don't see them without a
    // translation
    graphics.translate(-pane.getBounds().x, -pane.getBounds().y);
    pane.paint(graphics);

    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] { downSample(image) };
    loader.save(fos, getType());

    gc.dispose();
    image.dispose();
}
项目:seg.jUCMNav    文件:ExportImage.java   
/**
 * Given the IFigure, save it to a file.
 * 
 * @see seg.jUCMNav.extensionpoints.IUseCaseMapExport#export(org.eclipse.draw2d.IFigure, java.io.FileOutputStream)
 */
public void export(IFigure pane, FileOutputStream fos) {
    // generate image
    Image image = new Image(Display.getCurrent(), pane.getSize().width, pane.getSize().height);
    GC gc = new GC(image);
    SWTGraphics graphics = new SWTGraphics(gc);
    // if the bounds are in the negative x/y, we don't see them without a translation
    graphics.translate(-pane.getBounds().x, -pane.getBounds().y);
    pane.paint(graphics);

    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] { ReportUtils.cropImage(image.getImageData()) };
    // loader.data = new ImageData[] { image.getImageData() };
    loader.save(fos, getType());

    gc.dispose();
    image.dispose();
}
项目:arx    文件:ComponentStatusLabel.java   
/**
 * 
 *
 * @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();
}
项目:VonRep    文件:FrequencyDialog.java   
private void storePicture(){
    Rectangle rect=this.canvas.getClientArea();
    Image image=new Image(this.canvas.getDisplay(),rect.width,rect.height);
    this.gC.copyArea(image,0,0);
    ImageLoader loader=new ImageLoader();
    loader.data=new ImageData[]{image.getImageData()};
    FileDialog path=new FileDialog(this.shell,SWT.SAVE);
    path.setFileName("频率图");
    path.setFilterNames(new String[]{"JPEG(*.jpeg)"});
    path.setFilterExtensions(new String[]{"*.jpeg"});
    String pathStr=path.open();
    if (pathStr!=null) {
        loader.save(pathStr, SWT.IMAGE_JPEG);
        MessageDialog.openInformation(shell,"保存图片","操作完成:"+pathStr);
    }
}
项目:VonRep    文件:PicStore.java   
private void storePicture(){
    Rectangle rect=this.canvas.getClientArea();
    Image image=new Image(this.canvas.getDisplay(),rect.width,rect.height);
    this.gC.copyArea(image,0,0);
    ImageLoader loader=new ImageLoader();
    loader.data=new ImageData[]{image.getImageData()};
    FileDialog path=new FileDialog(this.shell,SWT.SAVE);
    path.setFileName("Ƶ��ͼ");
    path.setFilterNames(new String[]{"JPEG(*.jpeg)"});
    path.setFilterExtensions(new String[]{"*.jpeg"});
    String pathStr=path.open();
    if (pathStr!=null) {
        loader.save(pathStr, SWT.IMAGE_JPEG);
        MessageDialog.openInformation(shell,"����ͼƬ","������ɣ�"+pathStr);
    }
}
项目:cogtool    文件:WindowsImageTransfer.java   
protected Object nativeToJava(TransferData transferData) {
        final Object o = super.nativeToJava(transferData);
        final byte[] bytes = (byte[]) o;

        try {
                final InputStream bis = new PrependWinBMPHeaderFilterInputStream(
                                new UncompressDibFilterInputStream(new ByteArrayInputStream(
                                                bytes)));
                final ImageData[] data = new ImageLoader().load(bis);
                if (data.length < 1) {
                        return null;
                }
                return data[0];
        } catch (IOException e) {
                return null;
        }
}
项目:olca-app    文件:SaveImageAction.java   
@Override
public void run() {
    if (file == null)
        return;
    log.trace("export product graph as image: {}", file);
    ScalableRootEditPart editPart = (ScalableRootEditPart) editor.getGraphicalViewer().getRootEditPart();
    IFigure rootFigure = editPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
    Rectangle bounds = rootFigure.getBounds();
    Image img = new Image(null, bounds.width, bounds.height);
    GC imageGC = new GC(img);
    Graphics graphics = new SWTGraphics(imageGC);
    rootFigure.paint(graphics);
    ImageLoader imgLoader = new ImageLoader();
    imgLoader.data = new ImageData[] { img.getImageData() };
    imgLoader.save(file.getAbsolutePath(), SWT.IMAGE_PNG);
}
项目:convertigo-eclipse    文件:AnimatedGif.java   
public AnimatedGif(Display display, Canvas animationCanvas, String animatedGifFile) {
    this.display = display;
    this.animationCanvas = animationCanvas;

    try {
        loader = new ImageLoader();
    } catch (SWTException ex) {
        ConvertigoPlugin.logException(ex, "There was an error loading the GIF", false);
        loader = null;
    }
    imageDataArray = loader.load(getClass().getResourceAsStream(animatedGifFile));
    animationCanvasGC = new GC(animationCanvas);
    shellBackground = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ImageSaveUtil.java   
private static void saveEditorContentsAsImage(IEditorPart editorPart, GraphicalViewer viewer, String saveFilePath, int format) {

        ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID);
        IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);// rootEditPart.getFigure();
        Rectangle rootFigureBounds = rootFigure.getBounds();

        Control figureCanvas = viewer.getControl();
        GC figureCanvasGC = new GC(figureCanvas);

        Image img = new Image(null, rootFigureBounds.width, rootFigureBounds.height);
        GC imageGC = new GC(img);
        imageGC.setBackground(figureCanvasGC.getBackground());
        imageGC.setForeground(figureCanvasGC.getForeground());
        imageGC.setFont(figureCanvasGC.getFont());
        imageGC.setLineStyle(figureCanvasGC.getLineStyle());
        imageGC.setLineWidth(figureCanvasGC.getLineWidth());
        imageGC.setXORMode(figureCanvasGC.getXORMode());
        Graphics imgGraphics = new SWTGraphics(imageGC);

        rootFigure.paint(imgGraphics);

        ImageData[] imgData = new ImageData[1];
        imgData[0] = img.getImageData();

        ImageLoader imgLoader = new ImageLoader();
        imgLoader.data = imgData;
        imgLoader.save(saveFilePath, format);

        figureCanvasGC.dispose();
        imageGC.dispose();
        img.dispose();
    }
项目:knime-json-node-doc-generator    文件:JsonNodeDocuGenerator.java   
private static String getImageBase64(Image image) {
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { image.getImageData() };
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    imageLoader.save(stream, SWT.IMAGE_PNG);
    return new String(Base64.getEncoder().encode(stream.toByteArray()));
}
项目:http4e    文件:AnimatedGIFRunner.java   
AnimatedGIFRunner(
      Control control, 
      ImageLoader imageLoaderGIF, 
      final Image backgroundImage){

   this.control = control;
   controlGC = new GC(control);
   shellBackground = control.getBackground();
   this.imageLoader = imageLoaderGIF;
   this.imageDataArray = imageLoader.data;
   if(imageDataArray == null || imageDataArray.length < 2){
      throw new RuntimeException("Illegal ImageLoader.");
   }
   isStopped = false;
   this.backgroundImage = backgroundImage;
   Rectangle ctrR = control.getBounds();
   positionX = (ctrR.width - CoreConstants.IMAGES_HEIGHT)/2;
   positionY = (ctrR.height - CoreConstants.IMAGES_HEIGHT)/2;

   control.addPaintListener(new PaintListener() {
      public void paintControl( PaintEvent e){
         GC graphics = e.gc;
         if(!graphics.isDisposed()) {
            graphics.drawImage(backgroundImage, positionX, positionY);
            graphics.dispose();
         }
      }
   });
}
项目:http4e    文件:Animator.java   
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();
}
项目:ermasterr    文件:ImageInfo.java   
public void toImageData() throws InterruptedException, IOException {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();

    // try {
    format = SWT.IMAGE_PNG;
    //
    final ImageLoader imgLoader = new ImageLoader();
    imgLoader.data = new ImageData[] {image.getImageData()};
    imgLoader.save(out, format);
    //
    // } catch (SWTException e) {
    // if (this.format == SWT.IMAGE_PNG) {
    // BufferedImage bufferedImage = new BufferedImage(
    // image.getBounds().width, image.getBounds().height,
    // BufferedImage.TYPE_INT_RGB);
    //
    // ImageUtils.drawAtBufferedImage(bufferedImage, image, 0, 0);

    // BufferedImage bufferedImage =
    // ImageUtils.convertToBufferedImage(image);
    //
    // String formatName = "png";
    //
    // ImageIO.write(bufferedImage, formatName, out);

    // } else {
    // throw e;
    // }
    // }

    imageData = out.toByteArray();
}
项目:TranskribusSwtGui    文件:SWTUtil.java   
public static boolean createThumbnailFileOverSWTFast(File origImg, File thumb, int width, int height) throws IOException {
    ImageLoader imgLoader = new ImageLoader();
    ImageData[] imgData = imgLoader.load(origImg.getAbsolutePath());

    if (imgData.length > 0) {
        createThumbnail(imgData[0], thumb, width, height);
        return true;
    } else {
        logger.info("Unable to load " + origImg.getAbsolutePath());
        return false;
    }
}
项目:ermaster-k    文件:ImageInfo.java   
public void toImageData() throws InterruptedException, IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    // try {
    this.format = SWT.IMAGE_PNG;
    //
    ImageLoader imgLoader = new ImageLoader();
    imgLoader.data = new ImageData[] { this.image.getImageData() };
    imgLoader.save(out, this.format);
    //
    // } catch (SWTException e) {
    // if (this.format == SWT.IMAGE_PNG) {
    // BufferedImage bufferedImage = new BufferedImage(
    // image.getBounds().width, image.getBounds().height,
    // BufferedImage.TYPE_INT_RGB);
    //
    // ImageUtils.drawAtBufferedImage(bufferedImage, image, 0, 0);

    // BufferedImage bufferedImage =
    // ImageUtils.convertToBufferedImage(image);
    //
    // String formatName = "png";
    //
    // ImageIO.write(bufferedImage, formatName, out);

    // } else {
    // throw e;
    // }
    // }

    this.imageData = out.toByteArray();
}
项目:code    文件:ImageAnalyzer.java   
void menuReopen() {
    if (currentName == null) {
        return;
    }
    animate = false; // stop any animation in progress
    resetScrollBars();
    resetScaleCombos();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    this.setCursor(waitCursor);
    imageCanvas.setCursor(waitCursor);
    try {
        loader = new ImageLoader();
        long startTime = System.currentTimeMillis();
        ImageData[] newImageData;
        if (fileName == null) {
            URL url = new URL(currentName);
            InputStream stream = url.openStream();
            newImageData = loader.load(stream);
        }
        else {
            newImageData = loader.load(fileName);
        }
        loadTime = System.currentTimeMillis() - startTime;
        imageDataIndex = 0;
        displayImage(newImageData[imageDataIndex]);

    }
    catch (Exception e) {
        showErrorDialog(ImageAnalyzer.bundle.getString("Reloading_lc"), currentName, e);
    }
    finally {
        this.setCursor(null);
        imageCanvas.setCursor(crossCursor);
        waitCursor.dispose();
    }
}
项目:code    文件:ImageAnalyzer.java   
void menuReopen() {
    if (currentName == null) {
        return;
    }
    animate = false; // stop any animation in progress
    resetScrollBars();
    resetScaleCombos();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    this.setCursor(waitCursor);
    imageCanvas.setCursor(waitCursor);
    try {
        loader = new ImageLoader();
        long startTime = System.currentTimeMillis();
        ImageData[] newImageData;
        if (fileName == null) {
            URL url = new URL(currentName);
            InputStream stream = url.openStream();
            newImageData = loader.load(stream);
        }
        else {
            newImageData = loader.load(fileName);
        }
        loadTime = System.currentTimeMillis() - startTime;
        imageDataIndex = 0;
        displayImage(newImageData[imageDataIndex]);

    }
    catch (Exception e) {
        showErrorDialog(ImageAnalyzer.bundle.getString("Reloading_lc"), currentName, e);
    }
    finally {
        this.setCursor(null);
        imageCanvas.setCursor(crossCursor);
        waitCursor.dispose();
    }
}