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


Java BufferedImage.getMinX方法代码示例

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


在下文中一共展示了BufferedImage.getMinX方法的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);
            }
        }
    }
}
 
开发者ID:onsoul,项目名称:os,代码行数:27,代码来源:ImageUtil.java

示例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);
}
 
开发者ID:IzzelAliz,项目名称:LCL,代码行数:28,代码来源:GetMainColor.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:PathGraphics.java


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