安卓:填充留下了位图与白色 [英] Android: padding left a bitmap with white color

查看:143
本文介绍了安卓:填充留下了位图与白色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置全白的10行上的位图的左边? 心中已经得到了一个位图具有在左侧被填充。我以为我可以在旧getpixel每个位置setpixel在新的(白色或彩色),比返回新位图上创建一个新的形象迭代...这是错的? 任何建议?非常感谢!

How to set all white the 10 rows on the left side of a Bitmap? I'v got a Bitmap that has to be padded on the left side. I thought i can create a new image iterate on the old one getpixel for each position and setpixel on the new one (white or colored) than return the new bitmap...is this wrong? Any suggestion? thanks a lot!

推荐答案

您可以改为创建一个新的位图像素的微胖数量。 设置此为画布位图和颜色整个图像用所需的颜色,然后复制位图。

You can instead create a new Bitmap with the extra padding number of pixels. Set this as the canvas bitmap and Color the entire image with the required color and then copy your bitmap.

Public Bitmap pad(Bitmap Src, int padding_x, int padding_y){
    Bitmap outputimage = Bitmap.createBitmap(Src.getWidth() + padding_x,Src.getHeight() + padding_y, Bitmap.Config.ARGB_8888);
Canvas can = new Canvas(outputimage);
can.drawARGB(FF,FF,FF,FF); //This represents White color
can.drawBitmap(Src, padding_x, padding_y, null);

return outputimage;
}

这篇关于安卓:填充留下了位图与白色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆