• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Position类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.coobird.thumbnailator.geometry.Position的典型用法代码示例。如果您正苦于以下问题:Java Position类的具体用法?Java Position怎么用?Java Position使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Position类属于net.coobird.thumbnailator.geometry包,在下文中一共展示了Position类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: Watermark

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
/**
 * Instantiates a filter which applies a watermark to an image.
 * 
 * @param position			The position of the watermark.
 * @param watermarkImg		The watermark image.
 * @param opacity			The opacity of the watermark.
 * 							<p>
 * 							The value should be between {@code 0.0f} and
 * 							{@code 1.0f}, where {@code 0.0f} is completely
 * 							transparent, and {@code 1.0f} is completely
 * 							opaque.
 */
public Watermark(Position position, BufferedImage watermarkImg,
		float opacity)
{
	if (position == null)
	{
		throw new NullPointerException("Position is null.");
	}
	if (watermarkImg == null)
	{
		throw new NullPointerException("Watermark image is null.");
	}
	if (opacity > 1.0f || opacity < 0.0f)
	{
		throw new IllegalArgumentException("Opacity is out of range of " +
				"between 0.0f and 1.0f.");
	}
	
	this.position = position;
	this.watermarkImg = watermarkImg;
	this.opacity = opacity;
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:34,代码来源:Watermark.java


示例2: sourceRegion

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
/**
 * Specifies the source region from which the thumbnail is to be
 * created from.
 * <p>
 * Calling this method multiple times will result in an
 * {@link IllegalStateException} to be thrown.
 * 
 * @param position		Position of the source region.
 * @param width			Width of the source region.
 * @param height		Height of the source region.
 * @return				Reference to this object.
 * @throws NullPointerException		If the position and/or size is
 * 									{@code null}.
 * @throws IllegalArgumentException	If the width and/or height is
 * 									less than or equal to {@code 0}.
 * @since 	0.3.4
 */
public Builder<T> sourceRegion(Position position, int width, int height)
{
	if (position == null)
	{
		throw new NullPointerException("Position cannot be null.");
	}
	if (width <= 0 || height <= 0)
	{
		throw new IllegalArgumentException(
				"Width and height must be greater than 0."
		);
	}
	
	return sourceRegion(
			position,
			new AbsoluteSize(width, height)
	);
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:36,代码来源:Thumbnails.java


示例3: classifyImage

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
/**
 * Classifies an Image with the given neural net.
 * Performs 3 Classifications with different croppings, maxpools the vectors on each dimension to get hits
 */
private float[] classifyImage(BufferedImage img) {
    float[] probs = new float[1000];
    Arrays.fill(probs, 0f);
    Position[] positions = new Position[3];
    positions[0] = Positions.CENTER;
    if (img.getHeight() > img.getWidth()) {
        positions[1] = Positions.TOP_RIGHT;
        positions[2] = Positions.BOTTOM_RIGHT;
    } else {
        positions[1] = Positions.CENTER_RIGHT;
        positions[2] = Positions.CENTER_LEFT;
    }

    float[] curr;
    for (Position pos : positions) {
        try {
            curr = getNet().classify(Thumbnails.of(img).size(224, 224).crop(pos).asBufferedImage());
            probs = NeuralNetUtil.maxpool(curr, probs);
        } catch (IOException e) {
            LOGGER.error(e);
        }
    }
    return probs;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:29,代码来源:NeuralNetVGG16Feature.java


示例4: putWaterMark

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
private void putWaterMark(File file,Metadata metadata) throws IOException {
	
	BufferedImage bufferedImage = ImageIO.read(file);
	
	// Set up the caption properties
	String caption = "RASCUNHO";
	Font font = new Font("Monospaced", Font.PLAIN, 100);
	Color c = Color.GRAY;
	float opacity = 0.6f;
	Position[] positions = {Positions.TOP_LEFT,Positions.CENTER,Positions.BOTTOM_RIGHT};
	int insetPixels = 0;

	// Apply caption to the image
	Builder<BufferedImage> builder = Thumbnails.of(bufferedImage).size(bufferedImage.getHeight(),bufferedImage.getWidth()).outputFormat(metadata.getFileExtension());
	
	for(Position position: positions) {
		builder.addFilter(new Caption(caption, font, c, opacity, position, insetPixels));
	}
	BufferedImage result = builder.asBufferedImage();
	
	ImageIO.write(result, metadata.getFileExtension(), file);
}
 
开发者ID:josecoelho,项目名称:yep-rest-file-server,代码行数:23,代码来源:FileService.java


示例5: imgWatermark

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
public static void imgWatermark(File source, String output, int width, int height, Position position, String watermark, float transparency, float quality) {
    try {
        Thumbnails.of(source).size(width, height).watermark(position, ImageIO.read(new File(watermark)), transparency).outputQuality(0.8f).toFile(output);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:8,代码来源:ImageUtils.java


示例6: imgSourceRegion

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
public static void imgSourceRegion(File source, String output, Position position, int x, int y, int width, int height, boolean keepAspectRatio) {
    try {
        Thumbnails.of(source).sourceRegion(position, x, y).size(width, height).keepAspectRatio(keepAspectRatio).toFile(output);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:8,代码来源:ImageUtils.java


示例7: region

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
void region(final ThumbnailParameterBuilder builder, final ANode node)
        throws QueryException {

    int width = (int) Int.parse(node.attribute("width"), null);
    int height = (int) Int.parse(node.attribute("height"), null);
    Dimension d = new Dimension(width, height);
    Position pos = Utils.position(node, "position", Positions.CENTER);
    Region r = new Region(pos, new AbsoluteSize(d));
    builder.region(r);
}
 
开发者ID:expkg-zone58,项目名称:ex-thumbnailator,代码行数:11,代码来源:Thumbs.java


示例8: position

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
public static Position position(final ANode element, final String name, final Position def) {
    byte[] at = element.attribute(name);
    return (at == null) ? def : Positions.valueOf(Token.string(at));
}
 
开发者ID:expkg-zone58,项目名称:ex-thumbnailator,代码行数:5,代码来源:Utils.java


示例9: Caption

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
/**
 * Instantiates a filter which adds a text caption to an image.
 * 
 * @param caption	The text of the caption.
 * @param font		The font of the caption.
 * @param c			The color of the caption.
 * @param alpha		The opacity level of caption.
 * 					<p>
 * 					The value should be between {@code 0.0f} and
 * 					{@code 1.0f}, where {@code 0.0f} is completely
 * 					transparent, and {@code 1.0f} is completely opaque.
 * @param position	The position of the caption.
 * @param insets	The inset size around the caption.
 */
public Caption(String caption, Font font, Color c, float alpha,
		Position position, int insets)
{
	this.caption = caption;
	this.font = font;
	this.c = c;
	this.alpha = alpha;
	this.position = position;
	this.insets = insets;
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:25,代码来源:Caption.java


示例10: Canvas

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
/**
 * Instantiates a {@code Canvas} filter.
 * 
 * @param width			The width of the filtered image.
 * @param height		The height of the filtered image.
 * @param position		The position to place the enclosed image.
 * @param crop			Whether or not to crop the enclosed image if the
 * 						enclosed image has dimensions which are larger than
 * 						the specified {@code width} and {@code height}.
 * @param fillColor		The color to fill portions of the image which is
 * 						not covered by the enclosed image. Portions of the
 * 						image which is transparent will be filled with
 * 						the specified color as well.
 */
public Canvas(int width, int height, Position position, boolean crop, Color fillColor)
{
	super();
	this.width = width;
	this.height = height;
	this.position = position;
	this.crop = crop;
	this.fillColor = fillColor;
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:24,代码来源:Canvas.java


示例11: crop

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
/**
 * Crops the thumbnail to the size specified when calling the
 * {@link #size(int, int)} method, positioned by the given
 * {@link Position} object.
 * <p>
 * Calling this method will guarantee that the size of the thumbnail
 * will be exactly the dimensions specified in the
 * {@link #size(int, int)} method.
 * <p>
 * Internally, the resizing is performed in two steps.
 * First, the thumbnail will be sized so that one of the dimensions will
 * be sized exactly to the dimension specified in the {@code size}
 * method, while allowing the other dimension to overhang the specified
 * dimension. Then, the thumbnail will be cropped to the dimensions
 * specified in the {@code size} method, positioned using the speficied
 * {@link Position} object.
 * <p>
 * Once this method is called, calling the {@link #scale(double)} method
 * will result in an {@link IllegalStateException}.
 * <p>
 * Calling this method multiple times will result in an
 * {@link IllegalStateException} to be thrown.
 *
 * @param position		The position to which the thumbnail should be
 * 						cropped to. For example, if
 * 						{@link Positions#CENTER} is specified, the
 * 						resulting thumbnail will be made by cropping to
 * 						the center of the image.
 * @throws NullPointerException		If the position is {@code null}.
 * @since 	0.4.0
 */
public Builder<T> crop(Position position)
{
	checkForNull(position, "Position cannot be null.");
	
	updateStatus(Properties.CROP, Status.ALREADY_SET);
	updateStatus(Properties.SCALE, Status.CANNOT_SET);

	croppingPosition = position;
	fitWithinDimenions = false;
	return this;
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:43,代码来源:Thumbnails.java


示例12: watermark

import net.coobird.thumbnailator.geometry.Position; //导入依赖的package包/类
/**
 * Sets the image and opacity and position of the watermark to apply on
 * the thumbnail.
 * <p>
 * This method can be called multiple times to apply multiple
 * watermarks.
 * <p>
 * If multiple watermarks are to be applied, the watermarks will be
 * applied in the order that this method is called.
 * <p>
 * Calling this method to set this parameter is optional.
 * 
 * @param position		The position of the watermark.
 * @param image			The image of the watermark.
 * @param opacity		The opacity of the watermark.
 * 						<p>
 * 						The value should be between {@code 0.0f} and
 * 						{@code 1.0f}, where {@code 0.0f} is completely
 * 						transparent, and {@code 1.0f} is completely
 * 						opaque.
 * @return				Reference to this object.
 */
public Builder<T> watermark(Position position, BufferedImage image, float opacity)
{
	filterPipeline.add(new Watermark(position, image, opacity));
	return this;
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:28,代码来源:Thumbnails.java



注:本文中的net.coobird.thumbnailator.geometry.Position类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextRenderer类代码示例发布时间:2022-05-23
下一篇:
Java BatchProcessor类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap