我有一个基本图像视图,可以从SD卡加载图像。用户可以通过单击按钮将templates(bitmap images)
添加到此图像视图上,并可将添加的图像定位到用户需要的位置。我想将这些多张图像作为单张图像保存到SD卡中。我怎样才能做到这一点?在Android中保存多个图像
5
A
回答
3
您可以简单地获取ImageView的DrawingCache,然后将其转换为位图,然后将其保存到SDCARD。
imageview.setDrawingCacheEnabled(true);
Bitmap b = imageview.getDrawingCache();
b.compress(CompressFormat.JPEG, 100, new FileOutputStream("/sdcard/image.jpg"));
您可能必须在清单中设置SDCARD写入权限。
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
3
在此摘录看看:
How to merge multiple images into one image - Java ImageIO
int rows = 2; //we assume the no. of rows and cols are known and each chunk has equal width and height
int cols = 2;
int chunks = rows * cols;
int chunkWidth, chunkHeight;
int type;
//fetching image files
File[] imgFiles = new File[chunks];
for (int i = 0; i < chunks; i++) {
imgFiles[i] = new File("archi" + i + ".jpg");
}
//creating a bufferd image array from image files
BufferedImage[] buffImages = new BufferedImage[chunks];
for (int i = 0; i < chunks; i++) {
buffImages[i] = ImageIO.read(imgFiles[i]);
}
type = buffImages[0].getType();
chunkWidth = buffImages[0].getWidth();
chunkHeight = buffImages[0].getHeight();
//Initializing the final image
BufferedImage finalImg = new BufferedImage(chunkWidth*cols, chunkHeight*rows, type);
int num = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
finalImg.createGraphics().drawImage(buffImages[num], chunkWidth * j, chunkHeight * i, null);
num++;
}
}
System.out.println("Image concatenated.....");
ImageIO.write(finalImg, "jpeg", new File("finalImg.jpg"));
相关问题
- 1. 在Android中保存多个图像
- 2. 在android中保存图像
- 3. 在android中保存图像
- 4. 在c中保存多个图像
- 5. 在SQLite中保存多个图像
- 6. 将图像保存在缓存中android
- 7. 在android中捕获的图像保存
- 8. 在sqlite Android中保存图像?
- 9. 在Android阅读器中保存图像
- 10. Android将图像保存在SD卡中
- 11. 在webview中保存图像Android SDK
- 12. 在android中保存图像image
- 13. 在Android设备中保存图像
- 14. 如何在Android中保存图像?
- 15. 将图像保存在HashMap中Android
- 16. 在codeigniter中使用一对多保存多个图像
- 17. 在Android应用程序中添加许多保存的图像
- 18. 使用File.WriteAllBytes保存多个图像只保存最后一个
- 19. 保存图像库的Android
- 20. Android保存bmp图像
- 21. 相机Android:保存图像
- 22. 保存图像android sqlite
- 23. 保存图像,webview,android
- 24. 保存并上传多个图像
- 25. 保存多个元素的图像wpf
- 26. 保存多个图像进行分析
- 27. 解析 - 将多个图像保存在同一个对象中
- 28. 在一个数组中保存多个图像
- 29. 在一个文件中保存多个图像
- 30. Gnuplot保存很多图像
是Android中的BufferedImage ImageIO的可用这些类? –
我没有试过..只是一个线索..这是基于Java的文件。 – Venky
好吧,它看起来像这些类不适用于Android .. –