本文整理汇总了Java中java.awt.image.BufferedImage.TYPE_4BYTE_ABGR属性的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.TYPE_4BYTE_ABGR属性的具体用法?Java BufferedImage.TYPE_4BYTE_ABGR怎么用?Java BufferedImage.TYPE_4BYTE_ABGR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.TYPE_4BYTE_ABGR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColorMap
/**
* Use the median cut algorithm to cluster similar colors.
*
* @param sourceImage the source image
* @param colorCount the size of the palette; the number of colors returned
* @param quality 0 is the highest quality settings. 10 is the default. There is
* a trade-off between quality and speed. The bigger the number,
* the faster the palette generation but the greater the
* likelihood that colors will be missed.
* @param ignoreWhite if <code>true</code>, white pixels are ignored
* @return the color map
*/
public static CMap getColorMap(
BufferedImage sourceImage,
int colorCount,
int quality,
boolean ignoreWhite) {
int[][] pixelArray;
switch (sourceImage.getType()) {
case BufferedImage.TYPE_3BYTE_BGR:
case BufferedImage.TYPE_4BYTE_ABGR:
pixelArray = getPixelsFast(sourceImage, quality, ignoreWhite);
break;
default:
pixelArray = getPixelsSlow(sourceImage, quality, ignoreWhite);
}
// Send array to quantize function which clusters values using median
// cut algorithm
CMap cmap = MMCQ.quantize(pixelArray, colorCount);
return cmap;
}
示例2: getSmallSystemIcon
public static ImageIcon getSmallSystemIcon(Image img) throws Exception {
if (img.getWidth(null) > 20 || img.getHeight(null) > 20) {
if (img.getWidth(null) > img.getHeight(null)) {
width = 18;
height = img.getHeight(null) * 18 / img.getWidth(null);
} else {
height = 18;
width = img.getWidth(null) * 18 / img.getHeight(null);
}
} else {
return new ImageIcon(img);
}
dest = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
dest2 = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
g = dest.getGraphics();
g.drawImage(img, 1, 1, width, height, null);
g.dispose();
blurOperator.filter(dest, dest2);
return new ImageIcon(dest2);
}
示例3: createSVGImage
public static BufferedImage createSVGImage(String filename, int width, int height) throws Exception
{
File file = new File(filename);
FileInputStream fis = new FileInputStream(file);
SVGUniverse universe = new SVGUniverse();
universe.loadSVG(fis, file.toURI().toString());
SVGDiagram diagram = universe.getDiagram(file.toURI());
diagram.setIgnoringClipHeuristic(true);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.transform(getAffineTransform((int)diagram.getWidth(), (int)diagram.getHeight(), width, height));
diagram.render(g);
g.dispose();
return image;
}
示例4: getEdgeIcon
@Override
public Image getEdgeIcon(Rectangle bounds, Point[] anglePoints) {
/*creates background image.*/
BufferedImage bgImage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics bgGr = bgImage.getGraphics();
bgGr.setColor(new Color(0, 0, 0, 0));
bgGr.fillRect(0, 0, bounds.width, bounds.height);
for (int i = 0; i < anglePoints.length - 1; i++) {
//Must convert absolute coords to local coords
int x0 = anglePoints[i].x - bounds.x, y0 = anglePoints[i].y - bounds.y, x1 = anglePoints[i + 1].x - bounds.x, y1 = anglePoints[i + 1].y
- bounds.y;
bgGr.setColor(Color.GRAY);
bgGr.drawLine(x0, y0, x1, y1);
bgGr.setColor(new Color(30, 30, 30, 30));
//bgGr.fillRect(Math.min(x0,x1)-1, Math.min(y0,y1)-1, Math.abs(x1-x0)+3, Math.abs(y1-y0)+3);
bgGr.drawLine(x0 - 1, y0 - 1, x1 - 1, y1 - 1);
}
return bgImage;
}
示例5: describeType
private static String describeType(int type) {
switch(type) {
case BufferedImage.TYPE_3BYTE_BGR:
return "TYPE_3BYTE_BGR";
case BufferedImage.TYPE_4BYTE_ABGR:
return "TYPE_4BYTE_ABGR";
case BufferedImage.TYPE_BYTE_GRAY:
return "TYPE_BYTE_GRAY";
case BufferedImage.TYPE_INT_ARGB:
return "TYPE_INT_ARGB";
case BufferedImage.TYPE_INT_BGR:
return "TYPE_INT_BGR";
case BufferedImage.TYPE_INT_RGB:
return "TYPE_INT_RGB";
case BufferedImage.TYPE_BYTE_INDEXED:
return "TYPE_BYTE_INDEXED";
default:
throw new RuntimeException("Test FAILED: unknown type " + type);
}
}
示例6: drawOptimalPath
public static BufferedImage drawOptimalPath(PlayerMovement[] moves, boolean includeGoal) {
BufferedImage ret = new BufferedImage(BG_WIDTH, BG_HEIGHT, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = ret.getGraphics();
int size = moves.length + (includeGoal ? 0 : -1);
for (int i = 0; i < size; i++) {
PlayerMovement p = moves[i];
ItemPoint cursorLoc = ItemPoint.valueOf("SLOT_" + p.LOCATION);
g.drawImage(OPTIMAL_MOVES[p.MOVEMENT],
ITEM_ORIGIN_X + cursorLoc.x - CURSOR_OFFSET,
ITEM_ORIGIN_Y + cursorLoc.y - CURSOR_OFFSET,
null);
}
return ret;
}
示例7: generateButtonTexture
public static BufferedImage generateButtonTexture(Color a,int w,int h,double seed) {
BufferedImage bi = new BufferedImage(w,h, BufferedImage.TYPE_4BYTE_ABGR);
Color c;
for(int i = 0;i < bi.getWidth();i++) {
for(int j = 0;j < bi.getHeight();j++) {
c = TextureGenerator.trick(a,VMath.noise(i/12. + .1, j/2. + .1, seed + .1)*60);
bi.setRGB(i, j, c.getRGB());
}
}
return bi;
}
示例8: buildBGImage
private void buildBGImage() {
int tileX = 30, tileY = 25;
Image tile = iconToolkit.getBGTileIcon(new Rectangle(tileX, tileY));
bgImage = new BufferedImage(getSize().width, getSize().height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = bgImage.getGraphics();
for (int i = 0; i * tileX < getSize().width; i++) {
for (int j = 0; j * tileY < getSize().height; j++) {
g.drawImage(tile, i * tileX, j * tileY, this);
}
}
}
示例9: tryGetImageType
private int tryGetImageType() {
switch (bitsPerPixel) {
case 1:
return BufferedImage.TYPE_BYTE_BINARY;
case 8:
return BufferedImage.TYPE_BYTE_GRAY;
case 32:
return BufferedImage.TYPE_4BYTE_ABGR;
default:
throw new IllegalArgumentException(
format("Unsupported image type with bits per pixel [%d]. Expected {1, 8, 32}.", bitsPerPixel));
}
}
示例10: getTexture
@Override
public BufferedImage getTexture(double seed) {
mainColor = new Color(133,94,66);
BufferedImage bi = new BufferedImage(TextureGenerator.TEX_W, TextureGenerator.TEX_H, BufferedImage.TYPE_4BYTE_ABGR);
Color c;
for(int i = 0;i < bi.getWidth();i++) {
for(int j = 0;j < bi.getHeight();j++) {
c = TextureGenerator.fade(TextureGenerator.trick(mainColor, -30),mainColor,Math.abs(VMath.mod(i,16)-16)/16);
//strength != 0 && weakStrength != 0 ? trick(mainc,turbulence(i+3.1f,j+3.1f,1,seed)*80) : mainc;
bi.setRGB(i, j, c.getRGB());
}
}
return bi;
}
示例11: getJobIcon
@Override
public Image getJobIcon(Rectangle bounds) {
int width = 100, height = 100;
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = bi.getGraphics();
g.setColor(new Color(0, 0, 0, 50));
g.fillOval(0, 0, width, height);
for (int i = 0, monoChannel = 0; i < 10; i++, monoChannel = (int) ((1 - Math.exp(-i * 0.5)) * 255)) {
g.setColor(new Color(monoChannel, monoChannel, monoChannel, 255));
int r = (int) Math.pow(i, 1.5), s = (int) (r * 2.9);
g.fillOval(r, r, width - s, height - s);
}
return bi.getScaledInstance(bounds.width, bounds.height, Image.SCALE_SMOOTH);
}
示例12: getBGTileIcon
@Override
public Image getBGTileIcon(Rectangle bounds) {
BufferedImage bi = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = bi.getGraphics();
g.setColor(new Color(150, 150, 150, 200));
g.fillRect(0, 0, bounds.width, bounds.height);
return bi;
}
示例13: getBGTileIcon
@Override
public Image getBGTileIcon(Rectangle bounds) {
BufferedImage bi = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = bi.getGraphics();
g.setColor(Color.WHITE);
g.fillRect(0, 0, bounds.width, bounds.height);
g.setColor(Color.GRAY);
g.fillRect(0, 0, 1, 1);
return bi;
}
示例14: getChartImage
/**
* Generates and returns a new chart <code>Image</code> configured according to this object's currently held
* settings. The given parameter determines whether transparency should be enabled for the generated images.
*
* <p>
* No chart will be generated until this or the related <code>saveToFile(File)</code> method are called. All
* successive calls will result in the generation of a new chart images, no caching is used.
*
* @param alpha
* whether to enable transparency.
* @return A newly generated chart <code>Image</code>. The returned images is a <code>BufferedImage</code>.
*/
public Image getChartImage(boolean alpha) {
// Calculate all unknown dimensions.
measureComponents();
updateCoordinates();
// Determine images type based upon whether require alpha or not.
// Using BufferedImage.TYPE_INT_ARGB seems to break on jpg.
int imageType = (alpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR);
// Create our chart images which we will eventually draw everything on.
BufferedImage chartImage = new BufferedImage(chartSize.width, chartSize.height, imageType);
Graphics2D chartGraphics = chartImage.createGraphics();
// Use anti-aliasing where ever possible.
chartGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Set the background.
chartGraphics.setColor(backgroundColour);
chartGraphics.fillRect(0, 0, chartSize.width, chartSize.height);
// Draw the title.
drawTitle(chartGraphics);
// Draw the heatmap images.
drawHeatMap(chartGraphics, zValues);
// Draw the axis labels.
drawXLabel(chartGraphics);
drawYLabel(chartGraphics);
// Draw the axis bars.
drawAxisBars(chartGraphics);
// Draw axis values.
drawXValues(chartGraphics);
drawYValues(chartGraphics);
return chartImage;
}
示例15: getImageTypeName
static String getImageTypeName(int type) {
switch(type) {
case BufferedImage.TYPE_INT_ARGB:
return "TYPE_INT_ARGB";
case BufferedImage.TYPE_INT_RGB:
return "TYPE_INT_RGB";
case BufferedImage.TYPE_INT_BGR:
return "TYPE_INT_BGR";
case BufferedImage.TYPE_INT_ARGB_PRE:
return "TYPE_INT_ARGB_PRE";
case BufferedImage.TYPE_3BYTE_BGR:
return "TYPE_3BYTE_BGR";
case BufferedImage.TYPE_4BYTE_ABGR:
return "TYPE_4BYTE_ABGR";
case BufferedImage.TYPE_4BYTE_ABGR_PRE:
return "TYPE_4BYTE_ABGR_PRE";
case BufferedImage.TYPE_BYTE_BINARY:
return "TYPE_BYTE_BINARY";
case BufferedImage.TYPE_BYTE_GRAY:
return "TYPE_BYTE_GRAY";
case BufferedImage.TYPE_BYTE_INDEXED:
return "TYPE_BYTE_INDEXED";
case BufferedImage.TYPE_USHORT_555_RGB:
return "TYPE_USHORT_555_RGB";
case BufferedImage.TYPE_USHORT_565_RGB:
return "TYPE_USHORT_565_RGB";
case BufferedImage.TYPE_USHORT_GRAY:
return "TYPE_USHORT_GRAY";
}
return "UNKNOWN";
}