在Android中將圖片轉成它的像素版:Pixelate
對于一個項目,我需要把圖像轉換成自身的像素化版本。不過,我無法找到Android的可使用的庫,所以我決定寫自己的東西。請不要指望它是完美的。
Heisenberg painting created by Armando Mesias
Usage
Use the Pixelate imageview in your layout XML.
<nl.dionsegijn.pixelate android:id="@+id/pixelate" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" android:scaleType="centerCrop" android:src="your image.."/>
Optional: Add the following attribute to the layout to pixelate an image immediately
pixelate:density="10"
Call the pixelate method on the view to render the pixels with the preferred density
Pixelate pixelate = (Pixelate)findViewById(R.id.pixelate); pixelate.pixelate(int density);
Or call the following method to pixelate a certain area of the image
pixelate.pixelateArea(int x, int y, int size, int density);
Download
Download via Gradle:
compile 'nl.dionsegijn:pixelate:1.0.1'
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!