當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageLoader類代碼示例

本文整理匯總了Java中org.eclipse.swt.graphics.ImageLoader的典型用法代碼示例。如果您正苦於以下問題:Java ImageLoader類的具體用法?Java ImageLoader怎麽用?Java ImageLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImageLoader類屬於org.eclipse.swt.graphics包,在下文中一共展示了ImageLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processLoad

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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 );
        }
    } );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:23,代碼來源:URLImageLabel.java

示例2: save

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:23,代碼來源:SwtImage.java

示例3: copyWidgetToFile

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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;
}
 
開發者ID:alfsch,項目名稱:workspacemechanic,代碼行數:21,代碼來源:MechanicPopupTest.java

示例4: write

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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);
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:17,代碼來源:ImageWriter.java

示例5: execute

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
@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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:27,代碼來源:ImageViewSaveAsHandler.java

示例6: saveImage

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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);
	}
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:20,代碼來源:AbstractImageSelectionListener.java

示例7: saveImage

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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);
	}
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:19,代碼來源:SquadSelectionChangeListener.java

示例8: saveImage

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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);
	}
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:20,代碼來源:AbstractImageSelectionListener.java

示例9: loadImageData

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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);
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:20,代碼來源:IconImageDescriptor.java

示例10: GIFAccess

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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];
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:24,代碼來源:GIFAccess.java

示例11: run

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:scenarioo,項目名稱:scenarioo-example-swtbot-e4,代碼行數:20,代碼來源:ScreenShooter.java

示例12: run

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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);

}
 
開發者ID:lowcoupling,項目名稱:plan,代碼行數:19,代碼來源:GanttView.java

示例13: addSnapshotButton

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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);
		}
	});
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:24,代碼來源:XYGraphToolbar.java

示例14: getScaled

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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();
}
 
開發者ID:HobieCat,項目名稱:drinviewer,代碼行數:24,代碼來源:DrinImageLoader.java

示例15: getImagaeData

import org.eclipse.swt.graphics.ImageLoader; //導入依賴的package包/類
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;
}
 
開發者ID:wso2,項目名稱:developer-studio,代碼行數:23,代碼來源:GetWizardIconDataFunction.java


注:本文中的org.eclipse.swt.graphics.ImageLoader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。