该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

public class ImageThumbnail {

public static int reckonThumbnail(int oldWidth, int oldHeight,

int newWidth, int newHeight) {

if ((oldHeight > newHeight && oldWidth > newWidth)

|| (oldHeight <= newHeight && oldWidth > newWidth)) {

int be = (int) (oldWidth / (float) newWidth);

if (be <= 1)

be = 1;

return be;

} else if (oldHeight > newHeight && oldWidth <= newWidth) {

int be = (int) (oldHeight / (float) newHeight);

if (be <= 1)

be = 1;

return be;

}

return 1;

}

public static Bitmap PicZoom(Bitmap bmp, int width, int height) {

int bmpWidth = bmp.getWidth();

int bmpHeght = bmp.getHeight();

Matrix matrix = new Matrix();

matrix.postScale((float) width / bmpWidth, (float) height / bmpHeght);

return Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeght, matrix, true);

}

public static String savaPhotoToLocal(Intent data, Bitmap btp) {

// 如果文件夹不存在则创建文件夹,并将bitmap图像文件保存

String filename = System.currentTimeMillis() + ".jpg";

File tempFile = new File(SgsCons.ROOT_DIR, filename);

String filePath = tempFile.getAbsolutePath();

try {

// 将bitmap转为jpg文件保存

FileOutputStream fileOut = new FileOutputStream(tempFile);

btp.compress(CompressFormat.JPEG, 100, fileOut);

} catch (FileNotFoundException e) {

e.printStackTrace();

}

return filePath;

}

}

public class ImageThumbnail {

public static int reckonThumbnail(int oldWidth, int oldHeight,

int newWidth, int newHeight) {

if ((oldHeight > newHeight && oldWidth > newWidth)

|| (oldHeight <= newHeight && oldWidth > newWidth)) {

int be = (int) (oldWidth / (float) newWidth);

if (be <= 1)

be = 1;

return be;

} else if (oldHeight > newHeight && oldWidth <= newWidth) {

int be = (int) (oldHeight / (float) newHeight);

if (be <= 1)

be = 1;

return be;

}

return 1;

}

public static Bitmap PicZoom(Bitmap bmp, int width, int height) {

int bmpWidth = bmp.getWidth();

int bmpHeght = bmp.getHeight();

Matrix matrix = new Matrix();

matrix.postScale((float) width / bmpWidth, (float) height / bmpHeght);

return Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeght, matrix, true);

}

public static String savaPhotoToLocal(Intent data, Bitmap btp) {

// 如果文件夹不存在则创建文件夹,并将bitmap图像文件保存

String filename = System.currentTimeMillis() + ".jpg";

File tempFile = new File(SgsCons.ROOT_DIR, filename);

String filePath = tempFile.getAbsolutePath();

try {

// 将bitmap转为jpg文件保存

FileOutputStream fileOut = new FileOutputStream(tempFile);

btp.compress(CompressFormat.JPEG, 100, fileOut);

} catch (FileNotFoundException e) {

e.printStackTrace();

}

return filePath;

}

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐