本文整理汇总了Java中org.eclipse.swt.graphics.ImageData类的典型用法代码示例。如果您正苦于以下问题:Java ImageData类的具体用法?Java ImageData怎么用?Java ImageData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageData类属于org.eclipse.swt.graphics包,在下文中一共展示了ImageData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawCompositeImage
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
@Override
protected void drawCompositeImage(int ignoredWidth, int ignoredHeight) {
// base image, possibly shifted to accommodate decorators
drawImage(getMainData(), shiftFromLeft(), shiftFromTop());
// row of decorators
int x = marginFromLeft();
final int y = marginFromTop();
for (ImageData decoData : getDecosData()) {
drawImage(decoData, x, y);
x += decoData.width;
}
}
示例2: processLoad
import org.eclipse.swt.graphics.ImageData; //导入依赖的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 );
}
} );
}
示例3: drawCompositeImage
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
protected void drawCompositeImage(int width, int height) {
drawImage(mBase.getImageData(), 0, 0);
ImageData imageData = mOverlay.getImageData();
switch (mCorner) {
case TOP_LEFT :
drawImage(imageData, 0, 0);
break;
case TOP_RIGHT :
drawImage(imageData, mBase.getBounds().width - imageData.width, 0);
break;
case BOTTOM_LEFT :
drawImage(imageData, 0, mBase.getBounds().height - imageData.height);
break;
case BOTTOM_RIGHT :
drawImage(imageData, mBase.getBounds().width - imageData.width, mBase.getBounds().height - imageData.height);
break;
}
}
示例4: drawShadowImage
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
public static void drawShadowImage(GC gc, Image image, int x, int y,
int alpha) {
Display display = Display.getCurrent();
Point imageSize = new Point(image.getBounds().width,
image.getBounds().height);
//
ImageData imgData = new ImageData(imageSize.x, imageSize.y, 24,
new PaletteData(255, 255, 255));
imgData.alpha = alpha;
Image img = new Image(display, imgData);
GC imgGC = new GC(img);
imgGC.drawImage(image, 0, 0);
gc.drawImage(img, x, y);
imgGC.dispose();
img.dispose();
}
示例5: save
import org.eclipse.swt.graphics.ImageData; //导入依赖的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);
}
示例6: encontraPixel
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
private RGB encontraPixel(int x, int y, int indice) {
labelPosicaoCor.setText(x + "," + y);
ImageData imageData = null;
PaletteData paletteData = null;
if (indice == 1 && imagem1 != null) {
imageData = imagem1.getImageData();
paletteData = imageData.palette;
} else if (indice == 2 && imagem2 != null) {
imageData = imagem2.getImageData();
paletteData = imageData.palette;
} else if (indice == 3 && imagem3 != null) {
imageData = imagem3.getImageData();
paletteData = imageData.palette;
}
if (paletteData != null && x > -1 && y > -1) {
int pixel = imageData.getPixel(x, y);
RGB rgb = paletteData.getRGB(pixel);
return rgb;
}
return null;
}
示例7: getImageData
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
protected ImageData getImageData() {
int[][] a = (int[][]) array;
ImageData data = new ImageData(width, height, 24, palette);
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
int v = a[y][x];
int r = (v >> 16) & 0xFF;
int g = (v >> 8) & 0xFF;
int b = v & 0xFF;
int pixel = 0;
if(valid(r, g, b)) {
pixel |= (redShift < 0 ? r << -redShift : r >>> redShift) & redMask;
pixel |= (greenShift < 0 ? g << -greenShift : g >>> greenShift) & greenMask;
pixel |= (blueShift < 0 ? b << -blueShift : b >>> blueShift) & blueMask;
}
// int pixel = valid(r,g,b) ? palette.getPixel(new RGB(r,g,b)) : palette.getPixel(new RGB(255, 0, 0));
data.setPixel(x, y, pixel);
}
}
return data;
}
示例8: drawCompositeImage
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
protected void drawCompositeImage(int width, int height) {
ImageData base = getBaseImageData();
drawImage(base, 0, 0);
if (fOverlays != null) {
if (fOverlays.length > 0) {
drawTopRight(fOverlays[0]);
}
if (fOverlays.length > 1) {
drawBottomRight(fOverlays[1]);
}
if (fOverlays.length > 2) {
drawBottomLeft(fOverlays[2]);
}
if (fOverlays.length > 3) {
drawTopLeft(fOverlays[3]);
}
}
}
示例9: loadImage
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
private static Image loadImage(final Display display, final String name) {
InputStream stream = null;
try {
stream = SWTBenchTest.class.getResourceAsStream(name);
if (stream != null) {
final ImageData imageData = new ImageData(stream);
return new Image(display, imageData);
// if (imageData != null) {
// ImageData mask = imageData.getTransparencyMask();
// return new Image(display, imageData, mask);
// }
}
}
catch (final Exception e) {
throw new RuntimeException(e);
}
return null;
}
示例10: copyWidgetToFile
import org.eclipse.swt.graphics.ImageData; //导入依赖的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;
}
示例11: write
import org.eclipse.swt.graphics.ImageData; //导入依赖的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);
}
}
示例12: applyTransparency
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
public void applyTransparency( TGColor background ){
RGB alpha = new RGB( background.getRed(), background.getGreen(), background.getBlue() );
RGB none = new RGB((0xff ^ alpha.red),(0xff ^ alpha.green),(0xff ^ alpha.blue));
Image srcImage = this.handle;
ImageData srcData = srcImage.getImageData();
ImageData maskData = new ImageData(srcData.width,srcData.height,1,new PaletteData(new RGB[]{ none,alpha } ));
for(int x = 0; x< maskData.width; x++) {
for(int y = 0; y < maskData.height; y++) {
RGB rgb = srcData.palette.getRGB(srcData.getPixel(x, y));
if(rgb.red == alpha.red && rgb.green == alpha.green && rgb.blue == alpha.blue){
maskData.setPixel(x, y, maskData.palette.getPixel(none));
}else{
maskData.setPixel(x, y, maskData.palette.getPixel(alpha));
}
}
}
this.handle = new Image(srcImage.getDevice(),srcData,maskData);
srcImage.dispose();
}
示例13: createFigure
import org.eclipse.swt.graphics.ImageData; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected IFigure createFigure() {
final InsertedImage model = (InsertedImage) getModel();
final byte[] data = Base64.decodeBase64((model.getBase64EncodedData().getBytes()));
final ByteArrayInputStream in = new ByteArrayInputStream(data);
imageData = new ImageData(in);
changeImage();
final InsertedImageFigure figure = new InsertedImageFigure(image, model.isFixAspectRatio(), model.getAlpha());
figure.setMinimumSize(new Dimension(1, 1));
return figure;
}
示例14: execute
import org.eclipse.swt.graphics.ImageData; //导入依赖的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;
}
示例15: saveImage
import org.eclipse.swt.graphics.ImageData; //导入依赖的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);
}
}