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


Java PixelGrabber.getColorModel方法代码示例

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


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

示例1: getTransparency

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Gets the transparency of an image.
 *
 * @param image the image
 * @return OPAQUE, BITMASK or TRANSLUCENT (see java.awt.Transparency)
 */
public static int getTransparency( Image image ) {
    // If buffered image, the color model is readily available
    if ( image instanceof BufferedImage ) {
        BufferedImage bimage = (BufferedImage) image;
        return bimage.getColorModel().getTransparency();
    }
    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
    PixelGrabber pg = new PixelGrabber( image, 0, 0, 1, 1, false );
    try {
        pg.grabPixels();
    }
    catch ( InterruptedException e ) {
    }

    // Get the image's color model
    ColorModel cm = pg.getColorModel();

    int transparency = Transparency.OPAQUE;
    if ( cm != null ) {
        transparency = cm.getTransparency();
    }
    return transparency;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:BufferedImageUtils.java

示例2: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static boolean hasAlpha( Image image ) {
    // If buffered image, the color model is readily available
    if ( image instanceof BufferedImage ) {
        BufferedImage bimage = (BufferedImage) image;
        return bimage.getColorModel().hasAlpha();
    }

    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
    PixelGrabber pg = new PixelGrabber( image, 0, 0, 1, 1, false );
    try {
        pg.grabPixels();
    }
    catch ( InterruptedException e ) {
    }

    // Get the image's color model
    ColorModel cm = pg.getColorModel();
    return cm.hasAlpha();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:BufferedImageUtils.java

示例3: getTransparency

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT.
 *
 * @param image
 *            The image.
 * @return the transparency of this ColorModel.
 */
private int getTransparency(Image image) {
    if (image instanceof BufferedImage) {
        BufferedImage bimage = (BufferedImage) image;
        return bimage.getColorModel().getTransparency();
    }
    PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
    try {
        if (pg.grabPixels() && pg.getColorModel() != null) {
            return pg.getColorModel().getTransparency();
        }
    } catch (InterruptedException e) {
        LOGGER.warn(e.getMessage());
    }
    // fallback to generic type
    return Transparency.TRANSLUCENT;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:24,代码来源:ImageScaler.java

示例4: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static boolean hasAlpha(Image image) {
	// If buffered image, the color model is readily available
	if (image instanceof BufferedImage) {
		BufferedImage bimage = (BufferedImage) image;
		return bimage.getColorModel().hasAlpha();
	}

	// Use a pixel grabber to retrieve the image's color model;
	// grabbing a single pixel is usually sufficient
	PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
	}

	// Get the image's color model
	ColorModel cm = pg.getColorModel();
	return cm.hasAlpha();
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:20,代码来源:Util.java

示例5: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * The next two mehtds where got from http://javaalmanac
 * .com/egs/java.awt.image/HasAlpha.html T
 * 
 * @param image
 * @return
 */
// This method returns true if the specified
// image has transparent pixels
public static boolean hasAlpha(Image image) {
	// If buffered image, the color model is
	// readily available
	if (image instanceof BufferedImage) {
		BufferedImage bimage = (BufferedImage) image;
		return bimage.getColorModel().hasAlpha();
	}

	// Use a pixel grabber to retrieve the
	// image's color model;
	// grabbing a single pixel is usually
	// sufficient
	PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
	}

	// Get the image's color model
	ColorModel cm = pg.getColorModel();
	return cm.hasAlpha();
}
 
开发者ID:TOMIGalway,项目名称:cmoct-sourcecode,代码行数:32,代码来源:ImageOperations.java

示例6: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static boolean hasAlpha(Image image) {
    // If buffered image, the color model is readily available
    if (image instanceof BufferedImage) {
        BufferedImage bimage = (BufferedImage)image;
        return bimage.getColorModel().hasAlpha();
    }

    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
     PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
    }

    // Get the image's color model
    ColorModel cm = pg.getColorModel();
    return cm.hasAlpha();
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:20,代码来源:IconGenerator.java

示例7: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * This method returns true if the specified image has transparent pixels
 * @param image
 * @return
 */
public static boolean hasAlpha(java.awt.Image image) {
    // If buffered image, the color model is readily available
    if (image instanceof BufferedImage) {
        BufferedImage bimage = (BufferedImage)image;
        return bimage.getColorModel().hasAlpha();
    }

    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
     PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
    }

    // Get the image's color model
    ColorModel cm = pg.getColorModel();
    return cm.hasAlpha();
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:25,代码来源:Image.java

示例8: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * This method returns true if the specified image has transparent pixels
 *
 * @param  image an image.
 *
 * @return {@code true} if the image has transparent pixels, {@code false}
 *         otherwise.
 */
private static boolean hasAlpha(Image image) {
    // If buffered image, the color model is readily available
    if (image instanceof BufferedImage) {
        BufferedImage bimage = (BufferedImage) image;

        return bimage.getColorModel().hasAlpha();
    }

    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
    PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);

    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
    }

    // Get the image's color model
    ColorModel cm = pg.getColorModel();

    return cm.hasAlpha();
}
 
开发者ID:khuxtable,项目名称:seaglass,代码行数:31,代码来源:Effect.java

示例9: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * This method returns {@code true} if the specified image has the
 * possibility to store transparent pixels.
 * Inspired by http://www.exampledepot.com/egs/java.awt.image/HasAlpha.html
 * @param image Image that should be checked for alpha channel.
 * @return {@code true} if the specified image can have transparent pixels,
 *         {@code false} otherwise
 */
public static boolean hasAlpha(Image image) {
	ColorModel cm;
	// If buffered image, the color model is readily available
	if (image instanceof BufferedImage) {
		BufferedImage bimage = (BufferedImage) image;
		cm = bimage.getColorModel();
	} else {
		// Use a pixel grabber to retrieve the image's color model;
		// grabbing a single pixel is usually sufficient
		PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
		try {
			pg.grabPixels();
		} catch (InterruptedException e) {
			return false;
		}
		// Get the image's color model
		cm = pg.getColorModel();
	}
	return cm.hasAlpha();
}
 
开发者ID:eseifert,项目名称:vectorgraphics2d,代码行数:29,代码来源:GraphicsUtils.java

示例10: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
private static boolean hasAlpha(Image image) {
	// If buffered image, the color model is readily available
	if (image instanceof BufferedImage) {
		BufferedImage bimage = (BufferedImage)image;
		return bimage.getColorModel().hasAlpha();
	}

	// grabbing a single pixel is usually sufficient
	PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
	}

	// Get the image's color model
	ColorModel cm = pg.getColorModel();
	return cm.hasAlpha();
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:19,代码来源:AttachBL.java

示例11: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
boolean hasAlpha(Image image) {
    // If buffered image, the color model is readily available
    if (image instanceof BufferedImage) {
        BufferedImage bimage = (BufferedImage) image;
        return bimage.getColorModel().hasAlpha();
    }

    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
    PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
    }

    // Get the image's color model
    ColorModel cm = pg.getColorModel();
    return cm.hasAlpha();
}
 
开发者ID:KVRajil,项目名称:RemoteDesktopSharing,代码行数:20,代码来源:ImageHandler.java

示例12: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static boolean hasAlpha(Image image) {
  // If buffered image, the color model is readily available
  if (image instanceof BufferedImage) {
    BufferedImage bimage = (BufferedImage) image;
    return bimage.getColorModel().hasAlpha();
  }

  // Use a pixel grabber to retrieve the image's color model;
  // grabbing a single pixel is usually sufficient
  PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
  try {
    pg.grabPixels();
  } catch (InterruptedException e) {
  }

  // Get the image's color model
  ColorModel cm = pg.getColorModel();
  return cm.hasAlpha();
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:20,代码来源:Util.java

示例13: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Taken from http://www.exampledepot.com/egs/java.awt.image/Image2Buf.html
 * @param image
 * @return
 */
public static boolean hasAlpha(Image image) {
    // If buffered image, the color model is readily available
    if (image instanceof BufferedImage) {
        BufferedImage bimage = (BufferedImage) image;
        return bimage.getColorModel().hasAlpha();
    }

    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
    PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
    }

    // Get the image's color model
    ColorModel cm = pg.getColorModel();
    return cm.hasAlpha();
}
 
开发者ID:frapu78,项目名称:processeditor,代码行数:25,代码来源:ProcessUtils.java

示例14: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * http://javaalmanac.com/egs/java.awt.image/HasAlpha.html. This method
 * returns true if the specified image has transparent pixels
 * 
 * @param image
 *            the image to check.
 */
public static boolean hasAlpha(Image image) {
	// If buffered image, the color model is readily available
	if (image instanceof BufferedImage) {
		BufferedImage bimage = (BufferedImage) image;
		return bimage.getColorModel().hasAlpha();
	}

	// Use a pixel grabber to retrieve the image's color model;
	// grabbing a single pixel is usually sufficient
	PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
	}

	// Get the image's color model
	ColorModel cm = pg.getColorModel();
	return cm.hasAlpha();
}
 
开发者ID:guiguito,项目名称:SiJaRayCluster,代码行数:27,代码来源:UtilsImage.java

示例15: hasAlpha

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * This method returns true if the specified image has transparent pixels
 *
 * Code taken from the Java Developers Almanac 1.4
 * http://javaalmanac.com/egs/java.awt.image/HasAlpha.html
 */
public static boolean hasAlpha(Image image) {
    // If buffered image, the color model is readily available
    if (image instanceof BufferedImage) {
        BufferedImage bimage = (BufferedImage)image;
        return bimage.getColorModel().hasAlpha();
    }
    
    // Use a pixel grabber to retrieve the image's color model;
    // grabbing a single pixel is usually sufficient
    PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
    }
    
    // Get the image's color model
    ColorModel cm = pg.getColorModel();
    return cm.hasAlpha();
}
 
开发者ID:sebkur,项目名称:montemedia,代码行数:26,代码来源:Images.java


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