本文整理汇总了Java中java.awt.image.BufferedImage.getMinY方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.getMinY方法的具体用法?Java BufferedImage.getMinY怎么用?Java BufferedImage.getMinY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.getMinY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeRGB
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
* 执行透明化的核心算法
*
* @param img
* 图片对象
* @param alpha
* 透明度
* @throws Exception
*/
public static void executeRGB(BufferedImage img, int alpha) throws Exception{
int rgb = 0;//RGB值
//x表示BufferedImage的x坐标,y表示BufferedImage的y坐标
for(int x=img.getMinX();x<img.getWidth();x++){
for(int y=img.getMinY();y<img.getHeight();y++){
//获取点位的RGB值进行比较重新设定
rgb = img.getRGB(x, y);
int R =(rgb & 0xff0000 ) >> 16 ;
int G= (rgb & 0xff00 ) >> 8 ;
int B= (rgb & 0xff );
if(((255-R)<30) && ((255-G)<30) && ((255-B)<30)){
rgb = ((alpha + 1) << 24) | (rgb & 0x00ffffff);
img.setRGB(x, y, rgb);
}
}
}
}
示例2: getImagePixel
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public static Color getImagePixel(InputStream file) {
int R = 0;
int G = 0;
int B = 0;
List<String> list = new ArrayList<String>();
BufferedImage bi = null;
try {
bi = ImageIO.read(file);
} catch (Exception e) {
e.printStackTrace();
}
int width = bi.getWidth();
int height = bi.getHeight();
int sum = width * height;
int minx = bi.getMinX();
int miny = bi.getMinY();
for (int i = minx; i < width; i++) {
for (int j = miny; j < height; j++) {
int pixel = bi.getRGB(i, j);
R = (pixel & 0xff0000) >> 16;
G = (pixel & 0xff00) >> 8;
B = (pixel & 0xff);
list.add(R + "-" + G + "-" + B);
}
}
return getMaxCount(list);
}
示例3: hasTransparentPixels
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
* Return true if the BufferedImage argument has non-opaque
* bits in it and therefore can not be directly rendered by
* GDI. Return false if the image is opaque. If this function
* can not tell for sure whether the image has transparent
* pixels then it assumes that it does.
*/
protected boolean hasTransparentPixels(BufferedImage bufferedImage) {
ColorModel colorModel = bufferedImage.getColorModel();
boolean hasTransparency = colorModel == null
? true
: colorModel.getTransparency() != ColorModel.OPAQUE;
/*
* For the default INT ARGB check the image to see if any pixels are
* really transparent. If there are no transparent pixels then the
* transparency of the color model can be ignored.
* We assume that IndexColorModel images have already been
* checked for transparency and will be OPAQUE unless they actually
* have transparent pixels present.
*/
if (hasTransparency && bufferedImage != null) {
if (bufferedImage.getType()==BufferedImage.TYPE_INT_ARGB ||
bufferedImage.getType()==BufferedImage.TYPE_INT_ARGB_PRE) {
DataBuffer db = bufferedImage.getRaster().getDataBuffer();
SampleModel sm = bufferedImage.getRaster().getSampleModel();
if (db instanceof DataBufferInt &&
sm instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel psm =
(SinglePixelPackedSampleModel)sm;
// Stealing the data array for reading only...
int[] int_data =
SunWritableRaster.stealData((DataBufferInt) db, 0);
int x = bufferedImage.getMinX();
int y = bufferedImage.getMinY();
int w = bufferedImage.getWidth();
int h = bufferedImage.getHeight();
int stride = psm.getScanlineStride();
boolean hastranspixel = false;
for (int j = y; j < y+h; j++) {
int yoff = j * stride;
for (int i = x; i < x+w; i++) {
if ((int_data[yoff+i] & 0xff000000)!=0xff000000 ) {
hastranspixel = true;
break;
}
}
if (hastranspixel) {
break;
}
}
if (hastranspixel == false) {
hasTransparency = false;
}
}
}
}
return hasTransparency;
}