當前位置:首頁 » 編程語言 » 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方法
}

熱點內容
emobile7伺服器地址如何查看 發布:2025-04-22 22:32:51 瀏覽:763
房間的秘密碼是什麼 發布:2025-04-22 22:32:43 瀏覽:120
文件夾前面多了選擇框 發布:2025-04-22 22:32:40 瀏覽:703
迅雷網ftp 發布:2025-04-22 22:30:02 瀏覽:622
滑鼠驅動源碼 發布:2025-04-22 22:29:55 瀏覽:768
如何開發android應用 發布:2025-04-22 22:18:55 瀏覽:880
醫保卡密碼從哪裡看 發布:2025-04-22 22:14:34 瀏覽:260
地鐵逃生安卓更新後為什麼進不去 發布:2025-04-22 22:13:49 瀏覽:443
java枚舉使用 發布:2025-04-22 22:06:56 瀏覽:257
分解壓與K 發布:2025-04-22 22:06:40 瀏覽:835