可能重复:
将视图转换为位图而不在Android中显示它?
我正在尝试将视图从以下引用链接转换为位图
现在的问题是如何才能获得仅从视图转换的位图.在示例作者中使用了relativelayout.dispatchDraw(c),但这一行给出了编译时错误,即
来自ViewGroup类型的方法dispatchDraw(Canvas)不可见
这是我的代码,我在onCreate函数中编写了以下代码
Canvas c=null;
//Create Layout
RelativeLayout relativeView ;
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
);
relativeView = new RelativeLayout(this);
relativeView.setLayoutParams(lp);
//Background of Layout
Bitmap viewBgrnd = BitmapFactory.decodeResource(getResources(),R.drawable.bgblack);
relativeView.setBackgroundDrawable(new BitmapDrawable(viewBgrnd));
//associated with canvas
Bitmap returnedBitmap = Bitmap.createBitmap(320,480,Bitmap.Config.ARGB_8888);
c = new Canvas(returnedBitmap);
Paint paint = new Paint();
//Create Imageview that holds image
ImageView newImage = new ImageView(this);
Bitmap srcBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bgpink);
newImage.setImageBitmap(srcBitmap);
TextView newText = new TextView(this);
newText.setText("This is the text that its going to …Run Code Online (Sandbox Code Playgroud) 我害怕已经有这个问题的不幸答案,但以防万一......我正在使用SurfaceView用位图(灯光和颜色修改)进行一些图像处理,我需要导入修改后的位图(即新的位图中的SurfaceView的内容,以便我可以将其保存为图像文件.
我一直在环顾四周,似乎可以从View.getDrawingCache()获取一个位图,但它不适用于SurfaceView.我得到的只是一个空位图.
这有什么解决方案吗?
谢谢
我试图理解android.graphics.Matrix类中的9个值如何用于渲染某些东西(特别是Bitmap).
我在值数组中看到了9个索引的定义,但命名约定对我来说似乎没有多大意义.
我有自己的定位系统,我用于我的引擎中的所有对象.对我来说,一个方向包括一个位置,一个前向矢量和一个左矢量.
我试图弄清楚如何获取这3个数据(已经映射到屏幕空间)并创建一个android.graphics.Matrix,它将像我期望的那样呈现我的对象的位图.
任何帮助,将不胜感激.
谢谢
我创建了一个类,它有几个成员变量,所有这些变量都是可序列化的...除了一个Bitmap!我试图扩展位图并实现可序列化,而不是认为Bitmap是最终类.
我想保存课程(它基本上形成了游戏的当前状态),因此玩家可以提升并加载游戏.
我看到它的方式我有两个选择:1)找到另一种方法来保存游戏状态.任何帮助在这里将不胜感激.
2)比较将位图成员变量更改为int,并创建一个BitmapGetter类,该类具有基于int返回位图的静态方法.(这个选项并不容易,因为我的类包含了很多位图可能性,而且我创建游戏的方式意味着需要付出巨大的努力.
基本上我没有人可以责备,但我自己懒得创造一个位图变量而不考虑,但我会感激任何帮助......
我正在开发一个具有非常强烈的图像处理的应用程序,其中我ListFragments在水平方向上有多个FragmentStatePagerAdapter.我积极地采用了我能够在这里和其他地方找到的每一个技巧和建议.我下载位图并将它们保存到SD并作为软参考存储器缓存.
然而,当我在某个时刻使用应用程序时,我开始在LogCat中看到消息,就像下面的消息一样
11-05 15:57:43.951: I/dalvikvm-heap(5449): Clamp target GC heap from 32.655MB to 32.000MB
11-05 15:57:43.951: D/dalvikvm(5449): GC_FOR_MALLOC freed 0K, 24% free 11512K/14983K, external 17446K/17896K, paused 64ms
11-05 15:57:44.041: D/dalvikvm(5449): GC_EXTERNAL_ALLOC freed <1K, 24% free 11511K/14983K, external 17258K/17896K, paused 77ms
Run Code Online (Sandbox Code Playgroud)
如果我继续,上面的消息将变得更加紧迫
11-05 16:02:09.590: D/dalvikvm(5449): GC_FOR_MALLOC freed 0K, 23% free 11872K/15239K, external 17497K/17896K, paused 71ms
11-05 16:02:09.700: D/dalvikvm(5449): GC_EXTERNAL_ALLOC freed <1K, 23% free 11872K/15239K, external 17497K/17896K, paused 84ms
11-05 16:02:09.720: E/dalvikvm-heap(5449): 192816-byte external allocation too large for this …Run Code Online (Sandbox Code Playgroud) 在我的代码中,我使用c#和ASP.NET动态创建一个位图.比我需要在asp图像控件上显示它.无论如何都可以使用处理程序吗?
我正在制作一个绘图应用程序,并希望实现一个撤消功能来删除前一个绘制的路径.
private HashMap<Integer, Path> pathMap; // current Paths being drawn
private HashMap<Integer, Point> previousPointMap; // current Points
private Bitmap bitmap; // drawing area for display or saving
private Canvas bitmapCanvas; // used to draw on bitmap
private Paint paintScreen; // use to draw bitmap onto screen
private Paint paintLine; // used to draw lines onto bitmap
public DrawView(Context context, AttributeSet attrs)
{
super(context, attrs); // pass context to View's constructor
this.context_new=context;
paintScreen = new Paint(); // used to display …Run Code Online (Sandbox Code Playgroud) 我试图从FB获取用户的个人资料图片并在我的应用程序上以圆形图像显示它.我能够检索并显示Facebook SDK提供的ProfilePictureView小部件中的显示图片.但是当我尝试获取该图像的位图并尝试将其置于圆形图像视图中时,我得到了默认的FB显示图片,如果您没有显示图片,则每个人都会被分配.我无法解决这个问题.我这样做是为了从ProfilePictureView中获取位图并将其设置为我的圆形视图.
if (session == Session.getActiveSession()) {
if (user != null) {
// Set the id for the ProfilePictureView
// view that in turn displays the profile picture.
profilePictureView.setDrawingCacheEnabled(true);
profilePictureView.setProfileId(user.getId());
Bitmap bitmap = profilePictureView.getDrawingCache();
Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
BitmapShader shader = new BitmapShader (bitmap, TileMode.CLAMP, TileMode.CLAMP);
Paint paint = new Paint();
paint.setShader(shader);
Canvas c = new Canvas(circleBitmap);
c.drawCircle(bitmap.getWidth()/2, bitmap.getHeight()/2, bitmap.getWidth()/2, paint);
profilePic.setImageBitmap(circleBitmap);
//profilePictureView.draw(c);
//c.drawCircle(bitmap.getWidth()/2, bitmap.getHeight()/2, bitmap.getWidth()/2, paint);
}
Run Code Online (Sandbox Code Playgroud)
这里profilePic是我想要放置圆形的ImageView,而profilePictureView是具有显示pic的ProfilePictureView id.
我想在Swift中操作像素级别的图像.针对目标c回答了这个问题:如何访问和操作JPEG图像像素?,但我想看看Swift的等效来源.
bitmap ×10
android ×7
c# ×2
image ×2
asp.net ×1
canvas ×1
controls ×1
facebook ×1
matrix ×1
memory-leaks ×1
orientation ×1
pdf ×1
pixels ×1
save ×1
serializable ×1
surfaceview ×1
swift ×1