高分求助,在线等待! 这是哪个对象的,能不能具体举例! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // PixelColor.java// Get the color of a specific pixelimport java.awt.image.PixelGrabber;import java.awt.Image;import javax.swing.ImageIcon;import java.awt.image.PixelGrabber;import java.lang.InterruptedException;public class PixelColor{ public static void main(String[] args) { ImageIcon imageIcon = new ImageIcon("sample.jpg"); Image picture = imageIcon.getImage(); int height = imageIcon.getIconHeight(); int width = imageIcon.getIconWidth(); int[] pixels = new int[width * height]; PixelGrabber pg = new PixelGrabber(picture, 0, 0, width, height, pixels, 0, width); try { pg.grabPixels(); } catch (InterruptedException e) { e.printStackTrace(); } // point(x,y) int x = 3; int y = 3; int pixel = pixels[x + y * width]; int alpha = (pixel >> 24) & 0xff; int red = (pixel >> 16) & 0xff; int green = (pixel >> 8) & 0xff; int blue = (pixel ) & 0xff; System.out.println("height: " + height); System.out.println("width: " + width); System.out.println("alpha: " + alpha); System.out.println("red: " + red); System.out.println("green: " + green); System.out.println("blue: " + blue); }} for循环的问题 Thinking in Java里的一个包 cvs错误,已经发生好多次了,但是不知道怎么解决 java环境变量设置问题 帮忙注释一段代码吧谢谢 关于TimerTask 问题 我是新手,问大家一个问题 getClass()的作用 "no ResultSet was produced" exception in jdbc 请问具体介绍一下visual cafe吗??有下载的地方吗?多大?有卖的吗? 卖29日北京到重庆的1389次火车票卧铺 菜鸟初次使用包就出错,父老乡亲帮忙看看啊.
// Get the color of a specific pixel
import java.awt.image.PixelGrabber;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.image.PixelGrabber;
import java.lang.InterruptedException;public class PixelColor
{
public static void main(String[] args)
{
ImageIcon imageIcon = new ImageIcon("sample.jpg");
Image picture = imageIcon.getImage();
int height = imageIcon.getIconHeight();
int width = imageIcon.getIconWidth(); int[] pixels = new int[width * height];
PixelGrabber pg = new PixelGrabber(picture, 0, 0, width, height, pixels, 0, width);
try
{
pg.grabPixels();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
// point(x,y)
int x = 3;
int y = 3;
int pixel = pixels[x + y * width];
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel ) & 0xff;
System.out.println("height: " + height);
System.out.println("width: " + width); System.out.println("alpha: " + alpha);
System.out.println("red: " + red);
System.out.println("green: " + green);
System.out.println("blue: " + blue);
}
}