如何从Uri中获取Bitmap对象(如果我成功将其存储在
/data/data/MYFOLDER/myimage.png或中file///data/data/MYFOLDER/myimage.png)以在我的应用程序中使用它?
有没有人知道如何实现这一目标?
我正在尝试在Honeycomb中启用hw加速,并在Canvas上显示一些Bitmaps.一切正常,但对于大位图(一维> 2048),我在日志中得到错误:
OpenGLRenderer:位图太大而无法上传到纹理中
我知道这是因为hw限制,并且可以通过减少最大位图大小来解决它,如果启用了hw加速(由View.isHardwareAccelerated()检查).
我的问题是:如何轻松确定硬件可用于位图绘制的最大纹理大小.2048似乎是对我的设备的限制,但它可能在不同的设备上有所不同.
编辑:我不是创建OpenGL应用程序,只是普通的应用程序,它可以利用hw加速.因此我根本不熟悉OpenGL,我只是在日志中看到OpenGL相关的错误,并期待解决它.
我需要以图库形式全屏显示原始图像.对于拇指,它将完美地工作,当我尝试使用原始源以全屏显示该图像时,它将无法显示.在大多数情况下,如果图像分辨率大于2000,那么它将显示错误位图太大而无法上传到纹理android.
我想阻止这一点,我搜索谷歌但没有得到任何答案.
Android Studio 1.3
Run Code Online (Sandbox Code Playgroud)
你好,
我从Nexus 5手机上拍了一些照片.我想使用一个作为加载到imageview的标题.
但是,我不确定缩放比例和drawable-xhdi,drawable-xxhdi等,它应该进入.
我目前的图片是:
Width: 3200 pixels
Height: 2368 pixels
Size: 2.4 MB
file type: jpg
Run Code Online (Sandbox Code Playgroud)
我有gimp照片编辑工具,我可以压缩成一个png文件,以减小大小.但我不知道如何才能让图片在其他屏幕密度上看起来更好看.我必须将哪个可绘制的文件夹放入?
非常感谢任何建议,
我有 ImageView 的简单布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.vbusovikov.glidetest.MainActivity">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
和简单的 Glide 表达式加载图像到这个 ImageView 只是为了测试 Glide
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView = (ImageView)findViewById(R.id.image);
Glide.with(this)
.load("http://you-ps.ru/uploads/posts/2013-08/1376601606_1273.png")
.error(R.mipmap.ic_launcher)
.into(imageView);
}
Run Code Online (Sandbox Code Playgroud)
但是,会显示错误图标。它可能是什么问题?我的网络上有代理服务器,并且有适合这种情况的 gradle.properties。
systemProp.http.proxyHost=proxy******.ru
systemProp.http.proxyPort=****
Run Code Online (Sandbox Code Playgroud)
但即使我尝试在任何代理之外启动这个小应用程序,它也不会出于某种原因工作。
我的 build.gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.vbusovikov.glidetest"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled …Run Code Online (Sandbox Code Playgroud) 可能重复:
"位图太大而无法上传到纹理中"
我正在使用相机拍照,然后我将图片保存在SD卡上,然后使用
Bitmap bm = BitmapFactory.decodeFile(path);
要获得位图,那么
imageView.setImageBitmap(bm); 设置它.
但是当我把它放到我的视野中使用时
mFrameLayout.addView(imageView); 没有显示图像,我回来了 Bitmap to large to be uploaded into texture
位图是 1944 high, 2592 wide
有什么想法吗?
I am using a tablet, 10.1 inches, acer iconia, a500, running ics.
我做了一个有很大背景的应用程序.它在Nexus 7上完美运行,但在我的Galaxy Nexus上,背景消失了,并在logcat中给出了错误:位图太大而无法上传到纹理(...).
我已经阅读了这篇文章并使用了那里的代码.我用来设置背景的代码是这样的:
Display display = getWindowManager().getDefaultDisplay();
width = display.getWidth();
height = display.getHeight();
//-------------------------------------------------------------------------------------------------------------
ImageView achtergrond = (ImageView)findViewById(R.id.achtergrond);
achtergrond.setImageBitmap(decodeSampledBitmapFromResource(getResources(), R.drawable.achtergrond, width, height));
} (...)
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options); …Run Code Online (Sandbox Code Playgroud)