adb 進到 shell
指定 PC端的Port 對應到 模擬器的Port
redir add tcp:2221:2221
2013年12月18日 星期三
2013年11月14日 星期四
android TextView 字體
Typeface 需要使用MONOSPACE 其他的對中文字斜體無效
setTypeface(Typeface.MONOSPACE, Typeface.BOLD_ITALIC);
getPaint().setFakeBoldText(true);
setTypeface(Typeface.MONOSPACE, Typeface.BOLD_ITALIC);
getPaint().setFakeBoldText(true);
setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);//設置成24sp setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//中文加粗無效 setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));//中文無效 setText(Html.fromHtml("<u>"+texts+"</u>"));//下劃線 setTypeface(Typeface.MONOSPACE,Typeface.ITALIC);//斜體,中文有效 getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );//中間加橫線 getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );//底部加橫線
2013年11月4日 星期一
Java 影像亮度、對比
public Image filter2(Image img) {
int width = img.getWidth(null);
int height = img.getHeight(null);
BufferedImage src = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
src.getGraphics().drawImage(img, 0, 0, null);
int[] inPixels = new int[width * height];
int[] outPixels = new int[width * height];
int index = 0;
src.getRGB(0, 0, width, height, inPixels, 0, width);
int r, g, b;
int bfi = (int) (getBrightness() * 255);// 0~255
float cf = 1f + getContrast();// -1~1
cf *= cf;
int cfi = (int) (cf * 32768) + 1;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
index = row * width + col;
Color color = new Color(inPixels[index]);
r = color.getRed();
g = color.getGreen();
b = color.getBlue();
if (bfi != 0) {
// Add brightness
int ri = r + bfi;
int gi = g + bfi;
int bi = b + bfi;
// Clamp to byte boundaries
r = ri > 255 ? 255 : (ri < 0 ? 0 : ri);
g = gi > 255 ? 255 : (gi < 0 ? 0 : gi);
b = bi > 255 ? 255 : (bi < 0 ? 0 : bi);
}
if (cfi != 32769) {
// Transform to range [-128, 127]
int ri = r - 128;
int gi = g - 128;
int bi = b - 128;
// Multiply contrast factor
ri = (ri * cfi) >> 15;
gi = (gi * cfi) >> 15;
bi = (bi * cfi) >> 15;
// Transform back to range [0, 255]
ri = ri + 128;
gi = gi + 128;
bi = bi + 128;
// Clamp to byte boundaries
r = ri > 255 ? 255 : (ri < 0 ? 0 : ri);
g = gi > 255 ? 255 : (gi < 0 ? 0 : gi);
b = bi > 255 ? 255 : (bi < 0 ? 0 : bi);
}
color = new Color(r, g, b);
outPixels[index] = color.getRGB();
}
}
BufferedImage buffered = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
buffered.setRGB(0, 0, width, height, outPixels, 0, width);
return buffered;
}
int width = img.getWidth(null);
int height = img.getHeight(null);
BufferedImage src = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
src.getGraphics().drawImage(img, 0, 0, null);
int[] inPixels = new int[width * height];
int[] outPixels = new int[width * height];
int index = 0;
src.getRGB(0, 0, width, height, inPixels, 0, width);
int r, g, b;
int bfi = (int) (getBrightness() * 255);// 0~255
float cf = 1f + getContrast();// -1~1
cf *= cf;
int cfi = (int) (cf * 32768) + 1;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
index = row * width + col;
Color color = new Color(inPixels[index]);
r = color.getRed();
g = color.getGreen();
b = color.getBlue();
if (bfi != 0) {
// Add brightness
int ri = r + bfi;
int gi = g + bfi;
int bi = b + bfi;
// Clamp to byte boundaries
r = ri > 255 ? 255 : (ri < 0 ? 0 : ri);
g = gi > 255 ? 255 : (gi < 0 ? 0 : gi);
b = bi > 255 ? 255 : (bi < 0 ? 0 : bi);
}
if (cfi != 32769) {
// Transform to range [-128, 127]
int ri = r - 128;
int gi = g - 128;
int bi = b - 128;
// Multiply contrast factor
ri = (ri * cfi) >> 15;
gi = (gi * cfi) >> 15;
bi = (bi * cfi) >> 15;
// Transform back to range [0, 255]
ri = ri + 128;
gi = gi + 128;
bi = bi + 128;
// Clamp to byte boundaries
r = ri > 255 ? 255 : (ri < 0 ? 0 : ri);
g = gi > 255 ? 255 : (gi < 0 ? 0 : gi);
b = bi > 255 ? 255 : (bi < 0 ? 0 : bi);
}
color = new Color(r, g, b);
outPixels[index] = color.getRGB();
}
}
BufferedImage buffered = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
buffered.setRGB(0, 0, width, height, outPixels, 0, width);
return buffered;
}
2013年10月24日 星期四
SQL INDEX
create index log_id on log_records(id);
create index log_dt_id on log_records(datetime);
create index log_rrdt_id on relay_records(datetime);
create index log_crdt_id on card_records(datetime);
create index log_dt_id on log_records(datetime);
create index log_rrdt_id on relay_records(datetime);
create index log_crdt_id on card_records(datetime);
2013年10月15日 星期二
JAVA 取得可用字型名稱
String[] fontList = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();
.getAvailableFontFamilyNames();
2013年10月9日 星期三
SQL 隨機取一筆
SQL Server 2005
SELECT TOP 1 Field1, …, FieldN
FROM Table1
ORDER BY NEWID()
Access
SELECT TOP 1 Field1 , …, FieldN
FROM Table1
ORDER BY Rnd(Field1)
MySQL
SELECT Field1, …, FieldN
FROM Table1
ORDER BY RAND()
LIMIT 1
Oracle 10g Express
SELECT Field1, …, FieldN
FROM ( SELECT Field1, …, FieldN
FROM Table1
ORDER BY dbms_random.value)
WHERE rownum <= 1
SQLite 3
SELECT Field1, …, Field2
FROM Table1
ORDER BY Random()
LIMIT 1
PostgreSQL 8.3
SELECT “Field1″, “…”, “FieldN”
FROM “Table1″
ORDER BY RANDOM()
LIMIT 1
2013年10月8日 星期二
SQL IF ELSE
if not exists (select TOP(1) * from test_result_list where sub_cls_id ='C0000001-001' AND empno = '00000046')
insert into test_result_list (sub_cls_id,empno,is_pass,point) values('C0000001-001','00000046',0,12)
else
update test_result_list set sub_cls_id = 'C0000001-001',empno='00000046',is_pass=1,point=70 where sub_cls_id = 'C0000001-001' AND empno='00000046'
insert into test_result_list (sub_cls_id,empno,is_pass,point) values('C0000001-001','00000046',0,12)
else
update test_result_list set sub_cls_id = 'C0000001-001',empno='00000046',is_pass=1,point=70 where sub_cls_id = 'C0000001-001' AND empno='00000046'
2013年9月12日 星期四
Jar 簽證
1.在cmd中用keytool建立公鑰和密鑰,生成簽名憑証
keytool -genkey -keystore 文件名.store -alias 别名(記住密碼) -validity (days)
Ex: keytool -genkey -keystore test.store -alias testkey -validity 7200 (私(密)key)
2.執行jarsigner工具,並指定jar檔和私密金鑰的別名
jarsigner -keystore 密鑰名 JAR名 别名
ex: jarsigner -keystore teststore testclient.jar testkey
3.產生certs.store並把testkey憑證加入
keytool -export -keystore test.store -alias testkey -file testkey.cert
keytool -import -keystore cert.store -alias testkey -file testkey.cert
4. 必須產生policy授與權限給所有以該金鑰庫中簽章的applet
在policy檔中加入
keystore "keystoreURL","keystore類型"
e.g
keystore "file:cert.store","JKS"
接著在policy中加入
grant
{
permission java.io.FilePermission "","";
};
5.測試時,確定金鑰庫 policy 和jar全在同一目錄下
qppletviewer -J-Djava.security.policy=applets.policy TestApplet.html
application -Djava.security.policy=applets.policy TestApplet.html
https://code.google.com/p/java-simple-serial-connector/wiki/jSSC_Terminal
keytool -genkey -keystore 文件名.store -alias 别名(記住密碼) -validity (days)
Ex: keytool -genkey -keystore test.store -alias testkey -validity 7200 (私(密)key)
2.執行jarsigner工具,並指定jar檔和私密金鑰的別名
jarsigner -keystore 密鑰名 JAR名 别名
ex: jarsigner -keystore teststore testclient.jar testkey
3.產生certs.store並把testkey憑證加入
keytool -export -keystore test.store -alias testkey -file testkey.cert
keytool -import -keystore cert.store -alias testkey -file testkey.cert
4. 必須產生policy授與權限給所有以該金鑰庫中簽章的applet
在policy檔中加入
keystore "keystoreURL","keystore類型"
e.g
keystore "file:cert.store","JKS"
接著在policy中加入
grant
{
permission java.io.FilePermission "","";
};
5.測試時,確定金鑰庫 policy 和jar全在同一目錄下
qppletviewer -J-Djava.security.policy=applets.policy TestApplet.html
application -Djava.security.policy=applets.policy TestApplet.html
https://code.google.com/p/java-simple-serial-connector/wiki/jSSC_Terminal
2013年9月2日 星期一
MySQL 日期
datetime('ColName','-1 day')日期減一天
MySQL datediff(date1,date2):取得date1 - date2 的天數
select datediff('2008-08-08', '2008-08-01');結果: -7
select datediff('2008-08-01', '2008-08-08');結果: 7
MySQL timediff(datetime1,datetime2):取得datetime1 - datetime2 的天數
select timediff('2008-08-08 08:08:08', '2008-08-08 00:00:00');結果:08:08:08
select timediff('08:08:08', '00:00:00');結果:08:08:08
MySQL datediff(date1,date2):取得date1 - date2 的天數
select datediff('2008-08-08', '2008-08-01');結果: -7
select datediff('2008-08-01', '2008-08-08');結果: 7
MySQL timediff(datetime1,datetime2):取得datetime1 - datetime2 的天數
select timediff('2008-08-08 08:08:08', '2008-08-08 00:00:00');結果:08:08:08
select timediff('08:08:08', '00:00:00');結果:08:08:08
MSSQL
time 型態 增加分鐘 DATEADD(MINUTE, @MinutesToAdd, @StartTime);
datetime 型態 增加分鐘 DATEADD(MINUTE, @StartTime, @MinutesToAdd);
2013年8月21日 星期三
IOS Static lib
創建
1.Create Project -> Cocoa Touch Static Libary
2.Product -> Scheme -> Edit Scheme -> Build Configuration 改 Release
3.選擇真機或模擬器 Build
1.Create Project -> Cocoa Touch Static Libary
2.Product -> Scheme -> Edit Scheme -> Build Configuration 改 Release
3.選擇真機或模擬器 Build
訂閱:
文章 (Atom)