gpt4 book ai didi

java - 使用 Android 中另一个位图中的像素填充空白位图?

转载 作者:太空狗 更新时间:2023-10-29 12:56:54 25 4
gpt4 key购买 nike

我想创建一个空白位图,我将有条件地用从另一个包含资源的位图中获得的像素 Rects 填充它。有可能这样做吗?我将如何着手做这样的事情?

我只想在准备好绘制后绘制位图。

现在我正在使用 Canvas 绘制使用 Rect 段的位图,但在它准备好之前我不需要绘制它。

谢谢!

最佳答案

Bitmap other = ...;
//create a blank bitmap
Bitmap newBitmap = Bitmap.createBitmap(other.getWidth(),
other.getHeight(), other.getConfig());

//copy some pixels from 'other'
int x=14,y=45,width=23,height=56;
int [] pixels = new int[width * height];
other.getPixels(pixels, 0, width, x, y, width, height);
newBitmap.setPixels(pixels, 0, width, x, y, width, height);

关于java - 使用 Android 中另一个位图中的像素填充空白位图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5545215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com