简体   繁体   English

在Android上实例化Canvas之后没有任何反应

[英]Nothing happens after instantiate Canvas on android

I don't know what is happening with Canvas : 我不知道Canvas发生了什么:

// @param String source
Bitmap bmp = BitmapFactory.decodeFile(source);

Log.i("output", "This message will be printed!");

Canvas canvas = new Canvas(bmp);

Log.i("output", "This message will NOT be printed, canvas stop all!");

After instantiate Canvas , nothing is being printed and I cannot run any code, but the application does not close. 实例化Canvas ,什么都没有打印,并且我无法运行任何代码,但是应用程序无法关闭。

► Run (output after the call): ►运行(通话后输出):

D/dalvikvm: GC_CONCURRENT freed 131K, 4% free 11360K/11783K, paused 11ms+1ms, total 15ms D / dalvikvm:GC_CONCURRENT释放了131K,4%释放了11360K / 11783K,暂停了11ms + 1ms,总计15ms

D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 22, 33856, 1157696 D / OpenGLRenderer:TextureCache :: callback:名称,删除的大小,mSize = 22、33856、1157696

D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 24, 36864, 1120832 D / OpenGLRenderer:TextureCache :: callback:名称,删除的大小,mSize = 24、36864、1120832

You need to create another bitmap with the properties of bmp and pass that to the canvas: 您需要使用bmp的属性创建另一个位图,并将其传递给画布:

Bitmap bmp = BitmapFactory.decodeFile(source);
Bitmap bmOverlay = Bitmap.createBitmap(bmp.getWidth(),bmp.getHeight(),bmp.getConfig());
Canvas canvas = new Canvas(bmOverlay);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM