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

熱點內容
sql分段統計 發布:2025-02-10 09:40:27 瀏覽:358
記賬app源碼 發布:2025-02-10 09:34:45 瀏覽:496
照片傳到g6的存儲卡 發布:2025-02-10 09:29:02 瀏覽:902
非加密公章 發布:2025-02-10 09:09:52 瀏覽:621
京東登錄密碼如何清除 發布:2025-02-10 09:07:41 瀏覽:690
dns伺服器地址192 發布:2025-02-10 09:07:39 瀏覽:662
redis緩存實現 發布:2025-02-10 09:01:26 瀏覽:711
後台登錄腳本 發布:2025-02-10 08:56:11 瀏覽:659
我的辣雞賬號和密碼是多少 發布:2025-02-10 08:55:37 瀏覽:691
超父演算法 發布:2025-02-10 08:43:05 瀏覽:911