本文整理汇总了Java中org.eclipse.swt.graphics.ImageLoader.save方法的典型用法代码示例。如果您正苦于以下问题:Java ImageLoader.save方法的具体用法?Java ImageLoader.save怎么用?Java ImageLoader.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.ImageLoader
的用法示例。
在下文中一共展示了ImageLoader.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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;
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: 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;
}
示例9: 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);
}
示例10: 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();
}
示例11: 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;
}
示例12: savePlotCanvasImage
import org.eclipse.swt.graphics.ImageLoader; //导入方法依赖的package包/类
/**
* 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();
}
示例13: saveImage
import org.eclipse.swt.graphics.ImageLoader; //导入方法依赖的package包/类
/**
* {@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();
}
}
示例14: export
import org.eclipse.swt.graphics.ImageLoader; //导入方法依赖的package包/类
/**
* 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();
}
示例15: export
import org.eclipse.swt.graphics.ImageLoader; //导入方法依赖的package包/类
/**
* 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();
}