本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}