This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline uint32_t YUV2RGB(int nY, int nU, int nV) { | |
nY -= 16; | |
nU -= 128; | |
nV -= 128; | |
if (nY < 0) nY = 0; | |
// This is the floating point equivalent. We do the conversion in integer | |
// because some Android devices do not have floating point in hardware. | |
// nR = (int)(1.164 * nY + 1.596 * nV); | |
// nG = (int)(1.164 * nY - 0.813 * nV - 0.391 * nU); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.util; | |
import android.annotation.SuppressLint; | |
import android.hardware.camera2.CameraCharacteristics; | |
import android.hardware.camera2.params.StreamConfigurationMap; | |
import java.lang.reflect.Array; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.InvocationTargetException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayInputStream; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.OutputStream; | |
import java.util.Map; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import com.itextpdf.text.Document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int calculateInSampleSize( | |
BitmapFactory.Options options, int reqWidth, int reqHeight) { | |
// Raw height and width of image | |
final int height = options.outHeight; | |
final int width = options.outWidth; | |
int inSampleSize = 1; | |
if (height > reqHeight || width > reqWidth) { | |
final int halfHeight = height / 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void drawWithPoint(Canvas canvas, int deep) { | |
float x0 = this.getMeasuredWidth() / 2; | |
float y0 = this.getMeasuredHeight() / 2; | |
paint.setColor(Color.BLACK); | |
for (int i = 0; i < 6145; i++) { | |
double angle = i * Math.PI / 512; | |
double radius = 0.3 * angle; | |
int y = (int) Math.round(radius * angle * Math.cos(angle)); | |
int x = (int) Math.round(radius * angle * Math.sin(angle)); | |
canvas.drawPoint(x0 + x, y0 + y, paint); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SIMCardInfo { | |
/** | |
* TelephonyManager提供设备上获取通讯服务信息的入口。 应用程序可以使用这个类方法确定的电信服务商和国家以及某些类型的用户访问信息。 | |
* 应用程序也可以注册一个监听器到电话收状态的变化。不需要直接实例化这个类 | |
* 使用Context.getSystemService(Context.TELEPHONY_SERVICE)来获取这个类的实例。 | |
*/ | |
private TelephonyManager telephonyManager; | |
/** | |
* 国际移动用户识别码 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#restore_cancel 代表需要过滤的字符串关键字 | |
# <string name="restore_cancel">@android:string\/cancel<\/string>/g 代表含有该关键字字符串的行该替换成什么样. | |
# res 代表查找路径 | |
sed -i 's/^.*restore_cancel.*$/ <string name="restore_cancel">@android:string\/cancel<\/string>/g' `grep restore_cancel -rl res` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// need permission | |
// <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | |
// <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> | |
public void saveMyBitmap(Bitmap mBitmap,String bitName) { | |
File f = new File( "/sdcard/Test/"+bitName + ".jpg"); | |
FileOutputStream fOut = null; | |
try { | |
fOut = new FileOutputStream(f); | |
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* YUV420sp | |
* | |
* @param inputWidth | |
* @param inputHeight | |
* @param scaled | |
* @return | |
*/ | |
public static byte[] getYUV420sp(int inputWidth, int inputHeight, Bitmap scaled) { | |
Log.d(TAG, "getYUV420sp: start"); |