jjzjj

createBitmap

全部标签

android - 将图像或照片切成 fragment

伙计们,我正在开发一款益智游戏,其中一部分我想将图像切割成15block填满整个屏幕,而且我需要将这些block一个放在另一个下方(在触摸屏上)。我的图像尺寸是414*310,我得到了代码,但我不确定如何使用它,请帮忙。我的图片在drawable文件夹中。publicBitmap[]splitBitmap(Bitmappicture){BitmapscaledBitmap=Bitmap.createScaledBitmap(picture,240,240,true);Bitmap[]imgs=newBitmap[9];imgs[0]=Bitmap.createBitmap(scaled

c# - Android - Bitmap.CreateBitmap - 空指针异常

有时,当我尝试创建模糊位图时,我会收到“空指针异常”。发生在这段代码中(我最近开始捕捉异常,所以至少它不会使应用程序崩溃):try{using(Bitmap.Configconfig=Bitmap.Config.Rgb565){returnBitmap.CreateBitmap(blurredBitmap,width,height,config);}}catch(Java.Lang.Exceptionexception){Util.Log(exception.ToString());}有关我传递给“CreateBitmap”方法的参数的更多详细信息,请参阅这些图片:扩展参数如下:完全异

android - createBitmap(int width, int height, Bitmap.Config config) 如何填充Bitmap?

createBitmap(intwidth,intheight,Bitmap.Configconfig)如何填充Bitmap?我想创建一个具有给定宽度和高度的位图,我不想生成一个随意的Color数组。我发现这个方法http://developer.android.com/reference/android/graphics/Bitmap.html#createBitmap(int,%20int,%20android.graphics.Bitmap.Config)创建一个没有任何来源的位图。该方法如何填充位图的像素? 最佳答案 带零,

android - 如何在 Android 上不使用 createBitmap() 和 copy() 将位图复制到另一个位图?

我有两个位图,我在onCreate()中创建它们。Bitmapbmp1=BitmapFactory.decodeResource(getResources(),id);Bitmapbmp2=BitmapFactory.decodeResource(getResources(),id);bmp1和bmp2是一样的。我在我的应用程序中修改了bmp2。完成工作后,我单击“清除”按钮。当我单击“清除”按钮时,我试图将bmp1(干净的图像)复制到bmp2(更改的图像)。但我不想使用createBitmap()或copy()函数。因为这些都是创建新的Bitmap对象。我只想使用我的两个位图(bmp

android - createBitmap --- java.lang.IllegalArgumentException : x must be < bitmap. 宽度()

我在截图和创建带裁剪图片的位图时出错下面是我的代码Viewv1=mKittyBGLayer.getRootView();v1.setDrawingCacheEnabled(true);Bitmapsource=v1.getDrawingCache();intwidth=source.getWidth();intheight=source.getHeight();System.out.println("vListView:-"+vListView.getWidth());System.out.println("hListView:-"+hListView.getHeight());Sys

java - Android Bitmap.createBitmap() 填充堆

我需要大位图(6000x2000),所以我创建了一个:Bitmap.Configconf=Bitmap.Config.ARGB_4444;Bitmapbm=Bitmap.createBitmap(6000,2000,conf);然后在该方法的末尾,我回收了bm并将其设置为null。但同样,每次调用我的方法时,我的堆都会增长。每次直到抛出OutOfMemoryError。 最佳答案 问题在于,在Android3.x之前,位图可能需要几个GC周期才能在Android上正确发布。即使您调用recycle(),我相信至少在下一次GC之前位图

android - Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height) 返回错误的位图

我必须裁剪位图图像。为此,我正在使用Bitmapbitmap=Bitmap.createBitmap(imgView.getWidth(),imgView.getHeight(),Bitmap.Config.RGB_565);Bitmapresult=Bitmap.createBitmap(bitmap,imgView.getLeft()+10,imgView.getTop()+50,imgView.getWidth()-20,imgView.getHeight()-100);bitmap.recycle();Canvascanvas=newCanvas(result);imgView

Android Bitmap.createBitmap() 返回高度和宽度为 -1 的位图

为什么会Bitmapbmp;bmp=Bitmap.createBitmap(100,100,Config.RGB_565);曾经返回过高度和宽度为-1的位图吗?我在文档中没有看到任何关于此的信息。只在documentation中看到这个ThrowsIllegalArgumentExceptionifthewidthorheightare但是在eclipse中调试时,我看到创建后宽度和高度为-1。一切似乎都正确显示。[更新]如果我添加一个日志并获取宽度和高度Log.i(logTag,"bmp-(width,height)("+bmp.getWidth()+","+bmp.getHeigh

Android - 新的 BitmapDrawable 已弃用;替代 Bitmap.createBitmap 必须有 w/h > 0

我使用了PopupWindow。使用此PopupWindow,我将BackgroundDrawable设置为空的BitmapDrawable。当我使用下面的代码时,它会给出弃用警告:myPopupWindow.setBackgroundDrawable(newBitmapDrawable());所以我改成了:myPopupWindow.setBackgroundDrawable(newBitmapDrawable(getApplicationContext().getResources(),Bitmap.createBitmap(0,0,Bitmap.Config.ARGB_8888)

android - 如何避免android中的createBitmap()崩溃

我在多个地方使用createBitmap()。有时这个api会抛出OutOfMemoryError()异常。如何避免这个异常?我正在使用如下,createBitamp(width,height,Config.ARGB_8888);width=屏幕宽度height=屏幕高度任何帮助将不胜感激。 最佳答案 我在以下Android问题单中发布了一些有关如何处理位图的信息。可能对您有帮助:http://code.google.com/p/android/issues/detail?id=8488#c80
12