当前位置:首页 » 编程语言 » java像素

java像素

发布时间: 2022-06-01 21:17:43

1. java 怎么提取Image对象的像素数据

这个是一段透明化处理的代码,里面有获取像素的代码存在!希望对你有所帮助!
pixels将是像素,int pixels[] = (int[]) pgr.getPixels();这里将写入到数组中了!

/**
* 使图片中的某一种颜色透明
*
* @param image
* Image
* @param RGB16
* String 十六进制的六位颜色值字符串
* @param isFiltrate
* boolean
* @return Image
*/
public static Image setTranImage(Image image, String RGB16,
boolean isFiltrate)
{
int width = image.getWidth(null);
int height = image.getHeight(null);
Image abufferedimage = new BufferedImage(width, height, 2);
Graphics g = abufferedimage.getGraphics();
g.drawImage(image, 0, 0, width, height, 0, 0, width, height, null);
g.dispose();
// 透明化处理
PixelGrabber pgr = new PixelGrabber(abufferedimage, 0, 0, -1, -1, true);
try
{
pgr.grabPixels();
}
catch (InterruptedException ex)
{
ex.getStackTrace();
}
int pixels[] = (int[]) pgr.getPixels();
if (isFiltrate && RGB16.length() == 6)
{
// 循环像素
for (int i = 0; i < pixels.length; i++)
{
// 去色
if (((pixels[i] & 0x00ff0000) >> 16 == Integer.parseInt(
RGB16.substring(0, 2), 16)
&& (pixels[i] & 0x0000ff00) >> 8 == Integer.parseInt(
RGB16.substring(2, 4), 16) && (pixels[i] & 0x000000ff) == Integer
.parseInt(RGB16.substring(4, 6), 16)))
{
// 透明化
pixels[i] = 0;
}
}
}
ImageProcer ip = new MemoryImageSource(pgr.getWidth(),
pgr.getHeight(), pixels, 0, pgr.getWidth());
return toolkit.createImage(ip);
}

2. java 中如何获得灰度图像的像素值,getRGB和getRaster有什么区别

前者是直接取某点的颜色
后者是得到java.awt.image.WritableRaster,再可以进行处理

3. 在java中如何获得屏幕像素的大小

进去。任务管理器。显示桌面。属性。设置。然后自己调 OK了。

4. JAVA中怎么获取一个字符串占的像素有什么方法

字符串占的字节?像素?

5. Java像素碰撞检测原理

大体有两种方式,一种是基于屏幕像素颜色检测,当移动的目标坐标像素的颜色与目标颜色相同时为发生碰撞。
另一种是坐标检测,就是维持各感兴趣物体的坐标数据,比如大炮打飞机,飞机和炮弹的坐标都保留着,判断二者坐标相同时为发生碰撞。

6. java 如何获取图片的像素值

try{
File _file = new File("C:/Documents and Settings/mayuanfei/My Documents/女友照片.jpg"); //读入文件
Image src = javax.imageio.ImageIO.read(_file); //构造Image对象
int wideth=src.getWidth(null); //得到源图宽
int height=src.getHeight(null); //得到源图长
System.out.println(wideth+","+height);
}catch(Exception e){
e.printStackTrace();
}

7. java设计一个类表示屏幕上的像素

public class Screen{
private int wide;
private int high;

//写 get set方法
}

热点内容
云服务器最先跑什么 发布:2025-07-01 05:02:39 浏览:215
微信公众平台手机上传视频 发布:2025-07-01 04:58:53 浏览:415
数控车床螺纹编程实例 发布:2025-07-01 04:46:27 浏览:422
什么是安卓品牌尖货 发布:2025-07-01 04:45:50 浏览:697
写入设备缓存 发布:2025-07-01 04:37:35 浏览:431
小鸡g4怎么连安卓 发布:2025-07-01 04:37:25 浏览:355
黄金线主图源码 发布:2025-07-01 04:35:38 浏览:298
阿里轻量服务器有固定IP吗 发布:2025-07-01 04:30:27 浏览:507
电脑什么配置要合适 发布:2025-07-01 04:24:15 浏览:167
哪个安卓恢复工具不要钱 发布:2025-07-01 04:21:54 浏览:743