本文整理汇总了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 );
}
} );
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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];
}
示例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;
}
示例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);
}
示例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);
}
});
}
示例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();
}
示例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;
}