Java Code Examples for org.eclipse.swt.SWT#IMAGE_BMP

The following examples show how to use org.eclipse.swt.SWT#IMAGE_BMP . These examples are extracted from open source projects. 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
/**
 * 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);
}
 
Example 2
Source Project: erflute   File: ExportToImageAction.java    License: Apache License 2.0 6 votes vote down vote up
public static int getFormatType(String saveFilePath) {
    int format = -1;
    final int index = saveFilePath.lastIndexOf(".");
    String ext = null;
    if (index != -1 && index != saveFilePath.length() - 1) {
        ext = saveFilePath.substring(index + 1, saveFilePath.length());
    } else {
        ext = "";
    }
    if (ext.equalsIgnoreCase("jpeg") || ext.equalsIgnoreCase("jpg")) {
        format = SWT.IMAGE_JPEG;
    } else if (ext.equalsIgnoreCase("bmp")) {
        format = SWT.IMAGE_BMP;
    } else if (ext.equalsIgnoreCase("png")) {
        format = SWT.IMAGE_PNG;
    }
    return format;
}
 
Example 3
Source Project: ermaster-b   File: ExportToImageAction.java    License: Apache License 2.0 6 votes vote down vote up
public static int getFormatType(String saveFilePath) {
	int format = -1;

	int index = saveFilePath.lastIndexOf(".");
	String ext = null;
	if (index != -1 && index != saveFilePath.length() - 1) {
		ext = saveFilePath.substring(index + 1, saveFilePath.length());
	} else {
		ext = "";
	}

	if (ext.equalsIgnoreCase("jpeg") || ext.equalsIgnoreCase("jpg")) {
		format = SWT.IMAGE_JPEG;

	} else if (ext.equalsIgnoreCase("bmp")) {
		format = SWT.IMAGE_BMP;

	} else if (ext.equalsIgnoreCase("png")) {
		format = SWT.IMAGE_PNG;

	}

	return format;
}
 
Example 4
public void setCaptureFormat(int format) {
	switch (captureFormat) {
	case SWT.IMAGE_BMP:
	case SWT.IMAGE_GIF:
	case SWT.IMAGE_ICO:
	case SWT.IMAGE_JPEG:
	case SWT.IMAGE_PNG:
	case SWT.IMAGE_TIFF:
		captureFormat = format;
		break;
	default:
		captureFormat = SWT.IMAGE_PNG;
	}
}
 
Example 5
Source Project: ermasterr   File: ImageUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static int getFormatType(final String saveFilePath) {
    int format = -1;

    if (saveFilePath == null) {
        return format;
    }

    final int index = saveFilePath.lastIndexOf(".");
    String ext = null;
    if (index != -1 && index != saveFilePath.length() - 1) {
        ext = saveFilePath.substring(index + 1, saveFilePath.length());
    } else {
        ext = "";
    }

    if (ext.equalsIgnoreCase("jpeg") || ext.equalsIgnoreCase("jpg")) {
        format = SWT.IMAGE_JPEG;

    } else if (ext.equalsIgnoreCase("bmp")) {
        format = SWT.IMAGE_BMP;

    } else if (ext.equalsIgnoreCase("png")) {
        format = SWT.IMAGE_PNG;

    }

    return format;
}
 
Example 6
Source Project: ermasterr   File: ImageUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String toFormatName(final int format) {
    if (SWT.IMAGE_JPEG == format) {
        return "jpg";

    } else if (SWT.IMAGE_BMP == format) {
        return "bmp";
    }

    return "png";
}
 
Example 7
Source Project: erflute   File: ExportToImageManager.java    License: Apache License 2.0 5 votes vote down vote up
public void doProcess() throws IOException, InterruptedException {
    if (format == SWT.IMAGE_JPEG || format == SWT.IMAGE_BMP) {
        writeJPGorBMP(img, saveFilePath, format);

    } else if (format == SWT.IMAGE_PNG || format == SWT.IMAGE_GIF) {
        writePNGorGIF(img, saveFilePath, formatName);
    }
}
 
Example 8
private int getSWTFileFormat(GraphicFileFormat fileFormat) {
	switch (fileFormat) {
	case BITMAP:
		return SWT.IMAGE_BMP;
	case GIF:
		return SWT.IMAGE_GIF;
	case JPEG:
		return SWT.IMAGE_JPEG;
	case TIFF:
		return SWT.IMAGE_TIFF;
	case PNG:
	default:
		return SWT.IMAGE_PNG;
	}
}
 
Example 9
Source Project: ermaster-b   File: ExportToImageManager.java    License: Apache License 2.0 5 votes vote down vote up
public void doProcess() throws IOException, InterruptedException {
	if (format == SWT.IMAGE_JPEG || format == SWT.IMAGE_BMP) {
		writeJPGorBMP(img, saveFilePath, format);

	} else if (format == SWT.IMAGE_PNG || format == SWT.IMAGE_GIF) {
		writePNGorGIF(img, saveFilePath, formatName);
	}
}
 
Example 10
private void capture(Rectangle bounds, String suffix) {
	GC gc = new GC(display);
	Image image = new Image(display, bounds);
	gc.copyArea(image, bounds.x, bounds.y);
	gc.dispose();

	ImageData[] da = new ImageData[] { image.getImageData() };
	image.dispose();

	ImageLoader il = new ImageLoader();
	il.data = da;

	StringBuilder sb = new StringBuilder();
	if (capturePath != null && capturePath.length() > 0) {
		sb.append(capturePath);
	} else {
		sb.append(System.getProperty("user.home"));
	}

	File path = new File(sb.toString());
	if (!path.exists()) {
		path.mkdirs();
	}

	sb.append(File.separator);
	sb.append(getName());
	if (suffix != null && suffix.length() > 0) {
		sb.append("-").append(suffix);
	}
	switch (captureFormat) {
	case SWT.IMAGE_BMP:
		sb.append(".bmp");
		break;
	case SWT.IMAGE_GIF:
		sb.append(".gif");
		break;
	case SWT.IMAGE_ICO:
		sb.append(".ico");
		break;
	case SWT.IMAGE_JPEG:
		sb.append(".jpg");
		break;
	case SWT.IMAGE_PNG:
		sb.append(".png");
		break;
	case SWT.IMAGE_TIFF:
		sb.append(".tiff");
		break;
	default:
		captureFormat = SWT.IMAGE_PNG;
		sb.append(".png");
		break;
	}

	il.save(sb.toString(), captureFormat);
}