当前位置: 首页>>代码示例>>Java>>正文


Java BufferedImage.TRANSLUCENT属性代码示例

本文整理汇总了Java中java.awt.image.BufferedImage.TRANSLUCENT属性的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.TRANSLUCENT属性的具体用法?Java BufferedImage.TRANSLUCENT怎么用?Java BufferedImage.TRANSLUCENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.image.BufferedImage的用法示例。


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

示例1: getOutputFormat

@Override
public String getOutputFormat(String tx_name,String tx_path,String substance_fs_path) {
	tx_name=tx_name.substring(tx_name.lastIndexOf("_")+1);
	boolean has_alpha=false;
	try{
		BufferedImage bimg=ImageIO.read(new File(PathUtils.toNative(substance_fs_path+tx_path)));
		has_alpha=bimg.getTransparency()==BufferedImage.TRANSLUCENT;
	}catch(Exception e){
		LOGGER.log(Level.WARNING,"Can't read image",e);
	}
	if(has_alpha)LOGGER.log(Level.FINE,tx_name+" has alpha channel.");
	switch(tx_name){
		case "DiffuseMap":
			return has_alpha?"S3TC_DXT5":"S3TC_DXT1";
		case "SpecularMap":
			return "S3TC_DXT1";
		case "GlowMap":
			return "S3TC_DXT1";
	
		case "NormalMap":
			return "rgb8";
		case "ParallaxMap":
			return "rgb8";
	}
	return null;
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:26,代码来源:PhongSubstance.java

示例2: getScaledImage

public static BufferedImage getScaledImage(BufferedImage src, double fraction){
	int finalw = (int)(src.getWidth()*fraction);
	int finalh = (int)(src.getHeight()*fraction);
	double factor = 1.0d;
	if(src.getWidth() > src.getHeight()){
		factor = ((double)src.getHeight()/(double)src.getWidth());
		finalh = (int)(finalw * factor);                
	}else{
		factor = ((double)src.getWidth()/(double)src.getHeight());
		finalw = (int)(finalh * factor);
	}   

	BufferedImage resizedImg = new BufferedImage(finalw, finalh, BufferedImage.TRANSLUCENT);
	Graphics2D g2 = resizedImg.createGraphics();
	g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
	g2.drawImage(src, 0, 0, finalw, finalh, null);
	g2.dispose();
	return resizedImg;
}
 
开发者ID:ForOhForError,项目名称:MTG-Card-Recognizer,代码行数:19,代码来源:ImageUtil.java

示例3: scale

/**
 * Scales a given image by rendering the supplied image with the given width and height into a new image and 
 * returning the new image. The method will throw an  {@link java.lang.IllegalArgumentException} if either of the 
 * two image sizes is 0 or below. A {@link java.lang.NullPointerException} will be thrown if the supplied image 
 * is null.
 * @param image Image to scale to the given width and height
 * @param width Width to scale image to
 * @param height Height to scale image to
 * @return New image scaled to the given width and height
 */
public static BufferedImage scale(BufferedImage image, int width, int height) {
	if (image == null) {
		log.error("The supplied image is null.");
		throw new NullPointerException("The supplied image is null.");
	}
	if (width <= 0) {
		log.error("The supplied pixel width is below 1.");
		throw new IllegalArgumentException("The supplied pixel width is below 1.");
	}
	if (height <= 0) {
		log.error("The supplied pixel height is below 1.");
		throw new IllegalArgumentException("The supplied pixel height is below 1.");
	}
	
	BufferedImage scaledImg = new BufferedImage(width, height, BufferedImage.TRANSLUCENT);
	Graphics2D graphics = scaledImg.createGraphics();
	graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
	graphics.drawImage(image, 0, 0, width, height, null);
	graphics.dispose();
	return scaledImg;
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:31,代码来源:ImageScaler.java

示例4: getScaledImage

public static BufferedImage getScaledImage(BufferedImage src, double factor) {
	int finalw = src.getWidth();
	int finalh = src.getHeight();
	if (src.getWidth() > src.getHeight()) {
		factor = ((double) src.getHeight() / (double) src.getWidth());
		finalh = (int) (finalw * factor);
	}

	else {
		factor = ((double) src.getWidth() / (double) src.getHeight());
		finalw = (int) (finalh * factor);
	}

	BufferedImage resizedImg = new BufferedImage(finalw, finalh, BufferedImage.TRANSLUCENT);
	Graphics2D g2 = resizedImg.createGraphics();
	g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
	g2.drawImage(src, 0, 0, finalw, finalh, null);
	g2.dispose();
	return resizedImg;
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:20,代码来源:ImageUtils.java

示例5: getOutputFormat

@Override
public String getOutputFormat(String tx_name, String tx_path, String substance_fs_path) {
	if(tx_path.isEmpty()) return tx_path;
	tx_name=tx_name.substring(tx_name.lastIndexOf("_")+1);
	boolean has_alpha=false;
	try{
		File f=new File(PathUtils.toNative(substance_fs_path+"/"+tx_path));
		System.out.println(f);
		BufferedImage bimg=ImageIO.read(f);
		has_alpha=bimg.getTransparency()==BufferedImage.TRANSLUCENT;
	}catch(Exception e){
		LOGGER.log(Level.WARNING,"Can't read image",e);
	}
	if(has_alpha) LOGGER.log(Level.FINE,tx_name+" has alpha channel.");
	switch(tx_name){
		case "BaseColorMap":
			return has_alpha?"S3TC_DXT5":"S3TC_DXT1";
		case "MetallicMap":
			return "S3TC_DXT1";
		case "RoughnessMap":
			return "S3TC_DXT1";
		case "EmissiveMap":
			return "S3TC_DXT1";
		case "NormalMap":
			return "rgb8";
		case "ParallaxMap":
			return "rgb8";
	}
	return null;
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:30,代码来源:PBRSubstance.java

示例6: tint

public BufferedImage tint(BufferedImage src, Color col) {
	BufferedImage img = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TRANSLUCENT);
	Graphics2D graphics = img.createGraphics();
	graphics.setXORMode(new Color(col.getRed(), col.getGreen(), col.getBlue(), 0));
	graphics.drawImage(src, null, 0, 0);
	graphics.dispose();
	return img;
}
 
开发者ID:Keabot-Studios,项目名称:Caritemere,代码行数:8,代码来源:GuiUtil.java


注:本文中的java.awt.image.BufferedImage.TRANSLUCENT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。