本文整理汇总了Java中java.awt.image.BufferedImage.TYPE_INT_RGB属性的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.TYPE_INT_RGB属性的具体用法?Java BufferedImage.TYPE_INT_RGB怎么用?Java BufferedImage.TYPE_INT_RGB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.TYPE_INT_RGB属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNPE
private static void testNPE() {
Graphics g = null;
try {
String test = "\ttest\ttest2";
BufferedImage buffImage = new BufferedImage(
100, 100, BufferedImage.TYPE_INT_RGB);
g = buffImage.createGraphics();
Segment segment = new Segment(test.toCharArray(), 0, test.length());
Utilities.drawTabbedText(segment, 0, 0, g, null, 0);
} finally {
if (g != null) {
g.dispose();
}
}
}
示例2: testDrawWithNullInfo
/**
* Draws the chart with a null info object to make sure that no exceptions
* are thrown (a problem that was occurring at one point).
*/
public void testDrawWithNullInfo() {
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null,
null);
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例3: testFix_204072_MissingIcon
/** Tests that multiple instances of the same class propagate well
* into array of actions of enclosing multiview TopComponent
*/
public void testFix_204072_MissingIcon() {
final Image img = new BufferedImage( 10, 10, BufferedImage.TYPE_INT_RGB );
MVElem elem1 = new MVElem();
MVElem elem2 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1", img, 0, elem1);
MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
TopComponent tc = MultiViewFactory.createMultiView(new MultiViewDescription[] { desc1, desc2 }, desc1);
tc.open();
tc.requestActive();
assertEquals( img, tc.getIcon() );
MultiViewTopComponent mvtc = ( MultiViewTopComponent ) tc;
mvtc.getModel().setActiveDescription( desc2 );
assertEquals( img, tc.getIcon() );
}
示例4: reverse
public ImageUtils reverse(boolean isVertical){
int width = this.dealedImage.getWidth();
int height = this.dealedImage.getHeight();
double[] matrix;
if(isVertical){
matrix = new double[]{1, 0, 0, -1, 0,height};
}else {
matrix = new double[]{-1, 0, 0, 1,width,0};
}
AffineTransform affineTransform = new AffineTransform(matrix);
BufferedImage newImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = newImg.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawRenderedImage(this.dealedImage, affineTransform);
g.dispose();
this.dealedImage = newImg;
return this;
}
示例5: paint
@Override
public void paint(Graphics g)
{
// Gets the canvas to draw in
BufferedImage bi = new BufferedImage(
Constant.BOARD_CELL_SIZE * board.countColumns(),
Constant.BOARD_CELL_SIZE * board.countRows(),
BufferedImage.TYPE_INT_RGB
);
Graphics2D canvas = bi.createGraphics();
// Draws the game in the canvas
for (int i = 0; i < board.countRows(); ++i)
{
for (int j = 0; j < board.countColumns(); ++j)
{
board.getCell(new Coord2D(i, j)).draw(canvas);
}
}
// Really paints the component
((Graphics2D) g).drawImage(bi, 0, 0, this);
}
示例6: createBufferedImage
private static BufferedImage createBufferedImage(final boolean aa) {
final BufferedImage bi = new BufferedImage(SIZE, SIZE,
BufferedImage.TYPE_INT_RGB);
final Graphics2D bg = bi.createGraphics();
bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
aa ? RenderingHints.VALUE_ANTIALIAS_ON
: RenderingHints.VALUE_ANTIALIAS_OFF);
bg.setColor(Color.RED);
bg.fillRect(0, 0, SIZE, SIZE);
bg.translate(100, 100);
bg.rotate(Math.toRadians(90));
bg.setColor(Color.BLACK);
bg.setFont(bg.getFont().deriveFont(20.0f));
bg.drawString("MMMMMMMMMMMMMMMM", 0, 0);
bg.dispose();
return bi;
}
示例7: testDrawWithNullInfo
/**
* Draws the chart with a null info object to make sure that no exceptions
* are thrown (a problem that was occurring at one point).
*/
public void testDrawWithNullInfo() {
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null,
null);
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例8: main
public static void main(String[] args) {
final BufferedImage dst_custom = createCustomBuffer();
final BufferedImage dst_dcm = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
renderTo(dst_custom);
renderTo(dst_dcm);
check(dst_custom, dst_dcm);
}
示例9: main
public static void main(String a[]) {
/* prepare blank image */
BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = (Graphics2D) bi.getGraphics();
g2.setColor(Color.WHITE);
g2.fillRect(0, 0, 50, 50);
/* draw outline somethere in the middle of the image */
FontRenderContext frc = new FontRenderContext(null, false, false);
g2.setColor(Color.RED);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
GlyphVector gv = g2.getFont().createGlyphVector(frc, "test");
g2.fill(gv.getOutline(20, 20));
/* Check if anything was drawn.
* If y direction is not correct then image is still blank and
* test will fail.
*/
int bgcolor = Color.WHITE.getRGB();
for (int i=0; i<bi.getWidth(); i++) {
for(int j=0; j<bi.getHeight(); j++) {
if (bi.getRGB(i, j) != bgcolor) {
System.out.println("Test passed.");
return;
}
}
}
throw new RuntimeException("Outline was not detected");
}
示例10: combine
private BufferedImage combine(BufferedImage etalonImage, BufferedImage actualImage) {
// create the new image, canvas size is the max. of both image sizes
int w = etalonImage.getWidth() + actualImage.getWidth() + 1;
int h = Math.max(etalonImage.getHeight(), actualImage.getHeight());
BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
// paint both images, preserving the alpha channels
Graphics g = combined.getGraphics();
g.drawImage(etalonImage, 0, 0, null);
g.drawImage(actualImage, etalonImage.getWidth() + 1, 0, null);
return combined;
}
示例11: setRGB
/**
* A convenience method for setting ARGB pixels in an image. This tries to avoid the performance
* penalty of BufferedImage.setRGB unmanaging the image.
*/
public static void setRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
int type = image.getType();
if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
image.getRaster().setDataElements( x, y, width, height, pixels );
else
image.setRGB( x, y, width, height, pixels, 0, width );
}
示例12: initImage
public void initImage(final Graphics2D _g2d) {
if (_g2d == null) {
image = new BufferedImage(SensorInfo.getInstance().parameter.getAreaWidth(),
SensorInfo.getInstance().parameter.getAreaHeight(), BufferedImage.TYPE_INT_RGB);
g2d = image.createGraphics();
} else {
g2d = _g2d;
}
}
示例13: createTestImage
private static BufferedImage createTestImage() {
BufferedImage img = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = img.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, 100, 100);
g.setColor(Color.black);
g.fillRect(20, 20, 60, 60);
return img;
}
示例14: createTestImage
protected static BufferedImage createTestImage() {
BufferedImage res = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = res.createGraphics();
g.setColor(Color.red);
g.fillRect(0,0, 100,100);
return res;
}
示例15: render
private BufferedImage render(Image img) throws InterruptedException {
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForAll();
BufferedImage bufImage = new BufferedImage(img.getWidth(null),
img.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics g = bufImage.createGraphics();
g.drawImage(img, 0, 0, null);
g.dispose();
return bufImage;
}