當前位置:首頁 » 安卓系統 » androidbitmapbmp

androidbitmapbmp

發布時間: 2025-07-10 22:55:09

❶ 請問在android 編程,Bitmap 怎麼轉換成 file

static boolean saveBitmap2file(Bitmap bmp,String filename){
CompressFormat format= Bitmap.CompressFormat.JPEG;
int quality = 100;
OutputStream stream = null;
try {
stream = new FileOutputStream("/sdcard/" + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return bmp.compress(format, quality, stream);
}

stream = new FileOutputStream("/sdcard/" + filename);
獲取要保存到的文件的文件流
bmp.compress(format, quality, stream);
把指定的bitmp壓縮到文件中 就是保存在指定文件中 format是文件格式(Bitmap.CompressFormat.JPEG jpeg) quality 是品質(100 就是原質量)
看名字 saveBitmap2file
你要上傳的話 就去指定位置取這個file就行 路徑的問題 可能有寫真機找不到/sdcard/
建議 Environment類取地址 保存和讀取時 都用Environment.getXXXX

❷ Android Bitmap 與 Drawable之間的區別和轉換

Bitmap - 稱作點陣圖,一般點陣圖的文件格式後綴為bmp,當然編碼器也有很多如RGB565、RGB888。作為一種逐像素的顯示對象執行效率高,但是缺點也很明顯存儲效率低。我們理解為一種存儲對象比較好。

Drawable - 作為Android平下通用的圖形對象,它可以裝載常用格式的圖像,比如GIF、PNG、JPG,當然也支持BMP,當然還提供一些高級的可視化對象,比如漸變、圖形等。

A bitmap is a Drawable. A Drawable is not necessarily a bitmap. Like all thumbs are fingers but not all fingers are thumbs.
Bitmap是Drawable . Drawable不一定是Bitmap .就像拇指是指頭,但不是所有的指頭都是拇指一樣.

The API dictates: API規定:

Though usually not visible to the application, Drawables may take a variety of forms: 盡管通常情況下對於應用是不可見的,Drawables 可以採取很多形式:

Bitmap: the simplest Drawable, a PNG or JPEG image. Bitmap: 簡單化的Drawable, PNG 或JPEG圖像.
Nine Patch: an extension to the PNG format allows it to specify
information about how to stretch it and place things inside of it.
Shape: contains simple drawing commands instead of a raw bitmap, allowing it to resize better in some cases.
Layers: a compound drawable, which draws multiple underlying drawables on top of each other.
States: a compound drawable that selects one of a set of drawables based on its state.
Levels: a compound drawable that selects one of a set of drawables based on its level.
Scale: a compound drawable with a single child drawable, whose overall size is modified based on the current level.

❸ android bitmap怎麼轉byte數組

java">ByteArrayOutputStreamstream=newByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG,100,stream);
byte[]byteArray=stream.toByteArray();

❹ android中Bitmap存為一張圖片

可以用Bitmap.compress函數來把Bitmap對象保存成PNG或JPG文件,然後可以用BitmapFactory把文件中的數據讀進來再生成Bitmap對象。
保存的代碼大概類似於這樣:
try {
FileOutputStream out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
具體的可以去查Bitmap和BitmapFactory的幫助文檔。

❺ android 載入大量圖片速度慢是什麼原因,是訪問sd卡慢,還是使用bitmap的時候慢

android 載入大量圖片速度慢原因一般是訪問sd卡慢,SD卡讀取速度較慢造成的載入文件速度慢。
載入,漢語詞語,字面意思是增加裝載量。現多用於計算機相關領域,表示啟動程序時文件或信息的載入。
點陣圖文件(Bitmap),擴展名可以是.bmp或者.dib。點陣圖是Windows標准格式圖形文件,它將圖像定義為由點(像素)組成,每個點可以由多種色彩表示,包括2、4、8、16、24和32位色彩。例如,一幅1024×768解析度的32位真彩圖片,其所佔存儲位元組數為:1024×768×32/8=3072KB
點陣圖文件圖像效果好,但是非壓縮格式的,需要佔用較大存儲空間,不利於在網路上傳送。jpg格式則恰好彌補了點陣圖文件這個缺點。

熱點內容
vbnet創建資料庫連接 發布:2025-07-12 13:15:34 瀏覽:232
為什麼社保卡在社康還要密碼 發布:2025-07-12 13:11:42 瀏覽:811
取隨機數php 發布:2025-07-12 12:58:16 瀏覽:840
如何配置組合音響 發布:2025-07-12 12:53:54 瀏覽:93
c語言冪計算 發布:2025-07-12 12:52:36 瀏覽:566
兔費WLAN密碼多少 發布:2025-07-12 12:50:59 瀏覽:861
阿里雲分布式存儲 發布:2025-07-12 12:45:04 瀏覽:535
sql日誌壓縮 發布:2025-07-12 12:39:53 瀏覽:343
紅點角標演算法 發布:2025-07-12 12:11:16 瀏覽:844
開心消消樂伺服器繁忙什麼情況 發布:2025-07-12 12:11:14 瀏覽:239