Java Code Examples for org.eclipse.swt.graphics.ImageData#scaledTo()

The following examples show how to use org.eclipse.swt.graphics.ImageData#scaledTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UiDBImage.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public Image getImageScaledTo(int width, int height, boolean bShrinkOnly){
	if (dbImage == null)
		return null;
	byte[] in = dbImage.getBinary(DBImage.FLD_IMAGE);
	ByteArrayInputStream bais = new ByteArrayInputStream(in);
	try {
		ImageData idata = new ImageData(bais);
		if (idata.width != width || idata.height != height) {
			idata = idata.scaledTo(width, height);
		}
		Image ret = new Image(UiDesk.getDisplay(), idata);
		return ret;
	} catch (Exception ex) {
		SWTHelper.showError("Image Error", "Ungültiges Bild",
			"Das Bild ist ungültig " + ex.getMessage());
		return null;
	}
	
}
 
Example 2
Source File: AbstractPictureControl.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the resized {@link ImageData}. This method can be override if
 * scale logic doen't please you.
 *
 * @param imageData
 * @return
 */
protected ImageData getResizedImageData(ImageData imageData) {
	int height = imageData.height;
	int width = imageData.width;
	if (height <= maxImageHeight) {
		return imageData;
	}
	int newHeight = maxImageHeight;
	float w = width;
	float h = height;
	float nw = (w / h) * maxImageHeight;
	int newWidth = (int) nw;
	return imageData.scaledTo(newWidth, newHeight);
}
 
Example 3
Source File: ColorMapRamp.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void paintClientArea(Graphics graphics) {
	super.paintClientArea(graphics);
	ImageData data = imageData==null
			       ? colorMap.drawImage(mapData, 1, 256, max, min)
	               : imageData;

	final Rectangle ca = getClientArea();
	data = data.scaledTo(ca.width, ca.height);

	final Image image = new Image(Display.getDefault(), data);
	graphics.drawImage(image, ca.x, ca.y);
	image.dispose();
}
 
Example 4
Source File: Activator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 5
Source File: Activator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 6
Source File: Activator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 7
Source File: Activator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 8
Source File: Activator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 9
Source File: Activator.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 10
Source File: Activator.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 11
Source File: Activator.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 12
Source File: Activator.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 13
Source File: Activator.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 14
Source File: Activator.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 15
Source File: CoreUiUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private static Image getImageScaledTo(Image orig, int width, int height, boolean bShrinkOnly){
	ImageData idata = orig.getImageData();
	if (idata.width != width || idata.height != height) {
		idata = idata.scaledTo(width, height);
	}
	Image ret = new Image(Display.getDefault(), idata);
	return ret;
}
 
Example 16
Source File: SetToolTipImage.java    From AndroidRobot with Apache License 2.0 4 votes vote down vote up
private void setImage(){
	ImageData proData = new ImageData(path);
	image = new Image(display, proData.scaledTo(width-10, height-10));
	picture.setImage(image);
}