我正在创建动态壁纸,并且在每个画布上绘画
颜色不断变化的Runnable.run()调用,我希望放置一个
渐变超过顶部,但我正在创建的渐变带
太可怕了搜寻了几天后,我想出了两种解决方案:
将抖动设置为true
将画布位图设置为ARGB_8888
我试过了第一个(将dither设置为true)
getWallpaper()访问器和Paint对象,但没有帮助(我看不到
任何抖动都没有),所以我尝试过更改画布位图,但是我
不确定如何实际显示
// _canvasBmp = Bitmap.createBitmap(metrics.wIDthPixels, metrics.heightPixels, Bitmap.Config.ARGB_8888);_shadowPaint.setStyle(Paint.Style.FILL);_shadowPaint.setShader(new RadialGradIEnt(metrics.wIDthPixels / 2,metrics.heightPixels / 2, metrics.heightPixels / 2, 0x00000000,0x33000000, Shader.TileMode.CLAMP));_shadowPaint.setDither(true); // this hasn't seemed to have done anything to fix the banding// my main rendering method is this (based on the Google live wallpaper example)voID drawFrame(){ final SurfaceHolder holder = getSurfaceHolder(); Canvas c = null; try { c = holder.lockCanvas(); // c.setBitmap(_canvasBmp);// this was my attempt to update the bitmap to one that was ARGB_8888 but it dIDn't render at all if (c != null) { // draw something drawBackground(c); drawtouchPoint(c); drawShading(c); drawborder(c); getWallpaper().setDither(true); // yet another attempt to get some kind of dithering going to no avail } } finally { if (c != null) holder.unlockCanvasAndPost(c); } _handler.removeCallbacks(_drawClock); // _drawClock is the Runnable object if (_isVisible) { _handler.postDelayed(_drawClock, 1000 / 25); }}private voID drawShading(Canvas c){ c.drawRect(_screenBounds, _shadowPaint); // _screenBounds is a Rect set to the _metrics wIDth and height}
在此先感谢您的时间
解决方法:
在您的PinupEngine类中…
@OverrIDepublic voID onCreate(SurfaceHolder surfaceHolder) { super.onCreate(surfaceHolder); surfaceHolder.setFormat(androID.graphics.PixelFormat.RGBA_8888);}
我发现liveWallpaper绘图在位图像素类型较大时较慢.我希望它也会使用更多的内存(比Double多).如果可以的话,尝试限制RGBA_8888的使用可能是值得的.我认为默认值为RGB_565,对此不确定.
总结以上是内存溢出为你收集整理的android-动态壁纸渐变条纹:是否可以使用ARGB_8888或抖动来解决?全部内容,希望文章能够帮你解决android-动态壁纸渐变条纹:是否可以使用ARGB_8888或抖动来解决?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)