0
A
回答
3
首先你需要你的活動的根容器。您的活動的假設XML看起來是這樣的:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- All your stuff-->
</RelativeLayout>
然後在活動中找到根源,並使用jkhouw1
方法得到Bitmap
其中有方法getPixel
:
@Override
protected void onCreate(Bundle savedInstanceState) {
//...
View container = findViewById(R.id.container);
Bitmap bitmap = loadBitmapFromView(container);
int pixel = bitmap.getPixel(100, 100);
int r = Color.red(pixel);
int b = Color.blue(pixel);
int g = Color.green(pixel);
}
public static Bitmap loadBitmapFromView(View v) {
Bitmap b = Bitmap.createBitmap(v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
v.draw(c);
return b;
}
+0
這個方法在可變像素中返回一個空值,任何想法爲什麼? –
+0
@ user3501635 hm,你確定'getPixel'返回null嗎?實際上它不能返回null。 – eleven
相關問題
- 1. 從Android顯示屏獲取像素值?
- 2. 獲取Android像素值
- 3. 如何獲取多個圖像顯示在Android的GridView中
- 4. Python:圖像顯示中的像素值?
- 5. 如何從Android圖像獲取像素值
- 6. 如何從表中獲取顯示值?
- 7. 獲取圖像中的像素值
- 8. 從Android Canvas獲取像素值
- 9. 如何顯示圖像中特定像素的LA * B *值?
- 10. 如何獲取使用數組顯示的Submit元素的值
- 11. Matlab - 如何獲取像素值?
- 12. 在Android中獲取位圖圖像的像素值
- 13. 如何獲取java中黑白圖像的像素值
- 14. 如何在PHP中獲取圖像的像素值?
- 15. 如何獲取灰度圖像中的像素值
- 16. Android:從相機中獲取像素在圖像視圖上顯示
- 17. jCarouselLite:如何獲取當前顯示圖像的值?
- 18. Java - 如何獲取圖像以顯示?
- 19. 如何獲取Android Intent以顯示「QuickContact」?
- 20. 如何獲取在0-255範圍內的圖像的像素值android
- 21. Android位圖獲取像素
- 22. 如何從視網膜顯示設備中的CGImage獲取正確的像素?
- 23. 如何讀取OpenCV中的像素值?
- 24. 如何獲取並顯示Jpicker Alpha值
- 25. 如何轉換的像素值,以顯示在OpenCV中
- 26. 用像素獲取css值
- 27. MATLAB獲取xyrgb像素值
- 28. 如何獲取「工作空間」中的像素的RGB值
- 29. 如何獲取Android中的像素顏色?
- 30. 如何在Android中獲取相機預覽的像素?
的解決方案是在這裏:HTTP://計算器.com/questions/6272859 /越來越像素顏色價值的點上一安卓視圖,包括一個bitm – eleven
我已經檢查過它,但我沒有找到如何獲得值 –
添加解釋。 – eleven