我不想机器人来自动调整我的位图 [英] I don't want Android to resize my bitmap Automatically

查看:131
本文介绍了我不想机器人来自动调整我的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把一些位图资源/绘制。

I have placed some bitmaps in res/drawable.

在我加载位图由BitmapFactory.de codeResource(),我发现,它们会自动根据密度的大小。

After I load the bitmaps by BitmapFactory.decodeResource(), I find out that they are resized automatically according the density.

这是不是我想要的。 我希望他们能够保持其原有的大小(像素大小)。

This is not what I want. I want them to keep their original size (pixel size).

我应该怎么办?

推荐答案

正如有人说的另外一个问题,使用提拉 - nodpi文件夹将prevent机器人从调整你的照片。

As was said in another question, using the drawable-nodpi folder will prevent android from resizing your pictures.

此外,如果你想有多个版本的华电国际和LDPI格式的图像,但不希望系统调整它们的大小(以保持两种分辨率例如功率),你可以使用下面的code载入您bitmpap:

Additionally, if you want to have multiple versions of an image for hdpi and ldpi format, but don't want the system to resize them (to keep a power of two resolution for example), you can use the following code while loading your bitmpap :

// ask the bitmap factory not to scale the loaded bitmaps
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;

// load the bitmap
Bitmap bitmap = BitmapFactory.decodeResource(ctx.getResources(), R.id.mybmp, opts);

这篇关于我不想机器人来自动调整我的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆