标签: bitmap

在设备上创建位图时内存不足

我有高分辨率图像的问题.

我使用nodpi-drawable文件夹为1280x720图像,并使用此代码来缩放它.

public static Drawable scaleDrawable(Drawable d, int width, Activity cxt)
    {
        BitmapDrawable bd = (BitmapDrawable)d;

        double oldWidth = bd.getBitmap().getWidth();
        double scaleFactor = width / oldWidth;

        int newHeight = (int) (d.getIntrinsicHeight() * scaleFactor);
        int newWidth = (int) (oldWidth * scaleFactor);

        Drawable drawable = new BitmapDrawable(cxt.getResources(),MainScreen.getResizedBitmap(bd.getBitmap(),newHeight,newWidth));

        BitmapDrawable bd2 = (BitmapDrawable)drawable;

        return  drawable;
    }

    public static Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { 

        int width = bm.getWidth(); 
        int height = bm.getHeight(); 

        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = …
Run Code Online (Sandbox Code Playgroud)

android bitmap out-of-memory

2
推荐指数
1
解决办法
2849
查看次数

如何在下载图像之前确定图像大小和尺寸

我有JPEG,GIF和PNG文件的图像URL.我想检查这些网址中的图片是否小于特定尺寸.

在此基础上,我想下载图像.

在Java中有ImageIO库,但是在AWT库中,我需要Android的东西.

java url android image bitmap

2
推荐指数
1
解决办法
6051
查看次数

在Imageview中清除图像

我经历了很多线程,但我还没有得到答案.

我正在以编程方式将图像设置为imageView

imageview.setBackgroundResource(R.Drawable.image);
Run Code Online (Sandbox Code Playgroud)

如果我将图像设置为如上所述,如果我给出,图像是否会被清除

imageview.setImageDrawable(null);
Run Code Online (Sandbox Code Playgroud)

什么imageview.setBackgroundDrawable(null)意思?

有什么区别

imageview.setImageDrawable(null);
Run Code Online (Sandbox Code Playgroud)

imageview.setImageBitmap(null);
Run Code Online (Sandbox Code Playgroud)

imageview.setBackgroundDrawable(null);
Run Code Online (Sandbox Code Playgroud)

android bitmap drawable imageview

2
推荐指数
1
解决办法
2万
查看次数

屏幕旋转后,Android Imageview会显示旧的位图

我的应用程序应该首先显示图像,当按下按钮时,另一个图像显示在图像视图中.但是,当旋转屏幕时,imageView会显示旧图像.我该怎么办呢?(bits是在创建时加载到imageView的Bitmap)

我的代码如下:

    RGBToBitmap(rgb.getWindow(), bits); //this loads a new image into bits

    imageView.setImageBitmap(bits);
Run Code Online (Sandbox Code Playgroud)

android bitmap screen-orientation imageview

2
推荐指数
1
解决办法
4817
查看次数

如何根据屏幕尺寸缩放图像?

我正在制作一个Android应用程序,我使用它来缩放位图 bitmap2 = Bitmap.createScaledBitmap(bmp, 150, 150, true);

这个图像在大屏幕的手机上看起来不错......但是当它在小尺寸的手机上使用时它会不成比例.....任何人都知道它的解决方案吗?

android bitmap bitmapimage android-imageview

2
推荐指数
1
解决办法
8222
查看次数

从通用图像加载器获取位图

我正在尝试使用Universal Image Loader Library 获取位图资源.我已经覆盖了onLoadComplete()方法,如下所示:

loader.displayImage(thumbnail.get(position), hold.ivThumbnailReflection, options, new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String arg0, View arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onLoadingComplete(String urlLink, View arg1, Bitmap loadedImage) {

            Log.i("loading complete","loading complete "+loadedImage);
            hold.ivThumbnail.setImageBitmap(loadedImage);


        }

        @Override
        public void onLoadingCancelled(String arg0, View arg1) {
            // TODO Auto-generated method stub

        }
    });
Run Code Online (Sandbox Code Playgroud)

图像在ivThumbnailReflection视图中设置,但视图上没有图像ivThumbnail.当我为loadedImage打印对象时,我得到一个表格 - android.graphics.Bitmap@4170f1d0. …

android bitmap universal-image-loader

2
推荐指数
2
解决办法
2万
查看次数

位图到文件,可以通过异步上传

经过一天的头痛,由于以前的问题实施工作照片上传系统,我觉得我在家里伸展.我的最后和最后一步是允许我的用户在裁剪后上传图像.

裁剪发生后,我可以访问位图和使用位图的imageView.使用的异步请求库是:http://loopj.com/android-async-http/

api im using以这样的方式设置,我需要发送一个"文件",如下所示:

File myFile = new File("/path/to/file.png");
RequestParams params = new RequestParams();
try {
    params.put("profile_picture", myFile);
} catch(FileNotFoundException e) {}
Run Code Online (Sandbox Code Playgroud)

将位图转换为"文件"有什么选择?

upload android asynchronous file bitmap

2
推荐指数
1
解决办法
1360
查看次数

Android快捷方式位图启动器图标大小

我有问题找到我的快捷方式的正确的启动器图标大小.

在我的Nexus 7.2上,android.R.dimen.app_icon_size(参见代码)的值为96像素.但是,如果我在主屏幕的屏幕截图上测量其他应用的真实图标大小,则为120像素.创建一个shortshut后,它比所有其他应用程序图标(120px)更小(96像素)

在我的三星Galaxy SII android.R.dimen.app_icon_size是72.这匹配我的截图测量.

这里的结果

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Run Code Online (Sandbox Code Playgroud)

Nexus 7.2:

android.R.dimen.app_icon_size = 96
metrics.dip = 192
metrics.density = 2.0
metrics.densityDpi = 320
metrics.heightPixels = 1824
metrics.scaledDensity = 2.0
metrics.widthPixels = 1200
metrics.xdpi = 320.842
metrics.ydpi = 322.966
Run Code Online (Sandbox Code Playgroud)

三星SII:

android.R.dimen.app_icon_size = 72
metrics.dip = 108
metrics.density = 1.5
metrics.densityDpi = 240
metrics.heightPixels = 800
metrics.scaledDensity = 1.5
metrics.widthPixels = 480
metrics.xdpi = 217.71428
metrics.ydpi = 218.49463
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

// Calculate launcher icon size
int size = (int) …
Run Code Online (Sandbox Code Playgroud)

icons android bitmap shortcut launcher

2
推荐指数
1
解决办法
2692
查看次数

两个不同的对象使用一个内存区域?

我需要能够在我的简单delphi绘制中进行Undo和Redo操作.所以我决定制作一些容器来保存历史记录(不是完整的历史记录,只有少数以前的位图文件).

unit HistoryQueue;

interface

uses
  Graphics;

type
myHistory = class
  constructor Create(Size:Integer);
  public
    procedure Push(Bmp:TBitmap);
    function Pop():TBitmap;
    procedure Clean();
    procedure Offset();
    function isEmpty():boolean;
    function isFull():boolean;
    function getLast():TBitmap;
  protected

end;

var
    historyQueueArray: array of TBitmap;
    historyIndex, hSize:Integer;
implementation

procedure myHistory.Push(Bmp:TBitmap);
var tbmp:TBitmap;
begin
  if(not isFull) then begin
      Inc(historyIndex);
      historyQueueArray[historyIndex]:=TBitmap.Create;
      historyQueueArray[historyIndex].Assign(bmp);
  end else begin
      Offset();
      historyQueueArray[historyIndex]:=TBitmap.Create;
      historyQueueArray[historyIndex].Assign(bmp);
  end;

end;

procedure myHistory.Clean;
var i:Integer;
begin
{  for i:=0 to hSize do begin
    historyQueueArray[i].Free;
    historyQueueArray[i].Destroy;
  end;        }

end;

constructor myHistory.Create(Size:Integer);
begin
  hSize:=Size;
  SetLength(historyQueueArray, hSize); …
Run Code Online (Sandbox Code Playgroud)

delphi paint bitmap delphi-7 undo-redo

2
推荐指数
1
解决办法
143
查看次数

Lwjgl/Opengl字体渲染

我正在尝试使用opengl在lwjgl显示器上显示带有自定义字体的文本.目前我正在使用我的自定义位图字体类从png文件加载字体,并以与tileset相同的方式显示它们.它工作正常但是当我将文本绘制到屏幕时,字符之间的间距是不同的,因为字母M比字母I宽,并且所有字符具有不同的宽度.有没有办法检测每个角色的宽度?或者是否有任何特定于lwjgl中字体的库?有一种方法可以使用slick2d来完成它,但加载整个库只是为了显示文本毫无意义!

opengl fonts rendering bitmap lwjgl

2
推荐指数
1
解决办法
2330
查看次数