编辑后图像尺寸缩小
我通过组合两个图像创建了一个新图像。但最终图像的尺寸会缩小到屏幕的尺寸(分辨率)。使用的代码是
Bitmap pic = BitmapFactory.decodeResource(getResources(), R.drawable.me);
Bitmap stat= BitmapFactory.decodeResource(getResources(), R.drawable.static);
Bitmap out1 = Bitmap.createBitmap(stat) ;
Canvas comboImage = new Canvas(out1);
comboImage.drawBitmap(map, 0, 0, null);
comboImage.drawBitmap(pic, 150f, 30f, null);
在这之后我存储图像,因为
OutputStream os = null;
os = new FileOutputStream("/sdcard/DCIM/Camera/" + "myNewFileName5.png");
out1.compress(CompressFormat.PNG, 100, os);
os.flush();
os.close();
图像的尺寸是静态的 640x480。但我的最终图像是 320x240,这是我的手机屏幕分辨率。是因为我使用Canvas吗?有没有什么方法可以在不改变图像大小的情况下做到这一点?
i created a new image by combining two images. but the size of the final is image is reduced to the size(resolution) of the screen. the code used is
Bitmap pic = BitmapFactory.decodeResource(getResources(), R.drawable.me);
Bitmap stat= BitmapFactory.decodeResource(getResources(), R.drawable.static);
Bitmap out1 = Bitmap.createBitmap(stat) ;
Canvas comboImage = new Canvas(out1);
comboImage.drawBitmap(map, 0, 0, null);
comboImage.drawBitmap(pic, 150f, 30f, null);
after this i am storing the image as
OutputStream os = null;
os = new FileOutputStream("/sdcard/DCIM/Camera/" + "myNewFileName5.png");
out1.compress(CompressFormat.PNG, 100, os);
os.flush();
os.close();
dimension of image is staic 640x480. but my final image is 320x240, which is my phones screen resolution. is it because i use Canvas? is there any way to do this without changing the image sizes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查你的 API 版本? 在 onDraw( ) 方法,为什么提供的 Canvas 已经具有缩放比例? 对于低于 4 的 API 级别,画布具有默认的缩放兼容模式,就好像它针对的是 G1 屏幕一样。
Check your API version? There's an explanation at In the onDraw() method, why does the supplied Canvas already have scale? that for an API level lower than 4 the canvas has a default scaled compatibility mode as if it were targeting a G1 screen.