我正在使用此代码对GlSurfaceView上的位图赋予多重效果. 应用效果,图像上,使用效果
现在,我想保存位图.他们给出了保存位图的代码,但是,整个GlSurfaceView将被保存为位图图像.相反,我想只保存位图区域以保存为图像.
有一种方法可以获取像素并从中制作位图并制作图像.例如:
public Bitmap takeScreenshot(GL10 mGL) {
final int mWidth = mEffectView.getWidth();
final int mHeight = mEffectView.getHeight();
IntBuffer ib = IntBuffer.allocate(mWidth * mHeight);
IntBuffer ibt = IntBuffer.allocate(mWidth * mHeight);
mGL.glReadPixels(0, 0, mWidth, mHeight, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, ib);
// Convert upside down mirror-reversed image to right-side up normal
// image.
for (int i = 0; i < mHeight; i++) {
for (int j = 0; j < mWidth; j++) {
ibt.put((mHeight - i - 1) * mWidth + j, ib.get(i …Run Code Online (Sandbox Code Playgroud) 我已经读了很多关于这个的问题,但是我仍然没有使用这个代码...也许任何人都可以核对我的代码...我想使用com.android.camera.action.CROP从我知道位置的文件裁剪图像像这样...
mImageCaptureUri = Uri.fromFile(f);
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");
intent.setData(mImageCaptureUri);
intent.putExtra("crop", true);
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 200);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
Bundle extras = intent.getExtras();
if (extras != null) {
Bitmap photo = extras.getParcelable("intent");
tampilan.setImageBitmap(photo);
}
File f = new File(mImageCaptureUri.getPath());
if (f.exists()) f.delete();
Run Code Online (Sandbox Code Playgroud)
但是,当我运行代码时,没有任何内容...... TT可以有人帮助我吗?
在我的应用程序中,我将使用四个(x,y)坐标裁剪图像,我还需要在另一个活动屏幕中显示裁剪的图像.例如,在下图中,我想裁剪白色图层本身.所以任何人都提供了在我的项目中完成这项技术的解决方案.
