相关疑难解决方法(0)

如何从GLSurfaceView保存位图(只有位图,而不是整个纹理)

我正在使用此代码对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)

android textures opengl-es bitmap glsurfaceview

6
推荐指数
1
解决办法
2890
查看次数

标签 统计

android ×1

bitmap ×1

glsurfaceview ×1

opengl-es ×1

textures ×1