方法1;
bitmap
bitmap
;public
bitmap drawtexttobitmap(context mcontext, bitmap bit, string mtext, string str3)
bitmap
= bitmap
.copy(bitmapconfig,
true
);canvas canvas =
new
canvas(
bitmap
);paint paint =
new
paint(paint.
anti_alias_flag
);//消除鋸齒
paint.setdither(
true
); //獲取跟清晰的影象取樣
paint.setfilterbitmap(
true
);//過濾一些
paint.setcolor(color.
red);
paint.settextsize((
int) (
2*scale));
paint.setshadowlayer(
1f,
0f,
1f, color.
dkgray
);//陰影製作半徑,x偏移量,y偏移量,陰影顏色
rect bounds =
new
rect();
paint.gettextbounds(mtext,
0, mtext.length(), bounds);
int
y = (
bitmap
.getheight() + bounds.height()) / 4;
int
x = 0;
toast.
maketext
(mycaremaactivity.
this
,"x"
+bitmap
.getheight() +
"y"+y +
"y*sace"
+ y * scale+
"sace"
+scale,toast.
length_long
).show();
log.v(
"===位置"
, "x"
+bitmap
.getheight() +
"y"+y +
"y*sace"
+ y * scale+
"sace"
+scale);
canvas.drawtext(mtext, x * scale, y * scale, paint);
canvas.drawtext(str3, x * scale, y * scale +
25, paint);
// canvas.drawtext(mtext, x * scale, 210, paint);
// canvas.drawtext(str3, x * scale,210 + 25 , paint);
log.v(
"===合成"
, "====ok"
+ mtext);
return
bitmap;}
catch
(exception e)
方法二:
bitmap
bitmap
;public
bitmap addwatermark(bitmap src, string water,string dtr, context context)
private
string
myear
;private
string
mmonth
;private
string
mday
;private
string
mway
;string s;
public
string stringdata()
else if
("2"
.equals(
mway
))else if
("3"
.equals(
mway
))else if
("4"
.equals(
mway
))else if
("5"
.equals(
mway
))else if
("6"
.equals(
mway
))else if
("7"
.equals(
mway))s
= +myear
+ "年"
+ mmonth
+ "月"
+ mday
+"日"
+"周"
+mway
+str;
log.v(
"==獲取時間"
,myear
+ "年"
+ mmonth
+ "月"
+ mday
+"日"
+"/星期"
+mway
+str);
log.v(
"==獲取時間s",s
);return s;
}}
android bitmap記憶體處理
程式中一次性載入多張,而且還要適應螢幕,這就造成記憶體緊張,程序會出現oom,特別是現在的手機解析度高達1920 1024,一張占用記憶體高達8m,首先要獲取原的高寬 減少記憶體 bitmapfactory.options options new bitmapfactory.options opti...
Android Bitmap應用收集
bitmap代表一張位圖,副檔名可以是.bmp或者.dib。點陣圖是windows標準格式圖形檔案,它將影象定義為由點 畫素 組成,每個點可以由多種色彩表示,包括2 4 8 16 24和32位色彩。例如,一幅1024 768解析度的32位真彩,其所佔儲存位元組數為 1024 768 32 8 307...
Android bitmap用法介紹
bitmap是android中重要的影象處理工具類,通過bitmap可以對影象進行剪下 旋轉 縮放等操作,同時還可以指定格式和壓縮質量儲存影象檔案。一 拿到乙個bitmap物件 檢視原始碼我們知道,bitmap被final修飾,因此不可以通過new來獲得乙個bitmap的例項,獲得乙個bitmap物...